function mem_logout(msg){
	var msg;
	alert(msg);
	location.href="member_logout.php";
}

function mem_edit(){
	location.href="profile.php";
}

function mem_history(){
	location.href="member.php?history=yes";
}

function fun_details(id) {
		var wd;
		var parm = "width=600 height=600 resizable=no scrollbars=yes,toolbar=no,location=no,menubar=yes";
		wd = window.open('number_details.php?id='+id,'NewWin',parm);
		wd.focus();
}

function fun_order(id,amount) {
		window.location.href='enquiry.php?id='+id+'&amount='+amount+'&action=1';
}

function cart_list(){
	location.href="shopping_cart.php";
}

function CheckCn(str){
  var value = escape(str);
  var is_kana = true;
  for(i=0;i<value.length;i++){
    var ch=value.charAt(i);
    if(ch=='%'){
      if( value.charAt(i+1)=='u' ){
        is_kana = false ;
        if(value.charAt(i+2)=='F' && value.charAt(i+3)=='F'){
          var cd = parseInt(value.charAt(i+4).toString()+value.charAt(i+5).toString(),16);
          if( 0x61 <= cd && cd <= 0x9F )
            is_kana = true ;

        }
        i+=5;
        if( is_kana )
          continue;
      }else
		i+=2;
    }
  }
  return is_kana;
}

function strLength(str){
  var value = escape(str);
  var len=0;
  for(i=0;i<value.length;i++){
    var ch=value.charAt(i);
    if(ch=='%'){
      if( value.charAt(i+1)=='u' ){
        var is_kana = false ;
        if(value.charAt(i+2)=='F' && value.charAt(i+3)=='F'){
          var cd = parseInt(value.charAt(i+4).toString()+value.charAt(i+5).toString(),16);
          if( 0x61 <= cd && cd <= 0x9F )
            is_kana = true ;
        }
        i+=5;
        len++;
        if( is_kana )
          continue;
      }else
        i+=2;
    }
    len++;
  }
  return len;
}

function CheckTextLen(theObject, en_len, cn_len){
	var theValue = theObject.value;

	if (CheckCn(theValue))
	{
		if(strLength(theValue) > en_len){
			alert('The max length of english is '+en_len+' characters!');
			theObject.focus();
			return false;
		}else{
			return true;
		}

	}else{
		if(strLength(theValue) > cn_len){
			alert('The max length of chinese is '+cn_len+' characters!');
			theObject.focus();
			return false;
		}else{
			return true;
		}	
	}


}

function display(myimage) {
 html = "<HTML><HEAD><TITLE>Photo</TITLE><script type='text/javascript' src='javascript/noclick.js'></script>" +
  "</HEAD><BODY LEFTMARGIN=20 " +
  "MARGINWIDTH=0 TOPMARGIN=20 MARGINHEIGHT=0><CENTER>" +
  "<IMG SRC='" + myimage + "' BORDER=0 NAME=image " +
  "onload='window.resizeTo(document.image.width+20,document.image.height+110)'></CENTER>" +
  "</BODY></HTML>";
 popup=window.open
   ('','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1');
 popup.document.open();
 popup.document.write(html);
 popup.document.focus();
 popup.document.close()
 };

 function display_color(myimage, myname) {
 html = "<HTML><HEAD><TITLE>Photo</TITLE><script type='text/javascript' src='javascript/noclick.js'></script>" +
  "</HEAD><BODY LEFTMARGIN=20 " +
  "MARGINWIDTH=0 TOPMARGIN=20 MARGINHEIGHT=0>" +
  "<b>Product Name : " + myname + "</b>" +
  "<CENTER><IMG SRC='" + myimage + "' BORDER=0 NAME=image " +
  "onload='window.resizeTo(document.image.width+20,document.image.height+110)'></CENTER>" +
  "</BODY></HTML>";
 popup=window.open
   ('','image','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=1');
 popup.document.open();
 popup.document.write(html);
 popup.document.focus();
 popup.document.close()
 };