document.getElementsByClass=function(tag, classname){
var tagcollect=document.all? document.all.tags(tag): document.getElementsByTagName(tag); //IE5 workaround
var filteredcollect=new Array();
var inc=0;
for (i=0;i<tagcollect.length;i++){
if (tagcollect[i].className==classname)
filteredcollect[inc++]=tagcollect[i];
}
return filteredcollect;
}

// For the global nav
function expandMenu(divName){
contractMenus();
document.getElementById(divName).style.left = 'auto';
}

function contractMenus(){
var divElements=new Array();
divElements=document.getElementsByClass('div','menuList');
var inc=0;
while (divElements[inc]){
divElements[inc].style.position = 'absolute';
divElements[inc].style.left = '-999em';
inc++;
}
}

// For the tabs
function expand(divname, tabname){
contract();
document.getElementById(divname).style.display = 'inline-block';
document.getElementById(tabname).className = 'activetabstyle';
}

function contract(){
var divElements=new Array();
divElements=document.getElementsByClass('div','tabcontent');
tabelements=document.getElementsByClass('div', 'activetabstyle');
var inc=0;
while (divElements[inc]){
divElements[inc].style.display = 'none';
inc++;
}

var tabinc=0;
while(tabelements[tabinc]){
tabelements[tabinc].className= 'tabstyle';
tabinc++;
}
}

// For the Next Gen Melvyl GO button.
function goBtnOn(){
document.getElementById('quicksearch_go').src = 'http://' + window.location.host + '/images/go-on.gif';
}

function goBtnOff(){
document.getElementById('quicksearch_go').src = 'http://' + window.location.host + '/images/go-off.gif';
}

// This is for testing ways to link to a tab.
function changeURL(tabname) {
	parent.location.hash = tabname;
	displayCorrectTab();
}

function displayCorrectTab(){
	var thisURL = window.location.href.split('#');
	if(thisURL[1] != null){
		contract();
		var urlname = thisURL[1].replace(/%20/g, " ");
		document.getElementById(urlname + ' content').style.display = 'inline-block';
		document.getElementById(urlname).className = 'activetabstyle';
	}
}

// For Google maps.

    
    	//append driving "To here" form to a current extra div (curr_div)
    	//long, lat - longtitude and latitude of a marker required.
    	//JL 2/4/2008
    	function to_here(curr_div, long, lat)
    	{
	    	window.status='';
	    	
	    	var me = document.getElementById(curr_div);
	    	
			me.innerHTML = "<b>Driving Directions:</b>";
			me.innerHTML += '&nbsp;&nbsp;<b>To here</b>&nbsp;&nbsp;&nbsp;<a class="maplink" href="javascript:from_here(' + curr_div + ',' + long + ',' + lat + ');">From here</a>';						    	
	    	
         me.innerHTML +=  '<p><b>Start address:</b><form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=60 name="saddr" id="saddr" value="" /><br>' +
           '<input class="button" value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + long + ',' + lat + '"/></p>';       
           
         //myclick(curr_div);                     
    	}
    	
    	//append driving "From here" form to a current extra div (curr_div)
    	//long, lat - longtitude and latitude of a marker required.
    	//JL 2/4/2008    	
    	function from_here(curr_div, long, lat)
    	{
	    	//alert(long + " " + lat);
	    	window.status='';
	    	
	    	var me = document.getElementById(curr_div);
	    	
			me.innerHTML = "<b>Driving Directions:</b>";
			me.innerHTML += '&nbsp;&nbsp;<a class="maplink" href="javascript:to_here(' + curr_div + ',' + long + ',' + lat + ');">To here</a> &nbsp;&nbsp;&nbsp;<b>From here</b>';					
	    		    	
         me.innerHTML +=  '<p><b>End address:</b><form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=60 name="daddr" id="daddr" value="" /><br>' +
           '<input class="button" value="Get Directions" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + long + ',' + lat + '"/></p>';
 		    		    	
         //myclick(curr_div);  
    	}
    	
    	
      //JL 2/4/2008
      // curr_div - current div that holds the "to here - from here" form.
      // div_count - number of markers of the map.
      // long, lat - longtitude and latitude of a marker.
		function toggle_div(curr_div, div_count, long, lat){
			
			//alert(div_count);
			//alert(long + " " + lat);			
			
			var me = document.getElementById(curr_div);
			
			if (me.style.display=="inline-block")
			{
				me.style.display="none";
			}
			else 
			{
				if (me.style.display=="none"){
					me.style.display="inline-block";
						
					//Add inner html stuff here.
					me.innerHTML = "<b>Driving Directions:</b>";
					me.innerHTML += '&nbsp;&nbsp;<a class="maplink" href="javascript:to_here(' + curr_div + ',' + long + ',' + lat + ');">To here</a> &nbsp;&nbsp;&nbsp;<a class="maplink" href="javascript:from_here(' + curr_div + ',' + long + ',' + lat + ');">From here</a>';					
				}
					
					//Close other divs and make only the current div active.
				for(i = 0; i < div_count; i++)
				{
					if(i != curr_div)
						document.getElementById(i).style.display="none";
				}															
			}
		}    



/* This is code for the hmong-textile page */
	PositionX = 100;
	PositionY = 100;
	
	// Set these value approximately 20 pixels greater than the
	// size of the largest image to be used (needed for Netscape)
	
	defaultWidth  = 500;
	defaultHeight = 500;
	
	// Set autoclose true to have the window close automatically
	// Set autoclose false to allow multiple popup windows
	
	var AutoClose = true;
	
	// Do not edit below this line...
	// ================================
	if (parseInt(navigator.appVersion.charAt(0))>=4){
	var isNN=(navigator.appName=="Netscape")?1:0;
	var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
	var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
	var optIE='scrollbars=yes,width=150,height=100,left='+PositionX+',top='+PositionY;
	function popImage(imageURL,imageTitle){
	if (isNN){imgWin=window.open('about:blank','',optNN);}
	if (isIE){imgWin=window.open('about:blank','',optIE);}
	with (imgWin.document){
	writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
	writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
	writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
	writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
	writeln('width=100-(document.body.clientWidth-document.images[0].width);');
	writeln('height=100-(document.body.clientHeight-document.images[0].height);');
	writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
	writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
	writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
	if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="yes" onload="reSizeToImage();doTitle();self.focus()">')
	else writeln('</head><body bgcolor=000000 scroll="yes" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
	writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
	close();		
	}}
/* End of code for hmong-texile page */