// JavaScript Document
//Picture Rotator v1.0
//©2004 Chadwick Anderson

//get the filename of the current page
var fileName = location.href.substring(location.href.lastIndexOf('/')+1);
var prot = location.protocol;
//alert(prot);

//random image generator
//num = A + (B-A)*Math.random()  // num is random, from A to B
var imageNum;
imageNum = 1 + (6-1)*Math.random();
imageNum = Math.round(imageNum);

  var anchorString=""
  var queryString=""
function getCatID() {
    // First, get the anchor reference off the URL, if there is one.
    theURL = ""+document.location;
    queryIndex = theURL.indexOf("?");
    if (queryIndex >= 0) {
		queryString = theURL.substring(queryIndex+1, theURL.length);
        anchorString = theURL.substring(queryIndex+1, theURL.length);
    }
    else {
        return;
    }
}

getCatID();

function switchPic(){
	switch(anchorString){
		case"CategoryID=9":{document.leftPic.src="/Images/pics/pic4.jpg";break;} //specials
		case"CategoryID=5":{document.leftPic.src="/Images/pics/pic5.jpg";break;} //out and proud
		case"CategoryID=4":{document.leftPic.src="/Images/pics/pic1.jpg";break;} //men's store
		case"CategoryID=7":{document.leftPic.src="/Images/pics/pic3.jpg";break;} //outgifts
		case"CategoryID=6":{document.leftPic.src="/Images/pics/pic6.jpg";break;} //woman's store
		case"CategoryID=8":{document.leftPic.src="/Images/pics/pic2.jpg";break;} //commitment
	}
}

function pickPicture(){
var switched=false;

	switch(fileName){
		case"SearchResult.aspx?CategoryID=9":{document.leftPic.src="/Images/pics/pic4.jpg";switched=true;break;} //specials
		case"SearchResult.aspx?CategoryID=5":{document.leftPic.src="/Images/pics/pic5.jpg";switched=true;break;} //out and proud
		case"SearchResult.aspx?CategoryID=4":{document.leftPic.src="/Images/pics/pic1.jpg";switched=true;break;} //men's store
		case"SearchResult.aspx?CategoryID=7":{document.leftPic.src="/Images/pics/pic3.jpg";switched=true;break;} //outgifts
		case"SearchResult.aspx?CategoryID=6":{document.leftPic.src="/Images/pics/pic6.jpg";switched=true;break;} //woman's store
		case"SearchResult.aspx?CategoryID=8":{document.leftPic.src="/Images/pics/pic2.jpg";switched=true;break;} //commitment
	}
	if(switched==false){
		//alert("pick not picked");
		document.leftPic.src="/Images/pics/pic" + imageNum + ".jpg";
	}
}

pickPicture();