/*
Blue Shift Inc Website Javascript

BSI image rollover effect

Copyright Max Johnson 2007
*/

/*
if( document.images )
{
}*/

function BSIImageSwapAttach()
{
	if( !document.getElementsByTagName ){ return false;}
	var arrImages = document.getElementsByTagName("img");
	for( i=0; i<arrImages.length; i++ )
	{
		arrImages[i].swapOver = BSIImageSwapOver;
		arrImages[i].swapOut = BSIImageSwapOut;
	}
}
function BSIImageSwap()
{
	var currSrc = this.src;
	if( !currSrc ){return;}
	var imageFileName;
	var imageFileExt;
	
	// strip out just the file name w/out path, extension, or "-over" //
	if( currSrc.match("-over.") )
	{
		imageFileExt = currSrc.substring(currSrc.lastIndexOf("."), currSrc.length);
		imageFileName = currSrc.substring(currSrc.lastIndexOf("/")+1, currSrc.lastIndexOf("-"));
		imageFileName += imageFileExt;
	}
	else
	{
		imageFileExt = currSrc.substring(currSrc.lastIndexOf("."), currSrc.length);
		imageFileName = currSrc.substring(currSrc.lastIndexOf("/")+1, currSrc.lastIndexOf("."));
		imageFileName += "-over" + imageFileExt;
	}
	
	this.src = gRootDir + "/images/" + imageFileName;
}

function BSIImageSwapOver()
{
	var currSrc = this.src;
	//display("SwapOver: " +  this.src);
	if( currSrc )
	{
		//if image is spacer.gif, skip //
		if ( new RegExp("spacer").test(currSrc)){
			if( this.realSrc != "" )
			{
				currSrc = this.realSrc;
			}
			else
			{
				return;
			}
		}
		
		var imageFileExt = currSrc.substring(currSrc.lastIndexOf("."), currSrc.length);
		var imageFileName = currSrc.substring(currSrc.lastIndexOf("/")+1, currSrc.lastIndexOf("."));
		
		if( imageFileName && !imageFileName.match("-over") )
		{
			imageFileName += "-over" + imageFileExt;
			this.src = gRootDir + "images/" + imageFileName;
		}
	}
}
function BSIImageSwapOut()
{
	var currSrc = this.src;
	if( currSrc )
	{	
		//if image is spacer.gif, skip //
		if ( new RegExp("spacer").test(currSrc)){
			if( this.realSrc )
			{
				currSrc = this.realSrc;
			}
			else
			{
				return;
			}
		}
		
		var imageFileExt = currSrc.substring(currSrc.lastIndexOf("."), currSrc.length);
		var imageFileName = currSrc.substring( currSrc.lastIndexOf("/")+1, currSrc.lastIndexOf("-") );
		
		if( imageFileName && currSrc.match("-over") )
		{
			imageFileName += imageFileExt;
			this.src = gRootDir + "images/" + imageFileName;	
		}
	}
}