// JavaScript Document

function NavbarOver(type) {
document.getElementById(type).className='over';
	}


function NavbarDone(type) {
document.getElementById(type).className='';
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function viewall() {
var Pathname = new String(document.location.search+'');
var url = window.location.toString();
var anchor_index = url.indexOf('&DistID');

if (Pathname.indexOf("pagesize=") !=-1) {
	var str=location.search.match(/\bpagesize\= *([^\&]+)/);
	var varid1=str[1];
	var str2=location.search.match(/\bpagenum\= *([^\&]+)/);
	var varid5=str2[1];


self.location=location.search.replace(varid1, 9999);

}

else if (Pathname.indexOf("pagenum") !=-1) {
	self.location=location.search.replace("pagenum=2", "pagenum=1")+'&pagesize=9999&sortEntity=0&SecID=0&DistID=0';
}


else {
	self.location=location+'?pagesize=9999&sortEntity=0&SecID=0&DistID=0';
}

}

function matchcat() {

var Pathname2 = new String(document.location);	
	
	if (Pathname2.indexOf('c-') !=-1) {	
		
var Pathname = new String(document.location.search+'');
		var divs = document.getElementsByTagName("a");
		
		for (i = 0; i < divs.length; i++) {
		  if (divs[i].className == "selected") {
			inner = divs[i].id;
			}
		  }
		var deptname = document.getElementById(inner).id+"-dept";
		var distname = document.getElementById(inner).id+"-dist";
		if (document.getElementById(deptname) != null) {	
			document.getElementById(deptname).className="matched";
		}
		if (document.getElementById(distname) != null) {	
			document.getElementById(distname).className="matched";
		}

	var Pathname = new String(document.location.search+'');
	var url = window.location.toString();

if (Pathname.indexOf('SecID') !=-1) {	
	var str=location.search.match(/\bSecID\= *([^\&]+)/);
	var varid2=str[1];
	document.getElementById(deptname).value = varid2;
}
	
if (Pathname.indexOf('DistID') !=-1) {	
	var str=location.search.match(/\bDistID\= *([^\&]+)/);
	var varid3=str[1];
	document.getElementById(distname).value = varid3;
}


if (document.getElementById('viewall') != null) {
	if (Pathname.indexOf("pagesize=9999") !=-1) {
	document.getElementById("viewall").style.display = "none";
	document.getElementById("viewallbottom").style.display = "none";
	}
	}
	}
	
	}

//Filter Functionality

//Filter Dept

function appenddept(dept) {
var Pathname = new String(document.location.search+'');
var url = window.location.toString();
var anchor_index = url.indexOf('&SecID');

if (Pathname.indexOf("SecID=0") !=-1) {
	self.location=location.search.replace('SecID=0', 'SecID='+dept);

}
else if (Pathname.indexOf("SecID=") !=-1) {
	var str=location.search.match(/\bSecID\= *([^\&]+)/);
	var varid2=str[1];
		self.location=location.search.replace(varid2, dept);
}
else if (Pathname.indexOf("pagenum") !=-1) {
	var str=location.search.match(/\bpagenum\= *([^\&]+)/);
	var varid=str[1];
	self.location=location.search.replace(varid, 1)+'&pagesize=9999&sortEntity=0&SecID='+dept+'&DistID=0';
}
else {
	self.location=location+'?pagesize=9999&sortEntity=0&SecID='+dept+'&DistID=0';
}

}

//Filter Dist

function appenddist(dist) {
	var Pathname = new String(document.location.search+'');
	var url = window.location.toString();
	var anchor_index = url.indexOf('&DistID');



if (Pathname.indexOf("DistID=0") !=-1) {
	self.location=location.search.replace('DistID=0', 'DistID='+dist);

}

else if (Pathname.indexOf("DistID=") !=-1) {
	var str=location.search.match(/\bDistID\= *([^\&]+)/);
	var varid3=str[1];
	
	self.location=location.search.replace(varid3, dist);

}


else if (Pathname.indexOf("pagenum") !=-1) {
	var str=location.search.match(/\bpagenum\= *([^\&]+)/);
	var varid=str[1];
	
	self.location=location.search.replace(varid, 1)+'&pagesize=9999&sortEntity=0&SecID=0&DistID='+dist;
	
}

else {
	self.location=location+'?pagesize=9999&sortEntity=0&SecID=0&DistID='+dist;
}

}




//Sort By Filters

function appendsort(sortentity) {
var Pathname = new String(document.location.search+'');
var url = window.location.toString();
var anchor_index = url.indexOf('&sortEntity');

if (Pathname.indexOf("sortEntity=") !=-1) {
	var str=location.search.match(/\bsortEntity\= *([^\&]+)/);
	var varid4=str[1];
		self.location=location.search.replace(varid4, sortentity);

}
else if (Pathname.indexOf("pagenum") !=-1) {
	self.location=location+'&pagesize=0&sortEntity='+sortentity+'&SecID=0&DistID=0';
}

else {
	self.location=location+'?pagesize=0&sortEntity='+sortentity+'&SecID=0&DistID=0';
}
}


function hideAllDivsFirst() {
		faqD = document.getElementsByTagName('div');
		for(var i=0;i<faqD.length;i++) {
			if(faqD[i].className=="faqTab") {
				faqD[i].style.display = "none";
			}
		}
	}
	function showFAQ(which) {
		hideAllDivsFirst();
		targetDivName = "faq_"+which;
		tabLiName = "tab_"+which;
		document.getElementById(targetDivName).style.display = "block";
	}
	function swapTopTab(whichID,onoff) {
		if(document.getElementById(whichID).className=="tab_sub") document.getElementById(whichID).className = "tab_sub_over";
		else if(document.getElementById(whichID).className=="tab_sub_over") document.getElementById(whichID).className = "tab_sub";
	}
	function hilite(tID) {
var Pathname2 = new String(document.location.href);

if (Pathname2.indexOf("p-") !=-1) {
		
		var allD = document.getElementsByTagName('li');
		for(var j=0;j<allD.length;j++) {
			if(allD[j].className=="tab_sub_selected") {
				allD[j].className = "tab_sub";
			}
		}
		var targetContentDiv = tID.split("_")[1];
		document.getElementById(tID).className = "tab_sub_selected";
		showFAQ(targetContentDiv);
	}
else if (Pathname2.indexOf("measurements") !=-1) {
		
		var allD = document.getElementsByTagName('li');
		for(var j=0;j<allD.length;j++) {
			if(allD[j].className=="tab_sub_selected") {
				allD[j].className = "tab_sub";
			}
		}
		var targetContentDiv = tID.split("_")[1];
		document.getElementById(tID).className = "tab_sub_selected";
		showFAQ(targetContentDiv);
	}



}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function startList() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=function() {
	startList();
	matchcat();

}