function MyAccountlogout(strTargetURL) {
	bProduction = false;
	var sTopPath = top.location.href;

	var sCheckDomain = sTopPath.substring(0, sTopPath.indexOf("/", 10));
	if ((sCheckDomain == "https://www.smartone-vodafone.com") || (sCheckDomain == "http://www.smartone-vodafone.com") || (sCheckDomain == "http://smartone-vodafone.com") || (sCheckDomain == "http://www.smartonevodafone.com.hk") || (sCheckDomain == "http://smartonevodafone.com.hk") || (sCheckDomain == "http://www.smartonevodafone.com") || (sCheckDomain == "http://smartonevodafone.com") || (sCheckDomain == "http://www.smartone.com.hk") || (sCheckDomain == "http://smartone.com.hk") || (sCheckDomain == "http://www.smartone-vodafone.com.hk") || (sCheckDomain == "http://smartone-vodafone.com.hk")) {
		bProduction = true;
	}

	if (sTopPath.indexOf("/english/") > -1) {
		ret = confirm("Are you sure you want to logout?");
		if (ret) {
			if (bProduction) {
				location = "https://myaccount.smartone-vodafone.com/servlet/mya_logout?language=E&dest_url=" + strTargetURL;
			} else {
				location = "http://cagdemo.smartone-vodafone.com/servlet/mya_logout?language=E&dest_url=" + strTargetURL;
			}
		}
	} else {
		ret = confirm("你是否確定要登出?");
		if (ret) {
			if (bProduction) {
				location = "https://myaccount.smartone-vodafone.com/servlet/mya_logout?language=C&dest_url=" + strTargetURL;
			} else {
				location = "http://cagdemo.smartone-vodafone.com/servlet/mya_logout?language=C&dest_url=" + strTargetURL;
			}
		}
	}
}

function AnCharlogout(strTargetURL) {
	bProduction = false;
	var sTopPath = top.location.href;

	var sCheckDomain = sTopPath.substring(0, sTopPath.indexOf("/", 10));
	if ((sCheckDomain == "https://www.smartone-vodafone.com") || (sCheckDomain == "http://www.smartone-vodafone.com") || (sCheckDomain == "http://smartone-vodafone.com") || (sCheckDomain == "http://www.smartonevodafone.com.hk") || (sCheckDomain == "http://smartonevodafone.com.hk") || (sCheckDomain == "http://www.smartonevodafone.com") || (sCheckDomain == "http://smartonevodafone.com") || (sCheckDomain == "http://www.smartone.com.hk") || (sCheckDomain == "http://smartone.com.hk") || (sCheckDomain == "http://www.smartone-vodafone.com.hk") || (sCheckDomain == "http://smartone-vodafone.com.hk")) {
		bProduction = true;
	}

	if (sTopPath.indexOf("/english/") > -1) {
		ret = confirm("Are you sure you want to logout?");
		if (ret) {
			if (bProduction) {
				if (strTargetURL.indexOf("http://") == -1) {
					strTargetURL = "http://www.smartone-vodafone.com/" + strTargetURL;
				}
				location = "https://download.smartone-vodafone.com/jsp/AnimationChar/english/animation_char_logout.jsp?dest_url=" + strTargetURL;
			} else {
				if (strTargetURL.indexOf("http://") == -1) {
					strTargetURL = "http://webstage1.smartone-vodafone.com/" + strTargetURL;
				}
				location = "http://202.140.96.137/jsp/AnimationChar/english/animation_char_logout.jsp?dest_url=" + strTargetURL;
			}
		}
	} else {
		ret = confirm("你是否確定要登出?");
		if (ret) {
			if (bProduction) {
				if (strTargetURL.indexOf("http://") == -1) {
					strTargetURL = "http://www.smartone-vodafone.com/" + strTargetURL;
				}
				location = "https://download.smartone-vodafone.com/jsp/AnimationChar/tchinese/animation_char_logout.jsp?dest_url=" + strTargetURL;
			} else {
				if (strTargetURL.indexOf("http://") == -1) {
					strTargetURL = "http://webstage1.smartone-vodafone.com/" + strTargetURL;
				}
				location = "http://202.140.96.137/jsp/AnimationChar/tchinese/animation_char_logout.jsp?dest_url=" + strTargetURL;
			}
		}
	}
}

// Change language
function ChangeLang() {
       var sTopPath = top.location.href;

       if (sTopPath .indexOf("/english/") > -1) {
               sTopPath = sTopPath .replace("/english/", "/tchinese/");
               sTopPath = sTopPath .replace("lang=english", "lang=tchinese");
       } else {
               sTopPath = sTopPath .replace("/tchinese/", "/english/");
               sTopPath = sTopPath .replace("lang=tchinese", "lang=english");
       }

       top.location.href = sTopPath ;
}
//backlink for logo
function backlinkMe(statusMe,lang){
	//var popWidth=screen.width-40;
		if (screen.width>800){
		var popHeight=520 ;
		var popWidth=790 ;
	}else{
		var popHeight=400 ;
		var popWidth=620 ;
	}
lang=="eng"?lang="english":lang="tchinese";
// test if opener exist
	 try {
	if (!window.opener || window.opener.closed){
		if (statusMe=="live"){
		var mynewwin=window.open("http://www.smartone-vodafone.com/jsp/"+lang+"/index.jsp","mainWin");
		}else{
		var mynewwin=window.open("http://webstage1.smartone-vodafone.com/jsp/"+lang+"/index.jsp","mainWin");
		}
		mynewwin.focus();		
	}else{	
		if (statusMe=="live"){
		window.opener.location="http://www.smartone-vodafone.com/jsp/"+lang+"/index.jsp";
		}else{
		window.opener.location="http://webstage1.smartone-vodafone.com/jsp/"+lang+"/index.jsp";
		}
		window.opener.focus();	
	}		
	} catch (error) {
  		if (statusMe=="live"){
		//var mynewwin=window.open('http://www.smartone-vodafone.com/jsp/'+lang+'/index.jsp','mainWin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+popWidth+',height='+popHeight+'\'');
		var mynewwin=window.open("http://www.smartone-vodafone.com/jsp/"+lang+"/index.jsp","mainWin","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+popWidth+",height="+popHeight+"\"");
		}else{
		//var mynewwin=window.open('http://webstage1.smartone-vodafone.com/jsp/'+lang+'/index.jsp','mainWin','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+popWidth+',height='+popHeight+'\'');
		var mynewwin=window.open("http://webstage1.smartone-vodafone.com/jsp/"+lang+"/index.jsp","mainWin","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+popWidth+",height="+popHeight+"\"");
		}
		mynewwin.focus();	
	 }
}
// random images
var Slide = 0;
//var albumArr = "";
var speedBanner = Math.round(500 / 75);
var maxOpacityBanner = 100;
var myGalImg = 0;
var img = 0;
var myAuto = false;
var t = null;
function killAuto(){
	//myAuto = true;
	myAuto=false;
	clearInterval(t);
}
function fadeOutbanner(id, speedBanner, maxOpacityBanner, dir){
/*if (myAuto==true){
do {
 img1=Math.floor(Math.random()*albumArr.length-1)-1;
} while (img1==img);
img= img1;
}*/
img+=dir;
if (img == albumArr.length){
	img = 0;
	}else if (img <0){
	img = albumArr.length-1;
}
if (myGalImg != img){
	myGalImg = img;
    var timer = 0;
    for (var i = maxOpacityBanner; i >= 20; i--) {
        setTimeout("changeOverlayOpacbanner(" + i + ",'" + id + "')", (timer * speedBanner));
        timer++;
    }
	}
}

function fadeInbanner(id, speedBanner, maxOpacityBanner){
	//MM_showHideLayers('popUpWindow','','hide');
	/*if (myAuto == true){
		myAuto=false;
		clearInterval(t);
		}*/
   document.getElementById(id).style.display = '';
    //document.mainimg.src = "images09/album09/"+albumArr[myGalImg];
	document.mainimg.src = "/homeflash/flashimage/"+myLang+"/"+albumArr[myGalImg];
	if (mySection=="main"){
		document.b1.src="/iPhone/common/i_1.gif";
		document.b2.src="/iPhone/common/i_2.gif";
		document.b3.src="/iPhone/common/i_3.gif";
		document.b4.src="/iPhone/common/i_4.gif";
		switch(myGalImg){
			case 0:document.b1.src="/iPhone/common/i_1_over.gif";
					break;
			case 1:document.b2.src="/iPhone/common/i_2_over.gif";
					break;
			case 2:document.b3.src="/iPhone/common/i_3_over.gif";
					break;
			case 3:document.b4.src="/iPhone/common/i_4_over.gif";
					break;
		}
	}
    var timer = 0;
	Slide = myGalImg;
    for (var i = 21; i <= maxOpacityBanner; i++) {
        setTimeout("changeOverlayOpacbanner(" + i + ",'" + id + "')", (timer * speedBanner));
        timer++;
    }
    //document.getElementById('popUpWindow').style.display = "block";
    //displayPopUpwindow();
};

function changeOverlayOpacbanner(opacity, id){

    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";

    if (opacity == 20) {
	fadeInbanner('mainimg', speedBanner, maxOpacityBanner);
    }
}
function gotoImg(which){
	var myD = which -Slide;
	myAuto = false;
	clearInterval(t);
	fadeOutbanner('mainimg', speedBanner, maxOpacityBanner, myD);
	t = setInterval ("advImg()", 4000);
}
function advImg(){
	fadeOutbanner('mainimg', speedBanner, maxOpacityBanner, 1);
}
var myLang = "";
var mySection = "";
function autoImg(lang, section){
	mySection = section;
	//if (section =="main"){
		//albumArr = new Array('smartphone_xmas_i.jpg','mbbplan_i.jpg','hpp_i.jpg','hbb_i.jpg');
	//}
	myLang = lang;
	if (myAuto == false){
	myAuto = true;
	t = setInterval ("advImg()", 4000);
	}
}
//random vdo

var vdoArr = new Array('../images/common/vdo_demo.jpg','../images/common/vdo_girlfriendgo.jpg','../images/common/vdo_wildcity.jpg');
function randV(lang){
	Slide = Math.ceil(Math.random()*vdoArr.length-1);
	myLang = lang;
	document.vdoimg.src=vdoArr[Slide];
}

//