<!--

// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function changeLanguage(newLanguage) {
   var curLoc = parent.location.href;

   if (curLoc.indexOf("gate/gb/") != -1) 
   {
	   	
	 	curLoc = curLoc.substring(29);
		//curLoc = curLoc.substring(32);
		curLoc = "ht" + "tp://" + curLoc;
		curLoc = curLoc.replace("big5","gb");
   }

   var arrlen = 3;
   var arr = new Array(arrlen);
   arr[0] = "eng";
   arr[1] = "big5";
   arr[2] = "gb";
   
   // Get the new language index in the array first
   var newpos = -1;
   for (i = 0; i < arrlen; i++)
   {
   	if (arr[i] == newLanguage)
   	{
   		newpos = i;
   		break;	
   	}
   }
   
   // Get the old language index second
   var oldpos = -1;
   for (i = 0; i < arr.length; i++)
   {
   	tmplanguage = "/" + arr[i];
   	if (curLoc.indexOf(tmplanguage) > 0)
   	{
   		oldpos = i;
   		break;	
   	}
   }
   
   var tmplen = 0;
	
   if (oldpos != newpos)
   {
		tmplanguage = "/" + arr[oldpos];
		tmplen = tmplanguage.length;
		var docPos = curLoc.indexOf(tmplanguage);
   
	   var pathPart = curLoc.substring(-5, docPos+1);
	   var docPart = curLoc.substring(docPos+tmplen);
	
	   if (newLanguage == "gb") 
	   {
			if (curLoc.indexOf("/eng") != -1) 
			{
				var big5Path = "big5" + docPart;
				eval("parent.location='http://203.186.61.70/gate/gb/www.karrie.com.hk/" + big5Path + "'");
			} 
			else 
			{
				curLoc = curLoc.substring(7);
				eval("parent.location='http://203.186.61.70/gate/gb/" + curLoc + "'");
			}
	   } 
	   else 
	   {
			eval("parent.location='" + pathPart + newLanguage + docPart + "'");
	   }
	}
}

function emailCheck(field) {
	var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@&_-.0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	hasAt = 0;
	hasDot = false;
	for (var i=0; i<field.value.length-1; i++) {
			if ((i >= 1) && (field.value.substring(i, i+1) == '@') && (field.value.substring(i+1, i+2) != '.')) // return true if it contains @ but not @.
				{
					hasAt = hasAt + 1;
				}
			if ((hasAt == 1) && (field.value.substring(i, i+1) == '.') && (i != field.value.length-1) && (field.value.substring(i+1, i+2) != '.') && (field.value.substring(i-1, i) != '.')) // return true if the pattern contains . after @ but not ..
				{
				hasDot = true;
				}
	}
	if ((hasAt == 1) && (hasDot) && (field.value.substring(field.value.length-1, field.value.length) != '.')) // return true if the pattern is *@*.*
	{
	}
	else 
	{
		ok = "no";
	}
	if (ok == "no") {
		alert("Sorry! Your email address is not valid!");
		field.focus();
		field.select();
		return false;
	}
}

function emailCheckBig5(field) {
	var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@&_-.0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	hasAt = 0;
	hasDot = false;
	for (var i=0; i<field.value.length-1; i++) {
			if ((i >= 1) && (field.value.substring(i, i+1) == '@') && (field.value.substring(i+1, i+2) != '.')) // return true if it contains @ but not @.
				{
					hasAt = hasAt + 1;
				}
			if ((hasAt == 1) && (field.value.substring(i, i+1) == '.') && (i != field.value.length-1) && (field.value.substring(i+1, i+2) != '.') && (field.value.substring(i-1, i) != '.')) // return true if the pattern contains . after @ but not ..
				{
				hasDot = true;
				}
	}
	if ((hasAt == 1) && (hasDot) && (field.value.substring(field.value.length-1, field.value.length) != '.')) // return true if the pattern is *@*.*
	{
	}
	else 
	{
		ok = "no";
	}
	if (ok == "no") {
		alert("¹q¶l¦a§}¿ù»~¡I");
		field.focus();
		field.select();
		return false;
	}
}

function mainSectionhighlight() { 
	if (mainSection != "") {
	   document.getElementById(mainSection + "btn").src = "../images/global/mainselectedpoint.gif";
	} 
}

function subNavhighlight() { 
	if (subSection != "") {
		if (subSection.substr(subSection.length-2, 2) == "IR") {
	   		document.getElementById(subSection).className = "IRsubLeftNavSelected";
		}
		else if (subSection.substr(subSection.length-1, 1) == "1") {
	   		document.getElementById(subSection).className = "subLeftNavSelected1";
		}
		else {
			document.getElementById(subSection).className = "subLeftNavSelected";
		}
	} 
	if (subSubSection != "") {
	   document.getElementById(subSubSection).className = "subsubLeftNavSelected";
	}
}

function changeLayerposition() {
	if (mainSection == "home") {
		document.getElementById('aboutlayer1').style.top = "239px";
		document.getElementById('productslayer').style.top = "266px";
		document.getElementById('manufacturinglayer').style.top = "293px";
		document.getElementById('medialayer1').style.top = "347px";
		document.getElementById('recruitlayer1').style.top = "401px";
	} else if (mainSection == "about") {
		document.getElementById('productslayer').style.top = "323px";
		document.getElementById('manufacturinglayer').style.top = "350px";
		document.getElementById('medialayer1').style.top = "405px";
		document.getElementById('recruitlayer1').style.top = "459px";
	} else if (mainSection == "products") {
		document.getElementById('manufacturinglayer').style.top = "229px";
		document.getElementById('medialayer1').style.top = "284px";
		document.getElementById('recruitlayer1').style.top = "338px";
	} else if (mainSection == "manufacturing") {
		document.getElementById('medialayer1').style.top = "373px";
		document.getElementById('recruitlayer1').style.top = "425px";
	} else if (mainSection == "media") {
		document.getElementById('recruitlayer1').style.top = "319px";
	} else if (mainSection == "recruitment") {
		document.getElementById('recruitlayer1').style.top = "337px";
	}
}

function changeLayerpositionBig5() {
	if (mainSection == "home") {
		document.getElementById('aboutlayer1').style.top = "239px";
		document.getElementById('productslayer').style.top = "266px";
		document.getElementById('manufacturinglayer').style.top = "293px";
		document.getElementById('medialayer1').style.top = "347px";
		document.getElementById('recruitlayer1').style.top = "401px";
	} else if (mainSection == "about") {
		document.getElementById('productslayer').style.top = "312px";
		document.getElementById('manufacturinglayer').style.top = "337px";
		document.getElementById('medialayer1').style.top = "393px";
		document.getElementById('recruitlayer1').style.top = "459px";
	} else if (mainSection == "products") {
		document.getElementById('manufacturinglayer').style.top = "229px";
		document.getElementById('medialayer1').style.top = "284px";
		document.getElementById('recruitlayer1').style.top = "338px";
	} else if (mainSection == "manufacturing") {
		document.getElementById('medialayer1').style.top = "373px";
		document.getElementById('recruitlayer1').style.top = "425px";
	} else if (mainSection == "media") {
		document.getElementById('recruitlayer1').style.top = "319px";
	} else if (mainSection == "recruitment") {
		document.getElementById('recruitlayer1').style.top = "337px";
	}
}

function printFriendly() 
{
	var curLoc = parent.location.href;
	if (curLoc.indexOf("gate/gb/") != -1) 
    {
		var winLink = window.location.href;
		var url = "ht" + "tp://www.karrie.com.hk/big5/print/printVersion2.php?file=" + winLink;
		window.open(url, 'printing', 'width=620,height=515,left=50,top=50,scrollbars=yes, menubar=yes');
    }
	
	else
	{
		var winLink = window.location.href;
		var url = "../print/printVersion.php?file=" + winLink;
		window.open(url, 'printing', 'width=620,height=515,left=50,top=50,scrollbars=yes, menubar=yes');
	}
}

//-->
