var tabArray = new Array();

function clearTabs(){
	if (tabArray.length==0){getTabs();}
	for (i=0;i<tabArray.length ;i++ )
	{
		tempSrc = tabArray[i].src;
		regExp = /_on/gi;
		newSrc = tempSrc.replace(regExp, "");
		tabArray[i].src = newSrc;
	}
}

function setTab(tabNum){
    clearTabs();
	tempSrc = tabArray[tabNum].src;
	regExp = /.gif/gi;
	newSrc = tempSrc.replace(regExp, "_on.gif");
	tabArray[tabNum].src = newSrc;
}

function getTabs(){
	tabfound = 1;
	for (i=0;i<document.images.length ;i++ )
	{
		if (document.images[i].src.indexOf("/tabs/")>-1)
		{
			document.images[i].name = "tab"+tabfound;
			tabfound++
			tabArray[tabArray.length]=document.images[i];
		}
	}
}

function pickPhoto(numberOfPhotos){
    
	tempSrc = document.images["photo"].src;
	srcString = "_";
	imageNum = Math.floor(Math.random()*numberOfPhotos)+1;
	if (imageNum < 10){srcString += "0";}
	srcString += imageNum;
	srcString += ".jpg";
	newSrc = tempSrc.substring(0, tempSrc.indexOf("_"))+srcString;
	document.images["photo"].src = newSrc;

}