// JavaScript Document

function leftNavHighlight(){
	leftNav = document.getElementById('siteLeftNav');
	
	
	if(leftNav){
		leftNavLinks = leftNav.getElementsByTagName('a');
		
		for(i=0;i<leftNavLinks.length;i++){
		
			if(leftNavLinks[i].href == location.href || leftNavLinks[i]+"default.aspx" == location.href || leftNavLinks[i] == location.href+"default.aspx"){
				leftNavLinks[i].className="mmhide_active";	
			}
			
		}
	}
}

function subNavHighlight(){
	
	subNav = document.getElementById('siteSubNav');
	currentPage = window.location.href;
	
	if(subNav){
		subNavLinks = subNav.getElementsByTagName('a');
			
		for(h=0;h<subNavLinks.length;h++){
		
			//get the last folder in nav link
			tmpSplitLink = subNavLinks[h].href.split("/");	
			while(tmpSplitLink[tmpSplitLink.length-1].lastIndexOf('.aspx') > 0 || tmpSplitLink[tmpSplitLink.length-1]==""){
				tmpSplitLink.pop();
			}
			
			//get the last folder in the current location
			currentSplitLink = currentPage.split("/");
			while(currentSplitLink[currentSplitLink.length-1].lastIndexOf('.aspx') > 0 || tmpSplitLink[currentSplitLink.length-1]==""){
				currentSplitLink.pop();
			}
			
			//even the arrays	
			while(currentSplitLink.length > tmpSplitLink.length){
				currentSplitLink.pop();	
			}
			while(tmpSplitLink.length > currentSplitLink.length){
				tmpSplitLink.pop();	
			}
			
			
			//alert(tmpSplitLink + " : " + currentSplitLink);
			
			//see if they're a match
			matchFound=true;
			for(m=0;m<tmpSplitLink.length;m++){
				
				if(tmpSplitLink[m]!=currentSplitLink[m]){
					
					matchFound=false;
				}
			}
			if(matchFound){
				subNavLinks[h].className="mmhide_active";		
			}
			//alert(tmpSplitLink.length + " : " + currentSplitLink.length);
		}
	}
}


function inputStyles(){
	pageInputs = document.getElementsByTagName('input');
	
	
	//style buttons
	for(pi=0;pi<pageInputs.length;pi++){
		if(pageInputs[pi].type=='submit' || pageInputs[pi].type=='reset' || pageInputs[pi].type=='button'){
			pageInputs[pi].className="input-button";
		}else if(pageInputs[pi].type=="checkbox" || pageInputs[pi].type=="radio"){
			pageInputs[pi].className="input-checkbox";	
		}
	}
	
}


function searchSite(){
	searchInput = document.getElementById('siteSearchInput');
	if(searchInput && searchInput.value!='search' && searchInput.value!=''){
		window.location='/search/?q='+searchInput.value;
	}else{
		alert("Not a valid search.");	
		searchInput.value='';
		searchInput.focus();
	}
}