function order_end(form){
	form.ps_mode.value = "write";
	form.action = "order_settle_ok.php";
	form.submit();
	return true;
}
function order_back(form){
	form.ps_mode.value = "back";
	form.action = "order_settle.php";
	form.submit();
	return true;
}
function sendcart(obj){
	var form = document.goods;
	form.addcart.value = obj;
	form.action="goods_cart.php";
	form.submit();
	return;
}
function addtocart(form,obj){
	form.addcart.value = obj;
	form.action="goods_cart.php";
	form.submit();
	return;
}
function sendwish_list(form,obj){
	form.addcart.value = obj;
	form.action="goods_cart.php?mode=wish_list";
	form.submit();
	return;
}
function popup_register(mode,goodsno,sno)
{
	alert("请先登录");
}
// ID 检查
function openoverlap() {
    var m=document.kgogo;

    if (m.id.value == "") {
        alert("请输入ID.");
        m.id.focus();
        return false;
    }

    if ((m.id.value.length < 4) || (m.id.value.length > 16)) {
        alert("请输入ID 4-15位英文字母或数字.");
        m.id.focus();
        return false;
    }
    window.open("overlap.php?form=kgogo&focus=id&muid="+m.id.value,"overlap","width=400,height=250,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

// POPUP增加
function zoomform(zooms){
    if(navigator.appName == 'Netscape') {
        alert("[POPUP增加]\n\n请使用IE4.0 以上浏览器.");
        return;
    }

    zooms.rows = zooms.rows+5;

    //if(zooms.rows == 3){zooms.rows =  10;}
    //else if(zooms.rows == 10){zooms.rows =  20;}
    //else if(zooms.rows == 15){zooms.rows =  20;}
    //else if(zooms.rows == 20){zooms.rows =  30;}
    //else if(zooms.rows == 30){zooms.rows =  40;}
    //else {zooms.rows =  3;}
}

// popup
function show_image(uid,img,width,height) {
    newWin = window.open("goods_popup_large.php?image="+img+"&uid="+uid,"show","width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function show_midea(uid,img,width,height) {
    newWin = window.open("goods_popup_midea.php?image="+img+"&uid="+uid,"show","width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function show_mall_image(uid,img,width,height) {
    newWin = window.open("goods_popup_large.php?image="+img+"&uid="+uid,"show","width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

function show_board_image(img,width,height) {
    newWin = window.open("board_image.php?image="+img,"show","width="+width+",height="+height+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

var p_sel_num = 0;
function select_radio(num) {
   p_sel_num =  num;
}

function submit_vote() {
   if (p_sel_num == 0) {
      alert('请选择投票选项.');
      return;
   }
   winopen("poll_vote.php?action=vote&num="+p_sel_num,"问卷调查",400,350);
}

function view_vote() {
   winopen("poll_vote.php?action=view","问卷调查",400,350);
}

function winopen(url,title,w,h) {
		newwin = window.open(url,title,"toolbar=0,location=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" + w + ",height=" + h + ",alwaysRadised=0");
		newwin.focus();
}

// main登录部分
function check_main_login() {
    var m=document.kgogo_main_login;
	
	    //alert(m.ps_murl.value);
	    if (m.ps_ssl.value == 1 && m.ps_murl.value)
	    {
		    m.action = m.ps_murl.value;
	    }

    if (m.login_id.value.length == "") {
       alert("请输入ID");
       m.login_id.focus();
       return false;
    }

    if (m.login_pass.value.length == "") {
       alert("请输入密码");
       m.login_pass.focus();
      return false;
    }

}

// 顶部登录部分
function check_top_login() {
    var m=document.kgogo_top_login;
	
	    //alert(m.ps_murl.value);
	    if (m.ps_ssl.value == 1 && m.ps_murl.value)
	    {
		    m.action = m.ps_murl.value;
	    }

    if (m.login_id.value.length == "") {
       alert("请输入ID");
       m.login_id.focus();
       return false;
    }

    if (m.login_pass.value.length == "") {
       alert("请输入密码");
       m.login_pass.focus();
      return false;
    }

}

// 左侧登录部分
function check_left_login() {
    var m=document.kgogo_left_login;
	
	    //alert(m.ps_murl.value);
	    if (m.ps_ssl.value == 1 && m.ps_murl.value)
	    {
		    m.action = m.ps_murl.value;
	    }

    if (m.login_id.value.length == "") {
       alert("请输入ID");
       m.login_id.focus();
       return false;
    }

    if (m.login_pass.value.length == "") {
       alert("请输入密码");
       m.login_pass.focus();
      return false;
    }

}

// 会员ID和密码检索
function check_member_loss() {
    var m=document.kgogo_loss;
/*
    if (m.loss_name.value.length == "") {
       alert(" 请输入名字. ");
       m.loss_name.focus();
       return false;
    }
*/
    if (m.loss_email.value.length == "") {
       alert(" 请输入E-mail. ");
       m.loss_email.focus();
      return false;
    }

}

// 会员注销
function check_member_delete() {
    var m=document.kgogo_delete;

    if (m.del_id.value.length == "") {
       alert(" 请输入ID. ");
       m.del_id.focus();
       return false;
    }

    if (m.del_pass.value.length == "") {
       alert(" 请输入密码. ");
       m.del_pass.focus();
      return false;
    }
/*
    if (m.del_name.value.length == "") {
       alert(" 请输入名字. ");
       m.del_name.focus();
       return false;
    }
*/
    if (m.del_email.value.length == "") {
       alert(" 请输入E-mail. ");
       m.del_email.focus();
      return false;
    }

}

// 简单检索
function check_top_search() {
    var m=document.kgogo_top_search;

    if (m.ps_search.value.length == "") {
       alert("请输入关键词");
       m.ps_search.focus();
       return false;
    }
}

// popup移动脚本

function open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? 'yes' : 'no';
  menubar_str = menubar ? 'yes' : 'no';
  statusbar_str = statusbar ? 'yes' : 'no';
  scrollbar_str = scrollbar ? 'yes' : 'no';
  resizable_str = resizable ? 'yes' : 'no';

  newWin= window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function coupon_overlap() {
    var m=document.kgogo;

    if (m.coupon.value == "") {
        alert("请输入优惠券");
        m.coupon.focus();
        return false;
    } else {	
    location = "order_settle.php?action=showbasket&kid="+m.kid.value+"&price="+m.price.value+"&coupon="+m.coupon.value;
	return true;
	}
}

// 会员条款确认形式
function check_license_submit() {
	if(!document.license.accept.checked) {
		alert("[注册之前请认真阅读会员注册条款] \n\n只有完全阅读、理解并同意会员注册条款中的内容方能注册会员.");
		return false;
	}
	return true;
}

// ID检测
function open_member_overlap() {
    var m=document.kgogo;

    if (m.id.value == "") {
        alert("请输入用户名.");
        m.id.focus();
        return false;
    }

    if ((m.id.value.length < 4) || (m.id.value.length > 16)) {
        alert("请输入用户名 4-16位英文字母或数字组合.");
        m.id.focus();
        return false;
    }

    window.open("overlap.php?form=kgogo&focus=id&muid="+m.id.value,"overlap","width=400,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
}

// 会员注册检查
function check_member_form() {
var m=document.kgogo;
//alert(m.ps_murl.value);
if(m.ps_ssl.value == 1 && m.ps_murl.value)
{
     m.action = m.ps_murl.value;
}
if ((m.id.value.length < 4) || (m.id.value.length > 16)) {
   alert("请输入用户名 4-16位英文字母或数字组合.");
   m.id.focus();
   return false;
}

if (m.pass1.value.length < 4 || (m.id.value.length > 16)) {
   alert("请输入密码，不少于四个字符，不多于二十个字符");
   m.pass1.focus();
   return false;
}

if ((m.pass1.value) != (m.pass2.value)) {
    alert("密码不一致 请正确输入. ");
    m.pass1.focus();
    return false;
}

if (m.email.value.length == "") {
    alert("请输入 E-mail");
    m.email.focus();
    return false;
}
else
	{
		patn = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		if(!patn.test(m.email.value))
		{
			alert ("电子邮件格式不正确，请输入正确的电子邮件地址！！"); 
      		m.email.focus (); 
      		return false; 
		}
	}
}

//缺货登记
function check_lackform() {
var m=document.kgogo;
   
        if ( m.name.value.length == "" ) {
			alert("请输入商品名称." );
			m.name.focus();
			return false;
		}
		
		if ( m.brand.value.length == "" ) {
			alert("请输入商品品牌." );
			m.brand.focus();
			return false;
		}
		
		if ( m.username.value.length == "" ) {
			alert("请输入您的姓名." );
			m.username.focus();
			return false;
		}
		
		if ( m.email.value.length == "" ) {
			alert("请输入您的E-mail." );
			m.email.focus();
			return false;
		}
		else
	{
		patn = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		if(!patn.test(m.email.value))
		{
			alert ("电子邮件格式不正确，请输入正确的电子邮件地址！！"); 
      		m.email.focus (); 
      		return false; 
		}
	}
}

//订购
function check_userinfo() {
var m=document.kgogo;
//alert(m.ps_murl.value);
if(m.ps_ssl.value == 1 && m.ps_murl.value)
{
     m.action = m.ps_murl.value;
}
        if ( m.buyer_name1.value.length == "" ) {
			alert("请输入购货人[姓名]" );
			m.buyer_name1.focus();
			return false;
		}

           for(i=0;i<m.buyer_name1.value.length;i++) {
        c = m.buyer_name1.value.charAt(i);   
        if(!((c < '0' || c > '9')&&(c < 'a' || c > 'z')&&(c < 'A' || c > 'Z'))){
           alert("购货人[姓]名只能输入中文.");        
           m.buyer_name1.value="";
		   m.buyer_name1.focus();
           return false;        
		}
	}


/*
	    if ( m.zip.value.length == "") {
			alert( "请输入[邮政编码]" );
			m.zip.focus();
			return false;
		}
*/
		if ( m.address.value.length == "" ) {
			alert( "请输入[联系地址]" );
			m.address.focus();
			return false;
  	    }




}
function check_userinfo_confirm() {
var m=document.kgogo;

//alert(m.ps_murl.value);
if(m.ps_ssl.value == 1 && m.ps_murl.value)
{
     m.action = m.ps_murl.value;
}

}
// 拷贝
function accept_check(){
   var m = document.kgogo;
   //alert(m.ps_murl.value);
if(m.ps_ssl.value == 1 && m.ps_murl.value)
{
     m.action = m.ps_murl.value;
}
   m.buyer_name3.value = m.buyer_name1.value;
   m.buyer_tel3.value = m.buyer_tel1.value;
   m.buyer_tel4.value = m.buyer_tel2.value;
   m.buyer_oicq1.value = m.buyer_oicq.value;
   m.buyer_msn1.value = m.buyer_msn.value;
   m.zip3.value = m.zip.value;
   m.address2.value = m.address.value;
   m.buyer_email1.value = m.buyer_email.value;
}

// 
function error (elem,text) {
	window.alert(text);
	elem.select();
	elem.focus();
}
/*
// 错误时候检查
function idcardcheck(idcard1) {

		var str_idcard1 = idcard1.value;
		var idcard1_err = idcard1;
		var checkImg='';


		var i3=0
		for (var i=0;i<str_idcard1.length;i++)
		{
		    var ch1 = str_idcard1.substring(i,i+1);
		    if ((ch1<'0' || ch1>'9')&&(ch1 < 'a' || ch1 > 'z')&&(ch1 < 'A' || ch1 > 'Z')) { i3=i3+1 }
		}
		if ((str_idcard1 == '') || ( i3 != 0 ))
		{
  		  error(idcard1_err,'身份证号码错误.\n\n请重新输入!');
  		  return false;
		}

		var i9=0

		return true;

}
*/
function check_member_modify() {
var m=document.kgogo;

if ((m.old_pass.value) == "") {
        alert("修改资料请输入密码");
        m.old_pass.focus();
       return false;
    }

if (m.pass1.value.length > 0) {
	if (m.pass1.value.length < 4) {
	   alert("密码必须4位以上.");
	}

    if ((m.pass1.value) != (m.pass2.value)) {
        alert("密码不一致，请重新输入. ");
        m.pass1.focus();
       return false;
    }
}
/*
if (m.email.value.length == "") {
    alert("请输入 E-mail");
    m.email.focus();
    return false;
}
else
	{
		patn = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		if(!patn.test(m.email.value))
		{
			alert ("电子邮件格式不正确，请输入正确的电子邮件地址！！"); 
      		m.email.focus (); 
      		return false; 
		}
	}

if (m.name.value.length == "") {
    alert("请输入 姓名");
    m.name.focus();
    return false;
}

if ((m.zip.value.length == "")) {
alert("请输入 邮政编码");
m.zip.focus();
return false;
}

if (m.address.value.length == "") {
alert("请输入 联系地址");
m.address.focus();
return false;
}

if (m.tel1.value.length == "") {
alert("请输入电话号码");
m.tel1.focus();
return false;
}
*/
}

// 删除时询问脚本
function del_really(){
    if (confirm('\n数据将被完全删除且不可恢复\n\n确定要删除吗？\n')) return true;
    return false;
}

//board发表回复
function board_check() {
    var m=document.kgogo_comment;

    if (m.board_subject.value.length < 3) {
        alert("请输入标题");
        m.board_subject.focus();
        return false;
    }
	
	if (m.board_name.value.length < 3) {
        alert("请输入昵称");
        m.board_name.focus();
        return false;
    }

    if (m.board_body.value.length < 3) {
        alert("请输入内容");
        m.board_body.focus();
        return false;
    }

}

// E-mail
function kgogo_mailer_check() {
    var m=document.kgogo_mailer;

    if (m.mailer_receive_email.value.length == "") {
       alert("请输入接收E-mail.");
       m.mailer_receive_email.focus();
      return false;
    }

    if (m.mailer_subject.value.length == "") {
       alert("请输入邮件标题.");
       m.mailer_subject.focus();
      return false;
    }

    if (m.mailer_body.value.length == "") {
       alert("请输入邮件内容.");
       m.mailer_body.focus();
      return false;
    }

}

// 商品推荐E-mail
function kgogo_recommend_check() {
    var m=document.kgogo_mailer;

    if (m.mailer_receive_email.value.length == "") {
       alert("请输入接收E-mail");
       m.mailer_receive_email.focus();
      return false;
    }
	
	if (m.mailer_body.value.length == "") {
       alert("请输入内容");
       m.mailer_body.focus();
      return false;
    }
}

function really_all(){
    if (confirm('\n数据将被完全删除且不可恢复\n\n确定要删除吗？\n')) 
	{ 
	  document.uid_check_form.submit();
	}
    return false;
}

function allproducts_excel(form_name){
    if (confirm('下载商品报价单 Excel_csv格式')) {
	    form_name.amode.value = "products_excel";
	    form_name.action = "kgogoprime_excel.php";
	    form_name.submit();
	    return true;
	}

	return false;
}

function OverImg(imageUrl)
{
	if (document.images.overimage)
		document.images.overimage.src = imageUrl;
}
function outSubM(obj) {
	SubM.style.display = 'none';
}
function overSubM(obj) {
	SubM.style.display = 'block';
}

/*** flash ***/
function embed(src,width,height,vars)
{
	document.write('\
	<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="'+width+'" HEIGHT="'+height+'">\
	<PARAM NAME=movie VALUE="'+src+'">\
	<PARAM NAME=quality VALUE=high>\
	<PARAM NAME=wmode VALUE=transparent>\
	<PARAM NAME=bgcolor VALUE=#FFFFFF>\
	<param name=flashvars value="' + vars + '">\
	<EMBED src="'+src+'" quality=high bgcolor=#FFFFFF WIDTH="'+width+'" HEIGHT="'+height+'" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" flashvars="' + vars + '"></EMBED>\
	</OBJECT>\
	');
}
/*-----------------------------
 时间显示.
-----------------------------*/
function TOfunc(){
  var s, d;
  var x = new Array(" [日] ", " [一] ", " [二] ", " [三] "," [四] ", " [五] ", " [六] ");

  window.setTimeout("TOfunc()",1000);
  d = new Date();

  s = d.getFullYear() + ".";
  //if(d.getMonth()<10){ s += "0" };
  s += (d.getMonth() + 1) + ".";
  if(d.getDate()<10){ s += "0" };
  s += d.getDate() + "";
  s += x[d.getDay()] + "";
  if(d.getHours()<10){ s += "0" };
  s += d.getHours() + ":";
  if(d.getMinutes()<10){ s += "0" };
  s += d.getMinutes() + ":";
  if(d.getSeconds()<10){ s += "0" };
  s += d.getSeconds();

  frmTime3.disp.value = s;
}
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function verifyNumber(n)
{
	var patn = /^\d+$|^\d+\.\d{1,2}$/;
	if(patn.test(n))
		return false;
	return true;
}

function good_cal(val)
{
	if (val > 0){
		goods.ea.value = (goods.ea.value*1) + 1;
	} else {
		if(goods.ea.value>1){ 
			goods.ea.value = goods.ea.value - 1;
		}
	}
	return;
}

function error (elem,text) {
	window.alert(text);
	elem.select();
	elem.focus();
}

function eScroll()
{	
	var thisObj = this;
	this.timeObj = null;
	
	/***  ***/
	this.mode = "top";				//  (top|left)
	this.width = "100%";			//  (pixel)
	this.height = 20;				//  (pixel)
	this.line = 1;					// 
	this.delay = 150;				// 
	this.speed = 1;					// 
	this.id = 'obj_eScroll';		//  id
	this.contents = new Array();	// 
	this.align = "left";			//  aligne
	this.valign = "middle";			//  valigne

	/***  ***/
	this.gap = 0;
	this.direction = 1;

	this.add = add;
	this.exec = exec;
	this.start = start;
	this.stop = stop;
	this.scroll = scroll;
	this.direct = direct;
	this.go = go;

	function add(str)
	{
		this.contents[this.contents.length] = str;
	}
	
	function exec()
	{
		this.basis = (this.mode == "left") ? this.width : this.height;
		var outWidth = this.width * ((this.mode == "left") ? this.line : 1);
		var outHeight = this.height * ((this.mode == "top") ? this.line : 1);
		
		var outline = "<div id=" + this.id + " style='overflow:hidden;width:" + outWidth + ";height:" + outHeight + "'><table></table></div>";
		document.write(outline);
		this.obj = document.getElementById(this.id);
		
		var tb = this.obj.appendChild(document.createElement("table"));
		var tbody = tb.appendChild(document.createElement("tbody"));
		tb.cellPadding = 0 ;
		tb.cellSpacing = 0 ;
		tb.onmouseover = function(){thisObj.stop()};
		tb.onmouseout = function(){thisObj.start()};
		
		if (this.mode=="left") var tr = tbody.appendChild(document.createElement("tr"));
		for (k in this.contents){
			if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
			var td = tr.appendChild(document.createElement("td"));
			td.noWrap = true;
			td.style.width = this.width;
			td.style.height = this.height;
			td.style.textAlign = this.align;
			td.style.verticalAlign = this.valign;
			td.innerHTML = this.contents[k];
		}
		
		var len = (this.contents.length<this.line) ? this.contents.length : this.line;
		for (i=0;i<len;i++){
			if (this.mode=="top") var tr = tbody.appendChild(document.createElement("tr"));
			td = tr.appendChild(document.createElement("td"));
			td.noWrap = true;
			td.style.width = this.width;
			td.style.height = this.height;
			td.style.textAlign = this.align;
			td.style.verticalAlign = this.valign;
			td.innerHTML = this.contents[i];
		}

		this.obj.parent = this;
		this.tpoint = this.basis * this.contents.length;
		this.start();
	}

	function scroll()
	{
		var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
		if (out%this.basis==0){
			this.gap++;
			if (this.gap>=this.delay) this.gap = 0;
		}
		if (!this.gap){
			var ret = (out==this.tpoint) ? this.direction : out + this.direction;
			if (ret<0) ret = this.tpoint + ret;
			if (this.mode=="left") this.obj.scrollLeft = ret;
			else this.obj.scrollTop = ret;
		}
	}

	function start()
	{
		this.timeObj = window.setInterval("(document.getElementById('" + this.id + "')).parent.scroll()",this.speed);
	}

	function stop()
	{
		clearTimeout(this.timeObj);
	}

	function direct(d)
	{
		this.direction = d;
	}

	function go()
	{
		this.stop();
		var out = (this.mode=="left") ? this.obj.scrollLeft : this.obj.scrollTop;
		var ret = (parseInt(out / this.basis) + this.direction) * this.basis;
		if (ret<0) ret = this.tpoint + ret;
		if (ret>this.tpoint) ret = this.basis;
		if (this.mode=="left") this.obj.scrollLeft = ret;
		else this.obj.scrollTop = ret;
	}

}
/*-------------------------------------
 'displayer' DIV 输出
-------------------------------------*/
function displayLay( getno ){

	if ( document.all.displayer.length==null ) document.all.displayer.style.display='block';
	else document.all.displayer[getno].style.display='block';
}

/*-------------------------------------
 'displayer' DIV
-------------------------------------*/
function disableLay( getno ){

	if ( document.all.displayer.length==null ) document.all.displayer.style.display='none';
	else document.all.displayer[getno].style.display='none';
}

if ( typeof( scrollingX ) == 'undefined' ){

	var scrollingX = function( objnm, elenm ){

		if ( objnm == '' ) return;
		if ( elenm == '' ) return;
		this.obj = objnm;
		this.ele = eval( "window.frames." + elenm );

		this.time = 20; // 
		this.drX = 1; // 
		this.scrollX = 0;
		this.is_move = 1;
		this.ele.scrollTo( 1, 0 );
	}

	scrollingX.prototype.stop = function(){ this.is_move = 0; }
	scrollingX.prototype.start = function(){ this.is_move = 1; }

	scrollingX.prototype.initScroll = function()
	{
		this.p_bound = this.ele.document.body.scrollWidth - this.ele.document.body.offsetWidth;
		this.p_moveRight = Math.floor( this.ele.document.body.scrollWidth / 2 );
		this.p_moveLeft = this.p_bound - this.p_moveRight;

		setInterval( this.obj + '.goScrolling()', this.time );
	}

	scrollingX.prototype.goMove = function( idx )
	{
		if ( idx == 0 ) this.drX = -Math.abs( this.drX );
		else this.drX = +Math.abs( this.drX );

		var pos = this.scrollX + idx;
		this.ele.scrollTo( pos, 0 );
	}

	scrollingX.prototype.goScrolling = function()
	{
		if ( !this.is_move ) return;
		this.scrollX = this.ele.document.body.scrollLeft + this.drX; // window.status = this.scrollX;
		if ( this.drX < 0 && this.scrollX < 1 ) this.scrollX = this.p_moveRight;
		if ( this.drX > 0 && this.scrollX > this.p_bound ) this.scrollX = this.p_moveLeft;
		this.ele.scrollTo( this.scrollX, 0 );
	}
}

if ( typeof( scrollingY ) == 'undefined' ){

	var scrollingY = function( objnm, elenm ){

		if ( objnm == '' ) return;
		if ( elenm == '' ) return;
		this.obj = objnm;
		this.ele = eval( "window.frames." + elenm );

		this.time = 20; // 
		this.drY = 1; // 
		this.scrollY = 0;
		this.is_move = 1;
		this.ele.scrollTo( 0, 1 );
	}

	scrollingY.prototype.stop = function(){ this.is_move = 0; }
	scrollingY.prototype.start = function(){ this.is_move = 1; }

	scrollingY.prototype.initScroll = function()
	{
		this.p_bound = this.ele.document.body.scrollHeight - this.ele.document.body.offsetHeight;
		this.p_moveBot = Math.floor( this.ele.document.body.scrollHeight / 2 );
		this.p_moveTop = this.p_bound - this.p_moveBot;

		setInterval( this.obj + '.goScrolling()', this.time );
	}

	scrollingY.prototype.goMove = function( idx )
	{
		if ( idx == 0 ) this.drY = -Math.abs( this.drY );
		else this.drY = +Math.abs( this.drY );

		var pos = this.scrollY + idx;
		this.ele.scrollTo( 0, pos );
	}

	scrollingY.prototype.goScrolling = function()
	{
		if ( !this.is_move ) return;
		this.scrollY = this.ele.document.body.scrollTop + this.drY; // window.status = this.scrollY;
		if ( this.drY < 0 && this.scrollY < 1 ) this.scrollY = this.p_moveBot;
		if ( this.drY > 0 && this.scrollY > this.p_bound ) this.scrollY = this.p_moveTop;
		this.ele.scrollTo( 0, this.scrollY );
	}
}

var preContent;
function view_content(obj)
{
	var div = obj.parentNode;

	if ( document.all ) obj = div.childNodes[ 1 ]; else obj = div.childNodes[ 3 ]; // 

	if (preContent && obj!=preContent){
		obj.style.display = "block";
		preContent.style.display = "none";
	}
	else if (preContent && obj==preContent) preContent.style.display = ( preContent.style.display == "none" ? "block" : "none" );
	else if (preContent == null ) obj.style.display = "block";

	preContent = obj;
	resizeFrame();
}

function resizeFrame()
{

    var oBody = document.body;
    var oFrame = parent.document.getElementById("inqna");
//    var i_height = oBody.scrollHeight + (oFrame.offsetHeight-oFrame.clientHeight);
//    oFrame.style.height = i_height;
}
function table_design_load()
{
	var tb = document.getElementsByTagName('table');
	for (i=0;i<tb.length;i++){
		if (tb[i].className=="tb"){
			with (tb[i]){
				border = 1;
				borderColor = "#EBEBEB";
				//frame = "hsides";
				//rules = "rows";
				//cellPadding = "4";
			}
			with (tb[i].style){
				width = "100%";
				borderCollapse = "collapse";
			}
		}
	}
}

// 地址
function GetProvince(strTheForm,strProvince,strCity,strCounty,strProvinceID)
{
	strProvince = strTheForm + "." + strProvince
	strCity = strTheForm + "." + strCity
	strCounty = strTheForm + "." + strCounty
	var TheProvince = eval(strProvince)
	var TheCity = eval(strCity)
	var TheCounty = eval(strCounty)
	TheCity.disabled = true
	TheCounty.disabled = true
    if(Province.length != 0)
    {
        TheProvince.options.length = 0
        TheProvince.options[0] = new Option('省份','')
        TheProvince.options[0].selected = true
        var j = 1
        for(i=0;i<Province.length;i+=2)
        {
            if(Province[i] == "" || Province[i+1] == "")
            {
            	continue
            }
        	else
        	{
        		TheProvince.options[j] = new Option(Province[i+1],Province[i])
        		j++
        	}
        }
    }
    if(strProvinceID != "")
    {
    	strProvinceID = strProvinceID.toString()
    	var L_strProvinceID = strProvinceID.length
    	if(L_strProvinceID < 12)
    	{
    		for(i=0;i<12-L_strProvinceID;i++)
    		{
    			strProvinceID += "0"
    		}
    	}
    	var DefaultProvince = strProvinceID.substring(0,6)
    	var DefaultCity = strProvinceID.substring(0,9)
    	var DefaultCounty = strProvinceID.substring(0,12)
    	GetDefaultItem(TheProvince,DefaultProvince)
    	GetCity(strTheForm,strProvince,strCity,strCounty)
    	GetDefaultItem(TheCity,DefaultCity)
    	GetCounty(strTheForm,strProvince,strCity,strCounty)
    	GetDefaultItem(TheCounty,DefaultCounty)
    }
}

function GetCity(strTheForm,strProvince,strCity,strCounty)
{
	strProvince = strTheForm + "." + strProvince
	strCity = strTheForm + "." + strCity
	strCounty = strTheForm + "." + strCounty
	var TheProvince = eval(strProvince)
	var TheCity = eval(strCity)
	var TheCounty = eval(strCounty)
	if(TheProvince.selectedIndex != 0)
	{
		TheCity.options.length = 0
		TheCity.options[0] = new Option('城市','')
		TheCity.options[0].selected = true
		TheCity.disabled = true
		TheCounty.options.length = 0
		TheCounty.options[0] = new Option('地区','')
		TheCounty.options[0].selected = true
		TheCounty.disabled = true
		CityIndex = TheProvince.options[TheProvince.selectedIndex].value
		var j = 1
        for(i=0;i<City[CityIndex].length;i+=2)
        {
            if(City[CityIndex][i] == "" || City[CityIndex][i+1] == "")
            {
            	continue
            }
        	else
        	{
            	TheCity.options[j] = new Option(City[CityIndex][i+1],City[CityIndex][i])
            	j++
            }
        }
        if(TheCity.options.length > 1) TheCity.disabled = false
	}
	else
	{
		TheCity.options.length = 0
		TheCity.options[0] = new Option('城市','')
		TheCity.options[0].selected = true
		TheCity.disabled = true
		TheCounty.options.length = 0
		TheCounty.options[0] = new Option('地区','')
		TheCounty.options[0].selected = true
		TheCounty.disabled = true
	}
}

function GetCounty(strTheForm,strProvince,strCity,strCounty)
{
	strProvince = strTheForm + "." + strProvince
	strCity = strTheForm + "." + strCity
	strCounty = strTheForm + "." + strCounty
	var TheProvince = eval(strProvince)
	var TheCity = eval(strCity)
	var TheCounty = eval(strCounty)
	if(TheProvince.selectedIndex != 0 && TheCity.selectedIndex != 0)
	{
		TheCounty.options.length = 0
		TheCounty.options[0] = new Option('地区','')
		TheCounty.options[0].selected = true
		TheCounty.disabled = true
		CountyIndex = TheCity.options[TheCity.selectedIndex].value
		var j = 1
        for(i=0;i<County[CountyIndex].length;i+=2)
        {
            if(County[CountyIndex][i] == "" || County[CountyIndex][i+1] == "")
            {
            	continue
            }
        	else
            {
            	TheCounty.options[j] = new Option(County[CountyIndex][i+1],County[CountyIndex][i])
            	j++
            }
        }
        if(TheCounty.options.length > 1) TheCounty.disabled = false
	}
	else
	{
		TheCounty.options.length = 0
		TheCounty.options[0] = new Option('地区','')
		TheCounty.options[0].selected = true
		TheCounty.disabled = true
	}
}

//把地点ID转为相应的地点
function getPlaceValue(strProvinceID)
{
    if (strProvinceID.length < 6) return false;//地点ID小于6是返回false
    var i = 0;
    var strProvince,strCity,strCounty;
    ProvinceID = strProvinceID.substr(0,6);
    CityID = strProvinceID.substr(0,9);
    CountyID = strProvinceID;
    for (i = 0;i < Province.length;i += 2)
    {
        if(Province[i] == ProvinceID)
        {
        	strProvince = Province[i+1]
        	break;
        }
    }
    if (strProvinceID.length > 8)//地点ID小于8不执行以下代码
    {
        for (i = 0;i < City[ProvinceID].length;i += 2)
        {
            if (City[ProvinceID][i] == CityID)
            {
                strCity = City[ProvinceID][i+1];
                break;
            }
        }
        if(strProvinceID.length > 11)//地点ID小于11不执行以下代码
        {
        
            for (i = 0;i < County[CityID].length;i += 2)
            {
                if (County[CityID][i] == CountyID)
                {
                    strCounty = County[CityID][i+1];
                    break;
                }
            }
        }
    }
	
	var strPlace = strProvince;
	if(strCity!=undefined){
		strPlace+=strCity;
		}
	if(strCounty!=undefined){
		strPlace+=strCounty;
	}
    ///var strPlace = strProvince + strCity + strCounty;
    ///return strPlace;
	
	return strPlace;
}
function DrawImage(ImgD,iwidth,iheight)
{
	var flag=false;
	var image=new Image();
	if(!iwidth)
		iwidth = 130;
	if(!iheight)
		iheight = 130;
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
	if(image.width/image.height>= iwidth/iheight){
	if(image.width>iwidth){ 
	ImgD.width=iwidth;
	ImgD.height=(image.height*iwidth)/image.width;
	}else{
	ImgD.width=image.width; 
	ImgD.height=image.height;
	}

	}
	else{
	if(image.height>iheight){ 
	ImgD.height=iheight;
	ImgD.width=(image.width*iheight)/image.height; 
	}else{
	ImgD.width=image.width; 
	ImgD.height=image.height;
	}
	}
	}
}

var price = new Array();
var reserve = new Array();
var consumer = new Array();

function calc_price(){
	
	var frm = document.goods;
	var cea = frm.ea.value;
	var isCntprice = frm.cntprice_yn.value;
	 
	if(isCntprice == "1"){
		var c1 = eval(frm.cnt_1.value);
		var c2 = eval(frm.cnt_2.value);
		var c3 = eval(frm.cnt_3.value);
		var c4 = eval(frm.cnt_4.value);
		
		var c1p = frm.cnt_1_price.value;
		var c2p = frm.cnt_2_price.value;
		var c3p = frm.cnt_3_price.value;
		var c4p = frm.cnt_4_price.value;
		
		
		if(c4 <= cea){
			frm.goods_price.value = c4p;
		}
		else if(c3 <= cea){
			frm.goods_price.value = c3p;
		}
		else if(c2 <= cea){
			frm.goods_price.value = c2p;
		}
		else if(c1 <= cea){
			frm.goods_price.value = c1p;
		}
		else{
			frm.goods_price.value = frm.goods_tmp_price.value;
		}
	}
}

function chg_cart_ea(obj,str,idx)
{
	if (obj.length) obj = obj[idx];
	if (isNaN(obj.value)){
		alert ("非法字符 购买数量只能是数字");
		obj.value=1;
		obj.focus();
	} else {
		if (str=='up') obj.value++;
		else  obj.value--;
		if (obj.value==0) obj.value=1;
	}
	calc_price();
}
function ChecktoAddress(val){
    document.kgogo.address.value=getPlaceValue(val);
}
//2007-05-21
function gimg_img_filter(gimg_ThisID,type){
	var obj = document.getElementById(gimg_ThisID);
	var appname = navigator.appName.charAt(0);
	if( type == "over" ){
		if( appname == "M" ) obj.style.filter = "Alpha(opacity=70)";
		else obj.style.opacity = "0.1";
	}else{
		if( appname == "M" ) obj.style.filter = "";
		else obj.style.opacity = "";
	}
}
function chkBox(El,mode)
{
	if (!El) return;
	if (typeof(El)!="object") El = document.getElementsByName(El);
	for (i=0;i<El.length;i++) El[i].checked = (mode=='rev') ? !El[i].checked : mode;
}
function isChked(El,msg)
{
	if (!El) return;
	if (typeof(El)!="object") El = document.getElementsByName(El);
	if (El) for (i=0;i<El.length;i++) if (El[i].checked) var isChked = true;
	if (isChked){
		return (msg) ? confirm(msg) : true;
	} else {
		alert ("没有选择项");
		return false;
	}
}
/*用户注册*/
function checkusername(){		
	var username=trim($('username').value);
	var cu = $('checkusername');
	var unlen = username.replace(/[^\x00-\xff]/g, "**").length;
	if(unlen < 3 || unlen > 15) {
		warning(cu, unlen < 3 ? username_tooshort : username_toolong);
		return;
	}
	ajaxresponse('checkusername', 'action=checkusername&username=' + username );
}
function checkpass1(confirm) {
	var pass1 = $('pass1').value;
	var cp = $('checkpass1');
	if(pass1 == '' || /[\'\"\\]/.test(pass1)) {
		warning(cp, passwd_illegal);
		return false;
	} else {
		cp.style.display = 'none';
		if(!confirm) {
			checkpass2(true);
		}
		return true;
	}
}
function checkpass2(confirm) {
		var pass1 = $('pass1').value;
		var pass2 = $('pass2').value;
		var cp2 = $('checkpass2');
		if(pass2 != '') {
			checkpass1(true);
		}
		if(pass1 == '' || (confirm && pass2 == '')) {
			cp2.style.display = 'none';
			return;
		}
		if(pass1 != pass2) {
			warning(cp2, passwd_notmatch);
		} else {
			cp2.style.display = 'none';
		}
}
function checkemail() {
	var email = trim($('email').value);
	var ce = $('checkemail');

	illegalemail = !(/^[\-\.\w]+@[\.\-\w]+(\.\w+)+$/.test(email));
	if(illegalemail) {
		warning(ce, illegalemail ? email_illegal : (accessemail != '' ? email_invalid : email_censor));
		return;
	}
	ajaxresponse('checkemail', 'action=checkemail&email=' + email);
}
function trim(str) {
	return str.replace(/^\s*(.*?)[\s\n]*$/g, '$1');
}
function ajaxresponse(objname, data) {
    var x = new Ajax('XML', objname);
    x.get('ajax.php?inajax=1&' + data, function(s){
        var obj = $(objname);
        if(s == 'succeed') {
        	obj.style.display = '';
        	obj.innerHTML = '<img src="images/check_right.gif" width="13" height="13">';
        	obj.className = "warning";
        } else {
        	warning(obj, s);
        }
    });
}
function warning(obj, msg) {
	obj.style.display = '';
	obj.innerHTML = '<img src="images/check_error.gif" width="13" height="13"> &nbsp; ' + msg;
	obj.className = "warning";
}