
function reloadPics() {	
	//Pictures Preload Begin
	var oDiv = document.createElement('div');
	var addImgFunc = function(_img){
		var oImg = document.createElement('img');
		oImg.src = _img;
		oDiv.appendChild(oImg);
	};
	addImgFunc('/Launch/images/launchBG.gif');
	addImgFunc('/Launch/images/launchBtn.gif');
	addImgFunc('/Launch/images/logo_T6.gif');
	addImgFunc('/Launch/images/btnBG.gif');
	addImgFunc('/Launch/images/ibtSwitch.gif');
	addImgFunc('/Launch/images/imgMenuItemBG_T4.gif');
	document.body.appendChild(oDiv);
	oDiv.style.visibility = 'hidden';
	oDiv.style.display = 'none';
	//Pictures Preload Ended 
}

//mouse effect
var btnMouseOverChina	= function(){
	this.style.backgroundPosition = "-210px 0";
};
var btnMouseOutChina	= function(){
	this.style.backgroundPosition = "0 0";
};
var btnMouseOverUSA		= function(){
	this.style.backgroundPosition = "-210px -50px";
};
var btnMouseOutUSA		= function(){
	this.style.backgroundPosition = "0 -50px";
};
var divSwitchDropOver	= function(){
	this.style.backgroundPosition = "right -21px";
};
var divSwitchDropOut	= function(){
	this.style.backgroundPosition = "right 0";
};

//menu events' define
function menuEvents(obj)
{
	var ua = navigator.userAgent.toLowerCase();
	var isOpera = ua.indexOf("opera") > -1;
	var isIE = !isOpera && ua.indexOf("msie") > -1;
	var liObj = obj.getElementsByTagName("li");

	var setWidth = function(_obj) 
	{
		var getWidth = function(_aObj) 
		{
			if(_aObj) 
			{				
				var divObj = document.createElement('div');
				divObj.style.position = 'absolute';
				divObj.style.width = 'auto';
				divObj.style.visibility = 'hidden';
				document.body.appendChild(divObj);
			
				var text = _aObj.innerHTML;
				divObj.innerHTML = text;
				var fontSize = _aObj.currentStyle['fontSize'];
				var fontStyle = _aObj.currentStyle['fontStyle'];
				var fontWeight = _aObj.currentStyle['fontWeight'];
				var fontFamily = _aObj.currentStyle['fontFamily'];
				var lineHeight =_aObj.currentStyle['lineHeight'];
				
				divObj.style.fontSize = fontSize;
				divObj.style.fontStyle = fontStyle;
				divObj.style.fontWeight = fontWeight;
				divObj.style.fontFamily = fontFamily;
				divObj.style.lineHeight = lineHeight;
				
				var width = divObj.offsetWidth;
				return width;
			}else 
			{
				return -1;
			}
		};
		// add 40px to leave padding space
		if(_obj.firstChild.tagName.toLowerCase() == 'a') 
		{
			_obj.style.width = getWidth(_obj.firstChild) + 40 + 'px';
		}
	};		//end of method getWidth
	
	for (var i=0; i<liObj.length; i++)
	{
		if(isIE) 
		{
			setWidth(liObj[i]);
			if (liObj[i].className.length > 0)
			{
				liObj[i].onmouseover=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
					setWidth(this);
				};
				liObj[i].onMouseDown=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
					setWidth(this);
				};
				liObj[i].onMouseUp=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
					setWidth(this);
				};
				liObj[i].onmouseout=function(){
					this.className=this.className.replace(new RegExp("( ?|^)lihover\\b"), "");
					setWidth(this);
				};
			}
		}else 
		{
			if (liObj[i].className.length > 0)
			{
				liObj[i].onmouseover=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
				};
				liObj[i].onMouseDown=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
				};
				liObj[i].onMouseUp=function(){
					this.className+=(this.className.length>0? " ": "") + "lihover";
				};
				liObj[i].onmouseout=function(){
					this.className=this.className.replace(new RegExp("( ?|^)lihover\\b"), "");
				};
			}
		}
	}
}

//Page Initializtion Ended
var initLaunch = function( intLang )
{	
	menuEvents(document.getElementById("ulSwitch"));
	reloadPics();
	//mouse effect
	if(document.getElementById("btnLaunchChina") != null) {
		var btnLaunchChina = document.getElementById("btnLaunchChina");
		btnLaunchChina.onmouseover	=	btnMouseOverChina;
		btnLaunchChina.onmouseout	=	btnMouseOutChina;
		btnLaunchChina.onmousedown	=	btnMouseOutChina;
	}
	if(document.getElementById("btnLaunchUSA") != null) {
		var btnLaunchUSA = document.getElementById("btnLaunchUSA");
		btnLaunchUSA.onmouseover	=	btnMouseOverUSA;
		btnLaunchUSA.onmouseout		=	btnMouseOutUSA;
		btnLaunchUSA.onmousedown	=	btnMouseOutUSA;
	}
	if(document.getElementById("divSwitchDropIcon") != null) {
		var divSwitchDropIcon = document.getElementById("divSwitchDropIcon");
		divSwitchDropIcon.onmouseover	=	divSwitchDropOver;
		divSwitchDropIcon.onmouseout	=	divSwitchDropOut;
		divSwitchDropIcon.onmousedown	=	divSwitchDropOver;
	}
	if(document.getElementById("divLaunchLogo") != null) {
		var divLaunchLogo = document.getElementById("divLaunchLogo");
		switch (intLang)
		{
			case 0:		//en
				divLaunchLogo.style.backgroundPosition = "0 0";
				break;
			case 1:		//de
				divLaunchLogo.style.backgroundPosition = "0 0";
				break;
			case 2:		//es
				divLaunchLogo.style.backgroundPosition = "0 -80px";
				break;
			case 3:		//fr
				divLaunchLogo.style.backgroundPosition = "0 -160px";
				break;
			case 4:		//ja
				divLaunchLogo.style.backgroundPosition = "0 -240px";
				break;
			case 5:		//ko
				divLaunchLogo.style.backgroundPosition = "0 -320px";
				break;
			case 6:		//ru
				divLaunchLogo.style.backgroundPosition = "0 0";
				break;
			case 7:		//cn
				divLaunchLogo.style.backgroundPosition = "0 -400px";
				break;
			case 8:		//tw
				divLaunchLogo.style.backgroundPosition = "0 -480px";
				break;
			default:	//en
				divLaunchLogo.style.backgroundPosition = "0 0";
				break;
		}
	}
};

function launch(country)
{
	document.getElementById('country').value = country;
	document.getElementById('launchForm').submit();
};
