function getExt(string){
	imgIndex = string.indexOf('images/');
	actSrc = string.slice(imgIndex); 
	imgFile = actSrc.split('.');
	imgType = imgFile[(imgFile.length - 1)];	
	return imgType;
}

function resetTabs(cls)
{
	var imgcount = document.getElementsByTagName('img');
	for (var i = 0; i < imgcount.length; i++){
		onCls = cls+'on';
		if(imgcount[i].className == onCls){
			img = imgcount[i].getAttribute('src');
			getExt(img);
			var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
			if(ie7 == true)
			{
				origImg = img.slice(0, -6)+"out."+imgType;
			}else{
				origImg = img.slice(0, -7)+"_out."+imgType;
			}
			imgcount[i].setAttribute('src', origImg);
			imgcount[i].className =  cls;
		}
	}
}

function initRollovers()
{
	var imgArray = new Array();
	var imgcount = document.getElementsByTagName('img');
	for (var i = 0; i < imgcount.length; i++)
	{
		// if the class is img, build rollover

		if (imgcount[i].className.toLowerCase().match('img'))
		{
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');//set, in array, name of the original src
			getExt(imgArray[n]);
			
			imgcount[i].onmouseover = function()
			{
				if(!this.className.toLowerCase().match('on'))
				{
					imgOriginSrc = this.getAttribute('src');
					imgNewSrc = imgOriginSrc.slice(0, -8)+"_on."+imgType;
					this.setAttribute('src', imgNewSrc); // set the image
				}
			}
			
			imgcount[i].onmouseout = function() 
			{
				if(!this.className.toLowerCase().match('on'))
				{
					this.setAttribute('src',imgOriginSrc);
				}
	        }
			
			imgcount[i].onclick = function() 
			{
				if(!this.className.toLowerCase().match('on'))
				{
					thisCls = this.className;
					//alert(thisCls);
					resetTabs(thisCls);
					this.className = thisCls+'on';
					
				}
	        }
		}
				
		// if the imgon is set, then make the image static, w/o rollover states
		if (imgcount[i].className == "imgon"){
			var n = imgcount[i].getAttribute('id');
			imgArray[n] = imgcount[i].getAttribute('src');
			getExt(imgArray[n]);
			imgcount[i].src = imgArray[n].slice(0, -8)+"_on."+imgType;
		}
		
	}
}


function hCls(cls)
{
	var hideArr = new Array();
	var hideCount = document.getElementsByTagName('div');
	for (var i = 0; i < hideCount.length; i++)
	{
		if (hideCount[i].className == "info") {
			var n = hideCount[i].getAttribute('id');
			document.getElementById(n).style.display = 'none';
		}
	}
}


function gCls(iid)
{
	var cls = document.getElementById(iid).className;
	return cls;
}

function tabbit(iid)
{
	var cls = gCls(iid);
	hCls(cls);
	document.getElementById(iid).style.display = 'block';
}

window.onload=function(){
initRollovers();
}



/*    									*\
		checkbox script
		searches through the document 
		and toggles checkbox on/off 
		for a checkbox array
\*    									*/

function checkAll(arr, master)
{
	var checkcount = document.getElementsByTagName('input');
	for (var i = 0; i < checkcount.length; i++){
		if(checkcount[i].name.toLowerCase().match(arr)){
			box = checkcount[i].checked = master.checked ? true : false;
		}
	}
}





