// JavaScript Document


function g_EBI(id)
{ //element by id
	var el = document.getElementById(id)
	if(el)
		return el;
	else
		return;
}






var imageNames = new Array();
var imageSrcs = new Array();

addImageToPreload( "/images/BM_web_button00.gif" );
addImageToPreload( "/images/BM_web_button01.gif" );
addImageToPreload( "/images/BM_web_button02.gif" );
addImageToPreload( "/images/BM_web_button03.gif" );
addImageToPreload( "/images/BM_web_button04.gif" );
addImageToPreload( "/images/BM_web_button05.gif" );

addImageToPreload( "/images/BM_www00_img.jpg" );
addImageToPreload( "/images/BM_www01_img.jpg" );
addImageToPreload( "/images/BM_www02_img.jpg" );
addImageToPreload( "/images/BM_www03_img.jpg" );
addImageToPreload( "/images/BM_www04_img.jpg" );
addImageToPreload( "/images/BM_www05_img.jpg" );

function addImageToPreload(imgStr)
{
//NOTE: if the name or arguments of 'addImageToPreload' changes we need to change the function getPreloadFileList()
	var currMax = imageNames.length;
	imageSrcs[currMax] = new Image;
	imageNames[currMax] = imgStr;
}
function doImageLoad(id, bool)
{
	//if the bool is true then move to next image if there are more, wait 2 secs and go to main page if done loading, otherwise just reloop this function
	if(bool)
	{
		id++;
		if(id < imageNames.length)
		{
			imageSrcs[id].src = imageNames[id];
			setTimeout("doImageLoad(" + id + ", false);", 10);
		}
	}
	else
	{
		if(imageSrcs[id].complete) //do next
			setTimeout("doImageLoad(" + id + ", true);", 10);
		else //wait for same
			setTimeout("doImageLoad(" + id + ", false);", 10);
	}
	
}
doImageLoad(0, true);




var minOpac = 30;
var maxOpac = 100;
function initDisplay()
{
	setItemOpac('www01', minOpac);
	setItemOpac('www02', minOpac);
	setItemOpac('www03', minOpac);
	setItemOpac('www04', minOpac);
	setItemOpac('www05', minOpac);
}

function setItemOpac(id, opac)
{
	if(!g_EBI(id)) return;
	setOpacity(g_EBI(id), opac);
}

function setOpacity(obj, opacity) 
{
	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}


var currSelID = 'www00';
function setBtn(el, way)
{
	if(!g_EBI(el.id)) return;
	if(el.id==currSelID) return;


	setBtnOnOff(el, way);

}

function setBtnOnOff(el, way)
{
	if(!el || !g_EBI(el.id)) return;
	if(way==0)
		setOpacity(el, minOpac);
	else
		setOpacity(el, maxOpac);
}

function clickBtn(el)
{
	var imgEl = g_EBI('main_img');
	if(!imgEl) return;

	if(el.id==currSelID) return;

	if(g_EBI(currSelID)) 
	{
		g_EBI(currSelID).src = "/images/BM_" + currSelID + "_btn.gif";
		setOpacity(g_EBI(currSelID), minOpac);
	}

	currSelID = el.id;

	el.src = "/images/BM_" + el.id + "_btn_D.gif";
	imgEl.src = "/images/BM_" + el.id + "_img.jpg";
	
}

