<!--

	var section = "";
	var subsection = "";

	function gocountry(cname)
	{
    	document.location = "/country/" + cname + ".htm";
	}

	function ReturnNetscape() 
	{
		return (navigator.appName == "Netscape");
	}

	function ReturnVersion() {
		var appVer = navigator.appVersion;
		var myPos = appVer.indexOf("AOL ");
		if (myPos != -1) {
			return parseInt(appVer.substring(myPos + 4, appVer.length - 1));
		} 
		else {
		    myPos = appVer.indexOf("MSIE ");
		    if (myPos != -1) {
				return parseInt(appVer.substring(myPos + 5, appVer.length - 1));
		    } 
			else {
				return parseInt(appVer);
			}
		}
	}

	function browserheight() {
		var browserheight = 0;
		if (ReturnNetscape() && (ReturnVersion() >= 4)) {
			browserheight = window.innerHeight-145;
		} else {
			browserheight = document.body.offsetHeight-148;
		}
		return browserheight;
	}
    



// topmenu starts

	function show(v,count)
	{	
		notshow(v,count)
		document.getElementById(v).style.display = 'inline';
	}
	function notshow(v,count)
	{
		var v = v.substring(0,v.length-1)
		for(i =0;i<count;i++)
		{
			if(document.getElementById(v+i))
			{
				document.getElementById(v+i).style.display = 'none';
			}
		}
	}

// topmenu ends




// rollovers starts

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_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_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];}
}


// rollovers-end






function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}







    function acrobat(url)
    {
        acrobat = window.open('http://www.adobe.com/products/acrobat/readstep2.html',"acrobat","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=750,height=550");
    }

    
	
	
	
    function directo(obj)
    {
        i = obj.selectedIndex;
        if (obj.options[i].value!="#")
        {
    	    document.location=obj.options[i].value;
        }
    }
	
	function gourlparent(name)
	{
		window.opener.location = name;
	}

	function openterms()
	{
		window.open("/terms.htm", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=630,height=530")
	}






//Validating the Date Selected
function CheckDate(SelYear,MonIndex,SelDay){
	if(parseInt(MonIndex)==4 || parseInt(MonIndex)==6 || parseInt(MonIndex)==9 || parseInt(MonIndex)==11)
	{
		if(parseInt(SelDay)==31)
		{
			return false;
		}
	}
	if(parseInt(MonIndex)==2)	//For Feb.
	{
		if((parseInt(SelYear) % 4)!=0)
		{
			if(parseInt(SelDay)>28)
			{
				return false;
			}
		}
		else if((parseInt(SelYear) % 400)==0)
		{
			if(parseInt(SelDay)>29)
			{
				return false;
			}
		}
		else if((parseInt(SelYear) % 100)==0)
		{
			if(parseInt(SelDay)>28)
			{
				return false;
			}
		}
		else
		{
			if(parseInt(SelDay)>29)
			{
				return false;
			}
		}
	}
	return true;
}


function isNumberInt(inputString) {
  return (!isNaN(parseInt(inputString))) ? true : false;
}

function isNumberFloat(inputString) {
  return (!isNaN(parseFloat(inputString))) ? true : false;
}


function validEmail(email) {
	if (email.length < 5)
		return false;
	x1 = email.indexOf("@");
	x2 = email.indexOf(".",x1+2);
	x3 = email.indexOf(" ");
	if ((x1 < 1 ) || (x2 < 1) || (x2 == email.length-1) || (x3 >= 0)){
		return false;
	}
	return true;
}


function getUrlEN(){
	var strPathName = new String(self.document.location.href)
	if (strPathName.search("global/b5/") > 0) {
		return strPathName.replace(/global\/b5\//g, "global/en/");
	} else {
		return strPathName.replace(/global\/gb\//g, "global/en/");
	}
	return strPathName;
}
function getUrlB5(){
	var strPathName = new String(self.document.location.href)
	if (strPathName.search("global/en/") > 0) {
		return strPathName.replace(/global\/en\//g, "global/b5/");
	} else {
		return strPathName.replace(/global\/gb\//g, "global/b5/");
	}
	return strPathName;
}
function getUrlGB(){
	var strPathName = new String(self.document.location.href)
	if (strPathName.search("global/en/") > 0) {
		return strPathName.replace(/global\/en\//g, "global/gb/");
	} else {
		return strPathName.replace(/global\/b5\//g, "global/gb/");
	}
	return strPathName;
}
function Set_Cookie( name, value, expires, path, domain, secure ) 
{
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );

  /*
  if the expires variable is set, make the correct 
  expires time, the current script below will set 
  it for x number of days, to make it for hours, 
  delete * 24, for minutes, delete * 60 * 24
  */
  if ( expires )
  {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}
function Get_Cookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
  {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
    return unescape( document.cookie.substring( len, end ) );
}
//
// TEAencrypt: Use Corrected Block TEA to encrypt plaintext using password
//             (note plaintext & password must be strings not string objects)
//
// Return encrypted text as string
//
function TEAencrypt(plaintext, password)
{
    if (plaintext.length == 0) return('');  // nothing to encrypt
    // 'escape' plaintext so chars outside ISO-8859-1 work in single-byte packing, but  
    // keep spaces as spaces (not '%20') so encrypted text doesn't grow too long, and 
    // convert result to longs
    var v = strToLongs(escape(plaintext).replace(/%20/g,' '));
    if (v.length == 1) v[1] = 0;  // algorithm doesn't work for n<2 so fudge by adding nulls
    var k = strToLongs(password.slice(0,16));  // simply convert first 16 chars of password as key
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = 0;

    while (q-- > 0) {  // 6 + 52/n operations gives between 6 & 32 mixes on each word
        sum += delta;
        e = sum>>>2 & 3;
        for (var p = 0; p < n-1; p++) {
            y = v[p+1];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z)
            z = v[p] += mx;
        }
        y = v[0];
        mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z)
        z = v[n-1] += mx;
    }
    // note use of >>> in place of >> due to lack of 'unsigned' type in JavaScript 

    return escCtrlCh(longsToStr(v));
}

//
// TEAdecrypt: Use Corrected Block TEA to decrypt ciphertext using password
//
function TEAdecrypt(ciphertext, password)
{
    if (ciphertext.length == 0) return('');
    var v = strToLongs(unescCtrlCh(ciphertext));
    var k = strToLongs(password.slice(0,16)); 
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = q*delta;

    while (sum != 0) {
        e = sum>>>2 & 3;
        for (var p = n-1; p > 0; p--) {
            z = v[p-1];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z)
            y = v[p] -= mx;
        }
        z = v[n-1];
        mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z)
        y = v[0] -= mx;
        sum -= delta;
    }

    var plaintext = longsToStr(v);
    // strip trailing null chars resulting from filling 4-char blocks:
    if (plaintext.search(/\0/) != -1) plaintext = plaintext.slice(0, plaintext.search(/\0/));

    return unescape(plaintext);
}


// supporting functions

function strToLongs(s) {  // convert string to array of longs, each containing 4 chars
    // note chars must be within ISO-8859-1 (with Unicode code-point < 256) to fit 4/long
    var l = new Array(Math.ceil(s.length/4))
    for (var i=0; i<l.length; i++) {
        // note little-endian encoding - endianness is irrelevant as long as 
        // it is the same in longsToStr() 
        l[i] = s.charCodeAt(i*4) + (s.charCodeAt(i*4+1)<<8) + 
               (s.charCodeAt(i*4+2)<<16) + (s.charCodeAt(i*4+3)<<24);
    }
    return l;  // note running off the end of the string generates nulls since 
}              // bitwise operators treat NaN as 0

function longsToStr(l) {  // convert array of longs back to string
    var a = new Array(l.length);
    for (var i=0; i<l.length; i++) {
        a[i] = String.fromCharCode(l[i] & 0xFF, l[i]>>>8 & 0xFF, 
                                   l[i]>>>16 & 0xFF, l[i]>>>24 & 0xFF);
    }
    return a.join('');  // use Array.join() rather than repeated string appends for efficiency
}

function escCtrlCh(str) {  // escape control chars which might cause problems with encrypted texts
    return str.replace(/[\0\n\v\f\r\xa0!]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
}

function unescCtrlCh(str) {  // unescape potentially problematic nulls and control characters
    return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}

var datestr= 'sresiw';
function initForm(form) {
    var strtmp = '';
    for(i=0;i<=3;i++)
    {
      if (form.elements[i].name != 'password'){
        strtmp = Get_Cookie(form.elements[i].name);
        if(strtmp=="" || strtmp == null){
          form.chkRememberPassword.checked = false;
        }else{
          form.chkRememberPassword.checked = true;
          form.elements[i].value = TEAdecrypt(strtmp, datestr);
        }
      }
    }
}

function submitLogin(form){
var count=0;
var msg="";

    for(i=0;i<=3;i++)
    {
        if(form.elements[i].value=="")
        {
        count=1;
        msg=msg+"\n"+form.elements[i].name;
        }else{
        	if (form.chkRememberPassword.checked == true) {
			if (form.elements[i].name != 'password'){
        			Set_Cookie(form.elements[i].name, TEAencrypt(form.elements[i].value, datestr), 365, "/");
			}else{
	        		Set_Cookie(form.elements[i].name, "", 365, "/");
			}
		}else{
        		Set_Cookie(form.elements[i].name, "", 365, "/");
		}
        }
        if((i>2) && (count==0))
        {
			    form.submit();
        }
    }
    for(i=0;i<=3;i++)
    {
        if(form.elements[i].value=="")
        {
	msg = msg.replace(/service-type/,"產品");
	msg = msg.replace(/group-id/,"組別名稱");
	msg = msg.replace(/user-name/,"用戶名稱");
	msg = msg.replace(/password/,"密碼");
        alert("請填寫以下資料\n "+msg);
        form.elements[i].focus();
        return(false);
        }

    }


}
	
function initDemoForm(form) {
    var strtmp = '';
    for(i=0;i<=3;i++)
    {
      strtmp = Get_Cookie(form.elements[i].name);
      if(strtmp=="" || strtmp == null){
        form.chkRememberPassword.checked = false;
      }else{
    form.chkRememberPassword.checked = true;
    form.elements[i].value = TEAdecrypt(strtmp, datestr);
      }
    }
}

function submitDemoLogin(form){
var count=0;
var msg="";

    for(i=0;i<=3;i++)
    {
        if(form.elements[i].value=="")
        {
        count=1;
        msg=msg+"\n"+form.elements[i].name;
        }else{
        	if (form.chkRememberPassword.checked == true) {
        		Set_Cookie(form.elements[i].name, TEAencrypt(form.elements[i].value, datestr), 365, "/");
					}else{
        		Set_Cookie(form.elements[i].name, "", 365, "/");
					}
        }
        if((i>2) && (count==0))
        {
			    form.submit();
        }
    }
    for(i=0;i<=3;i++)
    {
        if(form.elements[i].value=="")
        {
	//msg = msg.replace(/service-type/,"產品");
	//msg = msg.replace(/group-id/,"組別名稱");
	//msg = msg.replace(/user-name/,"用戶名稱");
	//msg = msg.replace(/password/,"密碼");
        alert("請填寫以下資料\n "+msg);
        form.elements[i].focus();
        return(false);
        }

    }


}
