// JavaScript Document
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 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 showhide() {
		var Pathname = new String(document.location.pathname+'');
		var Pathname2 = new String(document.location.href);
		var Pathname3 = new String(document.location.search+'');

if (Pathname2.indexOf("c-") !=-1) {
		document.getElementById("shopbycategory").style.display = "none";	
	}
if (Pathname2.indexOf("p-") !=-1) {
		document.getElementById("shopbycategory").style.display = "none";	
	}
if (Pathname2.indexOf("showcategory") !=-1) {
		document.getElementById("shopbycategory").style.display = "none";	
	}


}

function swapPic1() {
var Pathname = new String(document.location+'');
if (Pathname.indexOf("default") !=-1) {

var rand1 = 0;
var useRand = 0;

images = new Array;
images[1] = new Image();
images[1].src = "skins/Skin_1/images/popmovies-1.gif";
images[2] = new Image();
images[2].src = "skins/Skin_1/images/popmovies-2.gif";
images[3] = new Image();
images[3].src = "skins/Skin_1/images/popmovies-3.gif";
images[4] = new Image();
images[4].src = "skins/Skin_1/images/popmovies-4.gif";
images[5] = new Image();
images[5].src = "skins/Skin_1/images/popmovies-5.gif";

var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg1.src = images[useRand].src;
}
}

function swapPic2() {
var Pathname = new String(document.location+'');
if (Pathname.indexOf("default") !=-1) {
var rand1 = 0;
var useRand = 0;

images = new Array;
images[1] = new Image();
images[1].src = "skins/Skin_1/images/popmusic-1.gif";
images[2] = new Image();
images[2].src = "skins/Skin_1/images/popmusic-2.gif";
images[3] = new Image();
images[3].src = "skins/Skin_1/images/popmusic-3.gif";
images[4] = new Image();
images[4].src = "skins/Skin_1/images/popmusic-4.gif";
images[5] = new Image();
images[5].src = "skins/Skin_1/images/popmusic-5.gif";
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg2.src = images[useRand].src;
}
}
function swapPic3() {
var Pathname = new String(document.location+'');
if (Pathname.indexOf("default") !=-1) {
	
var rand1 = 0;
var useRand = 0;

images = new Array;
images[1] = new Image();
images[1].src = "skins/Skin_1/images/poppeople-1.gif";
images[2] = new Image();
images[2].src = "skins/Skin_1/images/poppeople-2.gif";
images[3] = new Image();
images[3].src = "skins/Skin_1/images/poppeople-3.gif";
images[4] = new Image();
images[4].src = "skins/Skin_1/images/poppeople-4.gif";
images[5] = new Image();
images[5].src = "skins/Skin_1/images/poppeople-5.gif";
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg3.src = images[useRand].src;
}
}

function appendsection() {
	var Pathname = new String(document.location.pathname+'');
		var str = location.href
		var number_1 = str.lastIndexOf('s-') + 2
		var number_2 = str.lastIndexOf('-')
		var myVar = str.substring(number_1, number_2) 
	
	if (Pathname.indexOf("s-") !=-1) {
		document.getElementById("art-link").href = document.getElementById("art-link").href+"?SecID="+myVar;
		document.getElementById("childrens-link").href = document.getElementById("childrens-link").href+"?SecID="+myVar;
		document.getElementById("college-link").href = document.getElementById("college-link").href+"?SecID="+myVar;
		document.getElementById("education-link").href = document.getElementById("education-link").href+"?SecID="+myVar;
		document.getElementById("movies-link").href = document.getElementById("movies-link").href+"?SecID="+myVar;
		document.getElementById("music-link").href = document.getElementById("music-link").href+"?SecID="+myVar;
		document.getElementById("people-link").href = document.getElementById("people-link").href+"?SecID="+myVar;
		document.getElementById("places-link").href = document.getElementById("places-link").href+"?SecID="+myVar;
		document.getElementById("sports-link").href = document.getElementById("sports-link").href+"?SecID="+myVar;
		document.getElementById("television-link").href = document.getElementById("television-link").href+"?SecID="+myVar;
		document.getElementById("misc-link").href = document.getElementById("misc-link").href+"?SecID="+myVar;
		
	}
	
}
function appendfilter(value) {
var Pathname = new String(document.location.search+'');
	self.location=self.location.protocol+'//'+self.location.host+self.location.pathname+'?DistID='+value;

var str=location.search.match(/\bSearchTerm\= *([^\&]+)/);
var varid=str[1];

if (Pathname.indexOf("SearchTerm") !=-1) {
	self.location=self.location.protocol+'//'+self.location.host+self.location.pathname+self.location.search+'&DistID='+value;
}
if (Pathname.indexOf("pagesize") !=-1) {
	self.location=self.location.protocol+'//'+self.location.host+self.location.pathname+self.location.search+'&pagesize='+value;
}
if (Pathname.indexOf("pagenum") !=-1) {
	var str=location.search.match(/\bpagenum\= *([^\&]+)/);
	var varid=str[1];
	self.location=self.location.protocol+'//'+self.location.host+self.location.pathname+self.location.search.replace('&pagenum='+varid, "")+'&SecID='+value;
}


else if (Pathname.indexOf("DistID=00") !=-1) {
	self.location=location.search.replace(/0/, value);	
}

else if (Pathname.indexOf("DistID=01") !=-1) {
	self.location=location.search.replace(/1/, value);	
}

else if (Pathname.indexOf("DistID=02") !=-1) {
	self.location=location.search.replace(/2/, value);	
}

else if (Pathname.indexOf("DistID=03") !=-1) {
	self.location=location.search.replace(/3/, value);	
}

else if (Pathname.indexOf("DistID=04") !=-1) {
	self.location=location.search.replace(/4/, value);	
}

else if (Pathname.indexOf("DistID=05") !=-1) {
	self.location=location.search.replace(/5/, value);	
}

else if (Pathname.indexOf("DistID=06") !=-1) {
	self.location=location.search.replace(/6/, value);	
}

else if (Pathname.indexOf("DistID=07") !=-1) {
	self.location=location.search.replace(/7/, value);	
}

}

function setfilter() {
		var Pathname = new String(document.location+'');
		var str = location.href
		var number_1 = str.lastIndexOf('ID=') + 3
		var number_2 = str.lastIndexOf('-')
		var myVar = str.substring(number_1) 
if (Pathname.indexOf("c-") !=-1) {
	document.deptfilter.filtermenu.options.selectedIndex = myVar;
}
}

	window.onload=function(){
		showhide();
		appendsection();
		setfilter();
		swapPic1();
		swapPic2();
		swapPic3();
	}
	
	
