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
	  }
	},

	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);  
		document.cookie = name + "=" + escape (value) + "; expires=" +
       		((expires) ?  expires : de_expires.toGMTString()) +
        	((path) ? "; path=" + path : "") +
        	((domain) ? "; domain=" + domain : "") +
        	((secure) ? "; secure" : "");
	},


	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));
	},


	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,top,left,scrollbars){
		var newwin=window.open(url,'newwin','width='+width+',height='+height+',top='+top+', left='+left+',toolbar=no,menubar=no,scrollbars='+scrollbars+',resizable=no,location=no, status=no');
		newwin.focus();
	},
	
	imgChang:function (img_url,width,height){
		document.getElementById('previewImage').innerHTML="<img src='"+img_url+"' width='"+width+"' height='"+height+"' border=0>";
		alert(document.getElementById('previewImage').innerHTML);
	},

	goURL:function (s_url) { 
		window.location=s_url;
	},

	delete_record:function (s_url,text)
	{
		  if(true==confirm(text))
		  {
			  this.goURL(s_url);  
		  }
	},

	delete_record_null:function (s_url)
	{
		  if(true==confirm('Are you sure you wish to delete this?'))
		  {
			  this.goURL(s_url);  
		  }
	},
	NumOnly:function (evt)
	{	
		var isie = (document.all) ? true : false;
        var i;
        if (isie)
		{
            i = window.event.keyCode;
			if (i>57 || i<48)
			{
				window.event.keyCode=27;
			}
			if (i==keycode)
			{
				window.event.keyCode=keycode;
			}
		}
        else
		{
			var keycode = evt.keyCode || evt.charCode; 
			if (keycode  < 48 || keycode > 57) 
			{             
				evt.preventDefault(); 
				return false; 
			}
		}
	},

	clear_value:function (s)
	{
		s.value = '';
	},

	countWords:function (obj)
	{
		var tmp=0;
		for(i=0;i<obj.length;i++){
			/[^ -}]/.test(obj.charAt(i))?tmp+=2:tmp++;
		}
		return tmp;
	},

	fontAbride:function (obj,n)
	{
		var num = this.countWords(obj);
		if(num>n)
		{
			alert(num+" characters. Your input exceeded the number of characters allowed. Extra characters will be truncated.");
			return false;
		}
		return true;
	},

	//checkbox all
	check_box_all:function (obj,op_obj_name,status)
	{
		var obj_name = document.getElementsByName(op_obj_name);
		var len = obj_name.length;
		//alert(len);
		if(status == 1)
		{
			for(i=0;i<len;i++)
			{
				obj_name[i].checked = true;
				
			}
		}
		else
		{
			for(i=0;i<len;i++)
			{
				obj_name[i].checked = false;
				
			}
		}
	},

	all_select:function (a,delete_id)
	{
		if(a.checked)
		{
			this.check_box_all(a,delete_id+'[]',1);
		}
		else
		{
			this.check_box_all(a,delete_id+'[]',0);
		}
	},

	//srcStr is number, nAfterDot is decimal
	FormatNumber:function (srcStr,nAfterDot)
	{
		var srcStr,nAfterDot;
		var resultStr,nTen;
		srcStr = ""+srcStr+"";
		strLen = srcStr.length;
		dotPos = srcStr.indexOf(".",0);
		if (dotPos == -1)
		{
			resultStr = srcStr+".";
			for (i=0;i<nAfterDot;i++)
			{
				resultStr = resultStr+"0";
			}
			return resultStr;
		}
		else
		{
			if ((strLen - dotPos - 1) >= nAfterDot)
			{
				nAfter = dotPos + nAfterDot + 1;
				nTen =1;
				for(j=0;j<nAfterDot;j++)
				{
					nTen = nTen*10;
				}
				resultStr = Math.round(parseFloat(srcStr)*nTen)/nTen;
				return resultStr;
			}
			else
			{
				resultStr = srcStr;
				for (i=0;i<(nAfterDot - strLen + dotPos + 1);i++)
				{
					resultStr = resultStr+"0";
				}
				return resultStr;
			}
		}
	},
	
	//batch delete 
	del_all:function (form_name,delete_id)
	{
		var del_array = document.getElementsByName(delete_id+'[]');
		var len = del_array.length;
		for(i=0;i<len;i++)
		{
			if(del_array[i].checked == true)
			{
				var stuats = 1;
			}
		}
		if(stuats!=1)
		{
			alert("Please selected.");
		}
		else
		{
			if(true==confirm('Are you sure to delete all selected?'))
		  {
			  form_name.submit(); 
		  }
		}
	}
}


function cart_submit()
{
	var cart_id_array = document.getElementsByName('cart_id[]');
	var num = cart_id_array.length;
	var cart_status = 0;
	for(i=0 ; i<num ; i++)
	{
		if(cart_id_array[i].checked == true)
		{
			cart_status = 1;
			break;
		}
	}
	if(cart_status == '1')
	{
		document.shopping_cart_form.submit();
	}
	else
	{
		alert('请选择需要结算的商品.');
	}
}

function show_div(l,s)
{
	var startx = 0;
	var starty = 0;
	for(var p = document.getElementById('view_'+l); p && p.tagName!='BODY'; p = p.offsetParent)
	{
	startx += p.offsetLeft;
      	starty += p.offsetTop;
   	}
	document.getElementById(s).style.display = '';
	document.getElementById(s).style.left=startx+80+'px';
	document.getElementById(s).style.top=starty+'px';
	//key_word = d.split(',');
	//document.write(key_word[0]);
}

function close_div(a)
{
	document.getElementById(a).style.display = 'none';
}
//全选
function allchecked() { 
	var check = document.getElementsByTagName('input');
	for (var i=0; i<check.length; i++) {
		if (check[i].type == 'checkbox' && !check[i].disabled) {
			check[i].checked = !check[i].checked;
		}
	}
}

function checkbox_checked(name) { 
	var check = document.getElementsByTagName('input');
	for (var i=0; i<check.length; i++) {
		if (check[i].type == 'checkbox' && check[i].name == name && !check[i].disabled) {
			check[i].checked = !check[i].checked;
		}
	}
}


