function isblank(s)
{
	for(var i = 0; i < s.length; i++) {
		var c = s.charAt(i);
		if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
	}
	return true;
}

function CheckEmail(strEmail) {
	var i;
	var getChar;


	if ((Left(strEmail, 1) == "@") || (Right(strEmail, 1) == "@") )
		return false;
	

		getChar = 0;
	for (i = 0 ; i < strEmail.length ; i++ ) {
		if (strEmail.charAt(i)=='@'){
			getChar++;
		}
	}	    

	if ( getChar != 1 )
		return false;

	var email1;
	var email2;
	var temail;
	
	temail = strEmail.split('@')
	email1 = temail[0].replace(/\s/g, "");
	email2 = temail[1].replace(/\s/g, "");	
	
	var cemail;
	cemail = strEmail;
	cemail = cemail.replace(/\@/g, "");	
	cemail = cemail.replace(/\./g, "");	
	
	if (cemail.length == 0)
		return false;
	
	var allow;
	allow = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_-";
	for(i = 0 ; i < cemail.length; i++ )
		if (allow.indexOf(cemail.charAt(i)) < 0 )
			return false;

	if (Left(email1, 1) == '.')
		return false;

	
	if (Left(email2, 1) == '.' || Right(email2, 1) == '.' || email2.replace(/\./g, "").length == email2.length)
		return false;

	if (email2.indexOf("..") >= 0 )
		return false;

	if (Left(email2, 1) == '-' || Right(email2, 1) == '-')
		return false;

	if (Left(email2, 1) == '_' || Right(email2, 1) == '_')
		return false;
	
	return true;
}	

function Left( sourceStr, charIdx ) {
	if((sourceStr==null) || (sourceStr=="")) return "";
	return sourceStr.substring(0, charIdx);
}

function Right( sourceStr, charIdx ) {	
	if((sourceStr==null) || (sourceStr=="")) return "";
	return sourceStr.substring(sourceStr.length-charIdx, sourceStr.length);
}


// Check Login
function check_login(e)
{
	var msg;
	var textun="";
	var textpw="";
	var fg=1;

	if ((e.username.value == null) || (e.username.value == "") || isblank(e.username.value)) { textun = "E-mail Address is Required.\n"; fg=0;}
	
	if (fg) { 
	  if(e.username.value!='admin')
	 {
		if (!CheckEmail(e.username.value)) { textun = "An Error occurred. Please enter a correct email address. \n";} 
	 }
	}
	
	
	if ((e.password.value == null) || (e.password.value == "") || isblank(e.password.value)) { textpw = "Password is Required.\n"; }
		
	if (e.username.style) e.username.style.backgroundColor = textun != "" ? '#FFCC66':'#FFFFFF';
	if (e.password.style) e.password.style.backgroundColor = textpw != "" ? '#FFCC66':'#FFFFFF';
	
	if (textun == "" && textpw == "") { e.submit(); return true; }
	else { msg = textun+textpw;	} 
	
	alert(msg);
	return false;
}

// Review Submit
function check_review(e)
{
	var msg;
	var textcm="";

	if ((e.comment.value == null) || (e.comment.value == "") || isblank(e.comment.value)) { textcm = "Comment is Required.\n"; }	
		
	if (e.comment.style) e.comment.style.backgroundColor = textcm != "" ? '#FFCC66':'#FFFFFF';
	
	if (textcm == "") { e.submit(); return true; }
	else { msg = textcm;	} 
	
	alert(msg);
	return false;
}


// Check Register
function check_info(e)
{
	var msg;
	var textAll = "Please check your Personal Information.";
	var textfn="";
	var textln="";
	var textdb="";
	var textem="";
	var textad="";
	var textct="";
	var textsp="";
	var textcy="";
	var textzp="";
	var texttn="";
	var textpw="";
	var texton="";
	var fg=1;
	var vg=1;

	if ((e.customers_firstname.value == null) || (e.customers_firstname.value == "") || isblank(e.customers_firstname.value)) { textfn = "First Name is Required.\n";}	
	if ((e.customers_lastname.value == null) || (e.customers_lastname.value == "") || isblank(e.customers_lastname.value)) { textln = "Last Name is Required.\n";}
	//if ((e.customers_dob.value == null) || (e.customers_dob.value == "") || isblank(e.customers_dob.value)) {	textdb = "Date of Birth is Required.\n";}
	if ((e.customers_email.value == null) || (e.customers_email.value == "") || isblank(e.customers_email.value)) { textem = "E-mail Address is Required.\n"; fg=0;}
	if (fg) {
		 if (!CheckEmail(e.customers_email.value)) { textem = "An Error occurred. Please enter a correct email address. \n";} 
		}
	if ((e.street_address.value == null) || (e.street_address.value == "") || isblank(e.street_address.value)) {textad = "Address is Required.\n";}
    //if ((e.entry_zip.value == null) || (e.entry_zip.value == "") || isblank(e.entry_zip.value)) { textzp = "Zip or Post Code is Required.\n"; }
	if ((e.entry_city.value == null) || (e.entry_city.value == "") || isblank(e.entry_city.value)) { textct = "City is Required.\n";}
	if(document.getElementById('input_select').value == 'input')
	{
		if ((e.entry_state_input.value == "") || isblank(e.entry_state_input.value)) { textsp = "State or Province is Required.\n";}
	}
	else
	{
		if ((e.entry_state.value == 'Choose One') || (e.entry_state.value == "") || isblank(e.entry_state.value)) { textsp = "State or Province is Required.\n";}
	}
	//if (e.entry_country.value == 'Choose One') { textcy = "Country is Required.\n";}
	if ((e.customers_telephone.value == null) || (e.customers_telephone.value == "") || isblank(e.customers_telephone.value)) { texttn = "Telephone Number is Required.\n";}
	if ((e.password.value == null) || (e.password.value == "") || isblank(e.password.value)) { textpw = "Password is Required.\n"; vg=0;}
	if (vg) {
	 if (e.password.value != e.confirmation.value) { textpw = "Passowrd does not match.\n"; }
	}

	if ((e.organizationname.value == null) || (e.organizationname.value == "") || isblank(e.organizationname.value)) { texton = "Organization Name is Required.\n";}	
	
	if (e.organizationname.style) e.organizationname.style.backgroundColor = texton != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_firstname.style) e.customers_firstname.style.backgroundColor = textfn != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_lastname.style) e.customers_lastname.style.backgroundColor = textln != "" ? '#FFCC66':'#FFFFFF';
	//if (e.customers_dob.style) e.customers_dob.style.backgroundColor = textdb != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_email.style) e.customers_email.style.backgroundColor = textem != "" ? '#FFCC66':'#FFFFFF';
	if (e.street_address.style) e.street_address.style.backgroundColor = textad != "" ? '#FFCC66':'#FFFFFF';
	//if (e.entry_zip.style) e.entry_zip.style.backgroundColor = textzp != "" ? '#FFCC66':'#FFFFFF'; 
	if (e.entry_city.style) e.entry_city.style.backgroundColor = textct != "" ? '#FFCC66':'#FFFFFF';
	if (e.entry_state.style) e.entry_state.style.backgroundColor = textsp != "" ? '#FFCC66':'#FFFFFF';
	if (e.entry_state_input.style) e.entry_state_input.style.backgroundColor = textsp != "" ? '#FFCC66':'#FFFFFF';
	//if (e.entry_country.style) e.entry_country.style.backgroundColor = textcy != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_telephone.style) e.customers_telephone.style.backgroundColor = texttn != "" ? '#FFCC66':'#FFFFFF';
	if (e.password.style) e.password.style.backgroundColor = textpw != "" ? '#FFCC66':'#FFFFFF';
	if (e.confirmation.style) e.confirmation.style.backgroundColor = textpw != "" ? '#FFCC66':'#FFFFFF';
	
	if ((textfn == "") && (textln == "") && (textdb == "") && (textem == "") && (textad == "") && (textzp == "") && (textct == "") && (textsp == "")  && (textcy == "")  && (texttn == "")  && (textpw == "")&& (texton == "")) 
		{ 
			registerCheckEmail();
			//e.submit();
			return true;
		}
	
	if (textfn && textln && textdb && textem && textad && textzp && textct && textsp && textcy && texttn && textpw&& texton) {
		msg = textAll;
	} else {
		msg = textfn + textln + textdb + textem + textad + textzp + textct  + textsp + textcy + texttn + textpw + texton;
	}		
	alert(msg);
	return false;
}

// Check update
function check_updateinfo(e)
{
	var msg;
	var textAll = "Please check your Personal Information.";
	var textfn="";
	var textln="";
	var textdb="";
	var textem="";
	var textad="";
	var textct="";
	var textsp="";
	var textcy="";
	var textzp="";
	var texttn="";
	var textpw="";
	var texton="";
	var fg=1;
	var vg=1;

	if ((e.customers_firstname.value == null) || (e.customers_firstname.value == "") || isblank(e.customers_firstname.value)) { textfn = "First Name is Required.\n";}	
	if ((e.customers_lastname.value == null) || (e.customers_lastname.value == "") || isblank(e.customers_lastname.value)) { textln = "Last Name is Required.\n";}
	if ((e.street_address.value == null) || (e.street_address.value == "") || isblank(e.street_address.value)) {textad = "Address is Required.\n";}
	if ((e.entry_city.value == null) || (e.entry_city.value == "") || isblank(e.entry_city.value)) { textct = "City is Required.\n";}
	if(document.getElementById('input_select').value == 'input')
	{
		if ((e.entry_state_input.value == "") || isblank(e.entry_state_input.value)) { textsp = "State or Province is Required.\n";}
	}
	else
	{
		if ((e.entry_state.value == 'Choose One') || (e.entry_state.value == "") || isblank(e.entry_state.value)) { textsp = "State or Province is Required.\n";}
	}
	//if (e.entry_country.value == 'Choose One') { textcy = "Country is Required.\n";}
	if ((e.customers_telephone.value == null) || (e.customers_telephone.value == "") || isblank(e.customers_telephone.value)) { texttn = "Telephone Number is Required.\n";}
	if ((e.organizationname.value == null) || (e.organizationname.value == "") || isblank(e.organizationname.value)) { texton = "Organization Name is Required.\n";}
	
	if (e.organizationname.style) e.organizationname.style.backgroundColor = texton != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_firstname.style) e.customers_firstname.style.backgroundColor = textfn != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_lastname.style) e.customers_lastname.style.backgroundColor = textln != "" ? '#FFCC66':'#FFFFFF';
	if (e.street_address.style) e.street_address.style.backgroundColor = textad != "" ? '#FFCC66':'#FFFFFF';
	if (e.entry_city.style) e.entry_city.style.backgroundColor = textct != "" ? '#FFCC66':'#FFFFFF';
	if (e.entry_state.style) e.entry_state.style.backgroundColor = textsp != "" ? '#FFCC66':'#FFFFFF';
	if (e.entry_state_input.style) e.entry_state_input.style.backgroundColor = textsp != "" ? '#FFCC66':'#FFFFFF';
	//if (e.entry_country.style) e.entry_country.style.backgroundColor = textcy != "" ? '#FFCC66':'#FFFFFF';
	if (e.customers_telephone.style) e.customers_telephone.style.backgroundColor = texttn != "" ? '#FFCC66':'#FFFFFF';
	
	if ((textfn == "") && (textln == "") && (textdb == "") && (textem == "") && (textad == "") && (textzp == "") && (textct == "") && (textsp == "")  && (textcy == "")  && (texttn == "")  && (textpw == "")&& (texton == "")) 
		{ 
			e.submit();
			return true;
		}
	
	if (textfn && textln && textdb && textem && textad && textzp && textct && textsp && textcy && texttn && textpw&& texton) {
		msg = textAll;
	} else {
		msg = textfn + textln + textdb + textem + textad + textzp + textct  + textsp + textcy + texttn + textpw + texton;
	}		
	alert(msg);
	return false;
}


function check_pwd(e)
{
	var msg;
	var textAll = "Please check your submit form.";
	var textop="";
	var textnp="";
	var fg=1;
	
	//alert(publicJs.calcMD5(e.o_pass.value,32));
   if ((e.o_pass.value == null) || (e.o_pass.value == "") || isblank(e.o_pass.value)) { textop = "Current Password is Required.\n"; fg=0;}
   if (fg) { if (publicJs.calcMD5(e.o_pass.value,32) != e.mdpass.value) { textop = "Current Password is Wrong.\n";} }
   if ((e.n_pass.value == null) || (e.n_pass.value == "") || isblank(e.n_pass.value)) { textnp = "New Password is Required.\n"; }
   
   if (e.n_pass.value != e.c_pass.value) { textnp = "New Passowrd does not match.\n"; }
  
	if (e.o_pass.style) e.o_pass.style.backgroundColor = textop != "" ? '#FFCC66':'#FFFFFF';
	if (e.n_pass.style) e.n_pass.style.backgroundColor = textnp != "" ? '#FFCC66':'#FFFFFF';
	if (e.c_pass.style) e.c_pass.style.backgroundColor = textnp != "" ? '#FFCC66':'#FFFFFF';
		
	if ((textop == "") && (textnp == "")) {
		e.submit(); 
	return false;
	}
	
	if (textop && textnp) {
		msg = textAll;
	} else {
		msg = textop + textnp;
	}		
	
	alert(msg);
	return false;
}

function check_email(e)
{
	var msg;
	var textem="";
	var fg=1;

	if ((e.email.value == null) || (e.email.value == "") || isblank(e.email.value)) { textem = "E-mail Address is Required.\n"; fg=0;}
	
	if (fg) { 
	  if (!CheckEmail(e.email.value)) { textem = "An Error occurred. Please enter a correct email address. \n";} 	
	}
		
	if (e.email.style) e.email.style.backgroundColor = textem != "" ? '#FFCC66':'#FFFFFF';
	
	if (textem == "") 
	{ 
		forgotPwCheckEmail();
		//e.submit(); 
		return true;
	}
	else { msg = textem;	} 
	
	alert(msg);
	return false;
}


function check_type(e){
var txt="Date of Birth";
  if (!checkStr(e.value)) {
    e.style.backgroundColor = '#FFCC66';
	e.focus(); 
	e.select(); 
    txt = txt+" that you input is error!";
	alert(txt);
	return false;
  }
  e.style.backgroundColor = '#FFFFFF';
  return true;
}

function checkStr(str)
{
    for( var i=0; i < str.length; i++) {
        var ch = str.substring( i, i+1 );
        if( (ch < "0" || ch > "9") && ch != "-") 
            return false;              
    }    
    return true;
}

function check_num(e){
var txt="Quantity ";
  if (!checkData(e.value)) {
    e.style.backgroundColor = '#FFCC66';
	e.focus(); 
	e.select(); 
    txt = txt+" should be number!";
	alert(txt);
	return false;
  }
  e.style.backgroundColor = '#FFFFFF';
  return true;
}

function checkData(str)
{
    for( var i=0; i < str.length; i++) {
        var ch = str.substring( i, i+1 );
        if(ch < "0" || ch > "9") 
            return false;              
    }    
    return true;
}

function check_card(e){
var txt="Card Number";
  if (!checkCard(e.value)) {
    e.style.backgroundColor = '#FFCC66';
	e.focus(); 
    txt = txt+" has illegal character!";
	alert(txt);
	return false;
  }
  e.style.backgroundColor = '#FFFFFF';
  return true;
}

function checkCard(str)
{
    for( var i=0; i < str.length; i++) {
        var ch = str.substring( i, i+1 );
        if( (ch < "0" || ch > "9") && ch != " ") 
            return false;              
    }    
    return true;
}



	function showOrganizationResponse(originalRequest)
    {	
		if(originalRequest.responseText==1)
		{	
			document.register.submit();
			return false;
		}
		else
		{
			alert(originalRequest.responseText);
			return true;
		}
    }
	

	function registerCheckOrganization()
    {	
		var url = './register.php';
		//alert($('organizationname').value);
		var organizationname = $('organizationname').value;
		//alert(organizationname);
		var pars ="act=CheckOrganization&"+"organizationname="+organizationname;
		new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showOrganizationResponse});
    }


	function showResponse(originalRequest)
    {	
		if(originalRequest.responseText!='ok')
		{	
			alert(originalRequest.responseText);
			return false;
		}
		else
		{
			//document.register.submit();
			registerCheckOrganization();
			return true;
		}
    }
	

	function registerCheckEmail()
    {	
		var url = './register.php';
		var email = $('customers_email').value;
		var pars ="act=CheckEmail&"+"email="+email;
		new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: showResponse});
    }

	function forgotPwCheckEmail()
    {	
		var url = './register.php';
		var email = $('email').value;
		var pars ="act=CheckEmail&"+"email="+email;
		new Ajax.Request(url,{method: 'post', parameters: pars, onComplete: forgotPwResponse});
    }


	function forgotPwResponse(originalRequest)
    {	
		if(originalRequest.responseText=='ok')
		{	
			alert("An error occurred. Sorry, E-mail is not exist.");
			return false;
		}
		else
		{
			document.forgorPw.submit();
			return true;
		}
    }



function clear_value(s)
{	
	s.value = '';
}


function change_country(s)
{
	if(s.value != 'United States')
	{
		document.getElementById('entry_state').style.display = "none";
		document.getElementById('entry_state_input').style.display = "";
		document.getElementById('input_select').value = "input";
	}
	else
	{
		document.getElementById('entry_state').style.display = "";
		document.getElementById('entry_state_input').style.display = "none";
		document.getElementById('input_select').value = "select";
	}
}



var publicJs=
{	
	/*
*****************************************************************************
* md5.js
*
* A JavaScript implementation of the RSA Data Security, Inc. MD5
* Message-Digest Algorithm.
*
* Copyright (C) Paul Johnston 1999. Distributed under the LGPL.
*****************************************************************************/
	sAscii : " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"+ "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",

	/* convert integer to hex string */
	sHex : "0123456789abcdef",
	hex:function (i)
	{
	  h = "";
	  for(j = 0; j <= 3; j++)
	  {
		h += this.sHex.charAt((i >> (j * 8 + 4)) & 0x0F) +
			 this.sHex.charAt((i >> (j * 8)) & 0x0F);
	  }
	  return h;
	},

/* add, handling overflows correctly */
	add:function (x, y)
	{
	  return ((x&0x7FFFFFFF) + (y&0x7FFFFFFF)) ^ (x&0x80000000) ^ (y&0x80000000);
	},

	/* MD5 rounds functions */
	R1:function (A, B, C, D, X, S, T)
	{
	  q = this.add(this.add(A, (B & C) | (~B & D)), this.add(X, T));
	  return this.add((q << S) | ((q >> (32 - S)) & (Math.pow(2, S) - 1)), B);
	},

	R2:function (A, B, C, D, X, S, T)
	{
	  q = this.add(this.add(A, (B & D) | (C & ~D)), this.add(X, T));
	  return this.add((q << S) | ((q >> (32 - S)) & (Math.pow(2, S) - 1)), B);
	},

	R3:function (A, B, C, D, X, S, T)
	{
	  q = this.add(this.add(A, B ^ C ^ D), this.add(X, T));
	  return this.add((q << S) | ((q >> (32 - S)) & (Math.pow(2, S) - 1)), B);
	},

	R4:function (A, B, C, D, X, S, T)
	{
	  q = this.add(this.add(A, C ^ (B | ~D)), this.add(X, T));
	  return this.add((q << S) | ((q >> (32 - S)) & (Math.pow(2, S) - 1)), B);
	},

	/* main entry point */
	calcMD5:function (sInp,Type) {

	  /* Calculate length in machine words, including padding */
	  wLen = (((sInp.length + 8) >> 6) + 1) << 4;
	  var X = new Array(wLen);

	  /* Convert string to array of words */
	  j = 4;
	  for (i = 0; (i * 4) < sInp.length; i++)
	  {
		X[i] = 0;
		for (j = 0; (j < 4) && ((j + i * 4) < sInp.length); j++)
		{
		  X[i] += (this.sAscii.indexOf(sInp.charAt((i * 4) + j)) + 32) << (j * 8);
		}
	  }

	  /* Append padding bits and length */
	  if (j == 4)
	  {
		X[i++] = 0x80;
	  }
	  else
	  {
		X[i - 1] += 0x80 << (j * 8);
	  }
	  for(; i < wLen; i++) { X[i] = 0; }
	  X[wLen - 2] = sInp.length * 8;

	  /* hard-coded initial values */
	  a = 0x67452301;
	  b = 0xefcdab89;
	  c = 0x98badcfe;
	  d = 0x10325476;

	  /* Process each 16-word block in turn */
	  for (i = 0; i < wLen; i += 16) {
		aO = a;
		bO = b;
		cO = c;
		dO = d;

		a = this.R1(a, b, c, d, X[i+ 0], 7 , 0xd76aa478);
		d = this.R1(d, a, b, c, X[i+ 1], 12, 0xe8c7b756);
		c = this.R1(c, d, a, b, X[i+ 2], 17, 0x242070db);
		b = this.R1(b, c, d, a, X[i+ 3], 22, 0xc1bdceee);
		a = this.R1(a, b, c, d, X[i+ 4], 7 , 0xf57c0faf);
		d = this.R1(d, a, b, c, X[i+ 5], 12, 0x4787c62a);
		c = this.R1(c, d, a, b, X[i+ 6], 17, 0xa8304613);
		b = this.R1(b, c, d, a, X[i+ 7], 22, 0xfd469501);
		a = this.R1(a, b, c, d, X[i+ 8], 7 , 0x698098d8);
		d = this.R1(d, a, b, c, X[i+ 9], 12, 0x8b44f7af);
		c = this.R1(c, d, a, b, X[i+10], 17, 0xffff5bb1);
		b = this.R1(b, c, d, a, X[i+11], 22, 0x895cd7be);
		a = this.R1(a, b, c, d, X[i+12], 7 , 0x6b901122);
		d = this.R1(d, a, b, c, X[i+13], 12, 0xfd987193);
		c = this.R1(c, d, a, b, X[i+14], 17, 0xa679438e);
		b = this.R1(b, c, d, a, X[i+15], 22, 0x49b40821);

		a = this.R2(a, b, c, d, X[i+ 1], 5 , 0xf61e2562);
		d = this.R2(d, a, b, c, X[i+ 6], 9 , 0xc040b340);
		c = this.R2(c, d, a, b, X[i+11], 14, 0x265e5a51);
		b = this.R2(b, c, d, a, X[i+ 0], 20, 0xe9b6c7aa);
		a = this.R2(a, b, c, d, X[i+ 5], 5 , 0xd62f105d);
		d = this.R2(d, a, b, c, X[i+10], 9 ,  0x2441453);
		c = this.R2(c, d, a, b, X[i+15], 14, 0xd8a1e681);
		b = this.R2(b, c, d, a, X[i+ 4], 20, 0xe7d3fbc8);
		a = this.R2(a, b, c, d, X[i+ 9], 5 , 0x21e1cde6);
		d = this.R2(d, a, b, c, X[i+14], 9 , 0xc33707d6);
		c = this.R2(c, d, a, b, X[i+ 3], 14, 0xf4d50d87);
		b = this.R2(b, c, d, a, X[i+ 8], 20, 0x455a14ed);
		a = this.R2(a, b, c, d, X[i+13], 5 , 0xa9e3e905);
		d = this.R2(d, a, b, c, X[i+ 2], 9 , 0xfcefa3f8);
		c = this.R2(c, d, a, b, X[i+ 7], 14, 0x676f02d9);
		b = this.R2(b, c, d, a, X[i+12], 20, 0x8d2a4c8a);

		a = this.R3(a, b, c, d, X[i+ 5], 4 , 0xfffa3942);
		d = this.R3(d, a, b, c, X[i+ 8], 11, 0x8771f681);
		c = this.R3(c, d, a, b, X[i+11], 16, 0x6d9d6122);
		b = this.R3(b, c, d, a, X[i+14], 23, 0xfde5380c);
		a = this.R3(a, b, c, d, X[i+ 1], 4 , 0xa4beea44);
		d = this.R3(d, a, b, c, X[i+ 4], 11, 0x4bdecfa9);
		c = this.R3(c, d, a, b, X[i+ 7], 16, 0xf6bb4b60);
		b = this.R3(b, c, d, a, X[i+10], 23, 0xbebfbc70);
		a = this.R3(a, b, c, d, X[i+13], 4 , 0x289b7ec6);
		d = this.R3(d, a, b, c, X[i+ 0], 11, 0xeaa127fa);
		c = this.R3(c, d, a, b, X[i+ 3], 16, 0xd4ef3085);
		b = this.R3(b, c, d, a, X[i+ 6], 23,  0x4881d05);
		a = this.R3(a, b, c, d, X[i+ 9], 4 , 0xd9d4d039);
		d = this.R3(d, a, b, c, X[i+12], 11, 0xe6db99e5);
		c = this.R3(c, d, a, b, X[i+15], 16, 0x1fa27cf8);
		b = this.R3(b, c, d, a, X[i+ 2], 23, 0xc4ac5665);

		a = this.R4(a, b, c, d, X[i+ 0], 6 , 0xf4292244);
		d = this.R4(d, a, b, c, X[i+ 7], 10, 0x432aff97);
		c = this.R4(c, d, a, b, X[i+14], 15, 0xab9423a7);
		b = this.R4(b, c, d, a, X[i+ 5], 21, 0xfc93a039);
		a = this.R4(a, b, c, d, X[i+12], 6 , 0x655b59c3);
		d = this.R4(d, a, b, c, X[i+ 3], 10, 0x8f0ccc92);
		c = this.R4(c, d, a, b, X[i+10], 15, 0xffeff47d);
		b = this.R4(b, c, d, a, X[i+ 1], 21, 0x85845dd1);
		a = this.R4(a, b, c, d, X[i+ 8], 6 , 0x6fa87e4f);
		d = this.R4(d, a, b, c, X[i+15], 10, 0xfe2ce6e0);
		c = this.R4(c, d, a, b, X[i+ 6], 15, 0xa3014314);
		b = this.R4(b, c, d, a, X[i+13], 21, 0x4e0811a1);
		a = this.R4(a, b, c, d, X[i+ 4], 6 , 0xf7537e82);
		d = this.R4(d, a, b, c, X[i+11], 10, 0xbd3af235);
		c = this.R4(c, d, a, b, X[i+ 2], 15, 0x2ad7d2bb);
		b = this.R4(b, c, d, a, X[i+ 9], 21, 0xeb86d391);

		a = this.add(a, aO);
		b = this.add(b, bO);
		c = this.add(c, cO);
		d = this.add(d, dO);
	  }
	  if (Type == 32)
	  {
		return this.hex(a) + this.hex(b) + this.hex(c) + this.hex(d);
	  }
	  else
	  {
		return this.hex(b) + this.hex(c);
		//Dicky modified this to fit 16byte database password @ 2005-9-2 11:21:15
	  }
	},

	//设置Cookie的值
	setCookie:function (name, value, path, domain, expires, secure)
	{
		//var de_expires = new Date();  
		//de_expires.setTime(de_expires.getTime() + 1 * 30 * 24 * 60 * 60 * 1000);  
		/* 1个月 x 一个月当作 30 天 x 一天 24 小时 x 一小时 60 分 x 一分 60 秒 x 一秒 1000 毫秒 */
		document.cookie = name + "=" + escape (value) + /*"; expires=" +
       		((expires) ?  expires : de_expires.toGMTString()) +*/
        	((path) ? "; path=" + path : "") +
        	((domain) ? "; domain=" + domain : "") +
        	((secure) ? "; secure" : "");
	},


	//取出Cookie的值
	getCookie:function (name)
	{
		if(name == '')
			return('');
		name_index = document.cookie.indexOf(name + '=');//判断'='所在位置
		if(name_index == -1)
			return('');
		cookie_value =  document.cookie.substr(name_index + name.length + 1, 
										   document.cookie.length);
		end_of_cookie = cookie_value.indexOf(';');
		if(end_of_cookie != -1)
			cookie_value = cookie_value.substr(0, end_of_cookie);
		space = cookie_value.indexOf('+');
		while(space != -1)
		 { 
			cookie_value = cookie_value.substr(0, space) + ' ' + 
			cookie_value.substr(space + 1, cookie_value.length);		 
			space = cookie_value.indexOf('+');
		 }
	return(unescape(cookie_value));
	},

	//清除指定Cookie的值
	clearCookie:function (name)
	{                  
	   var expires = new Date();
	   expires.setTime (expires.getTime() - 1);
	   this.setCookie( name , "Delete Cookie", null,null,false,expires,null);	 
	},

	//生成随机数组
	Shuffle:function (ary)
	{
		for ( var i=ary.length-1 ; i >= 0 ; i-- )
		{
			 var v = parseInt(Math.random()*(i+1));
			 var tmp = ary[v];					   
			 ary[v] = ary[i];						
			 ary[i] = tmp;   
		}
		return ary; 
	},
	
	//开新窗口浏览
	//屏蔽一切可以屏蔽的可视工具
	OpenWin:function (url,width,height){
		var newwin=window.open(url,'newwin','width='+width+',height='+height+',top=100, left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no, status=no');
		newwin.focus();
	}
}



