
//create by liujy at 2008-05-22 ~ 

function js_login()
{
  var username = $('username').value;
  var password = $('password').value;
  var checkcode = $('checkcode').value;

  if (lenb(trim(username))<1)
  {
     alert('请输入用户帐号或格式(长度)不对!');
     $('username').focus();
     return ;
  }
  if (lenb(trim(password))<6)
  {
     alert('请输入用户密码或密码长度不够!');
     $('password').focus();
     return ;
  }
  if (lenb(trim(checkcode))!= 4)
  {
    alert("验证码不能为空或长度不对");
    $('checkcode').focus();
    return;
  }
  
  //if (js_test_mark && js_test_mark()) return ;
  var path = trim($('path').value);
  document.thisForm.target = "ifrm";
  document.thisForm.action = path+"sysctrl?t=1&type=1&v="+Math.random();
  document.thisForm.submit();
} 

//头部分类搜索
function js_search_head()
{
	if($('cataid'))$('cataid').value="";
	if($('taxis'))$('taxis').value="";
  var message = "index.jsp?v="+Math.random();
  var sort = toStr($('sortid').value);
  $("sortvalue").value = $("sortid").options[$("sortid").options.selectedIndex].text
  $('sortid').value = sort;
  //alert(sort+" "+$("sortvalue").value);
  
  var key1 = toStr(trim($('key1').value));
  $('keys').value = escape(key1);
  //alert(key1);
 
  var cata = toStr($('cataid1').value);
  $("cata1value").value = $("cataid1").options[$("cataid1").options.selectedIndex].text
  $('cataid1').value = cata;
  //alert(cata+" "+$("cata1value").value);
  
  var area = toStr($('areaid').value);
  //$("areavalue").value = $("areaid").options[$("areaid").options.selectedIndex].text
  $("areavalue").value = $("areaid1").value;
  $('areaid').value = area;
  //alert(area+" "+$("areavalue").value);
  
  //商品，编码
  if((sort=='sp' || sort=='bm') && cata<0 && area<0){
  	message = "html/search_sp.jsp?v="+Math.random();
  }
  
  //当cata有值时，应跳转的页面
  if(cata != "-1"){
  	message = "html/cata2.jsp?cataid="+cata+"&v="+Math.random();
  }
  //关键字
  if(key1.length>0 && (sort=='sp' || sort=='bm')){
  	message = "html/cata3.jsp?v="+Math.random();
  }
  //地区
  if(area != "-1"){
  	message = "html/cata3.jsp?v="+Math.random();
  }
  
  //品牌
  if(sort=='pp'){
  	message = "html/search_pp.jsp?v="+Math.random();
  }
  
  //店铺
  if(sort=='dp'){
  	message = "html/search_dp.jsp?v="+Math.random();
  }
  
  $('kareaids').value=area;
  $('kcataids').value=cata;
  if($('pagination'))$('pagination').value="";
  var path = trim($('path').value);
  document.thisForm.target = "_self";
  document.thisForm.action = path+message;
  document.thisForm.submit();
}

//尾部分类搜索
function js_search_tail()
{
if($('cataid'))$('cataid').value="";
if($('taxis'))$('taxis').value="";
  var cata2 = toStr($('cataid2').value);
  $("cata2").value = $("cataid2").options[$("cataid2").options.selectedIndex].text
  //alert(cata2+" "+$("cata2").value);
  
  var key2 = toStr(trim($('key2').value));
  $('keys').value = escape(key2);
  //alert(key2);
  
  var path = trim($('path').value);
  //查询所有分类（默认）
  if(cata2 == "-1" && key2.length<1){
  	location = path+"html/search_sp.jsp?v="+Math.random();
  	return ;
  }
  
  var message = "";
  if(key2.length>0){
  	message = "html/cata3.jsp?v="+Math.random();
  }else{
  	message = "html/cata2.jsp?cataid="+cata2+"&v="+Math.random();
  }
  $('kcataids').value=cata2;
  //当cata2有值时，应跳转的页面
  if($('pagination'))$('pagination').value="";
  document.thisForm.target = "_self";
  document.thisForm.action = path+message;
  document.thisForm.submit();
  
} 
//关键字搜索
function js_search()
{if($('cataid'))$('cataid').value="";
	var key = toStr(trim($('key3').value));
  	$('keys').value = escape(key);
  	
  	if(key.length<1){
  		alert("关键字不能为空");
  		return ;
  	}
  
    var path = trim($("path").value);
  	//当cata2有值时，应跳转的页面
  	document.thisForm.target = "_self";
  	document.thisForm.action = path+"html/cata3.jsp?v="+Math.random();
  	document.thisForm.submit();
}

//回调方法(登录 退出)
function js_call2(arr)
{
    var path = trim($("path").value);
    var hrefurl ='';
    if($('hrefurl')) hrefurl= trim($('hrefurl').value);
    
    
    //当层页面登录的操作
    if(lenb(hrefurl)>0 && arr[0]==1){
    	alert(arr[1]);
    	close();//关闭层
    	
    	if(toInt(hrefurl)==1){init_getname();}//我的购物车
    	else if(toInt(hrefurl)==2){init_getname();}//我的订单
    	else if(toInt(hrefurl)==3){init_getname();}//我的积分
    	else if(toInt(hrefurl)==4){init_getname();}//商品管理
    	else if(toInt(hrefurl)==5){init_getname();}//店铺管理
    	else if(toInt(hrefurl)==6){init_getname();}//购物商品
    	else if(toInt(hrefurl)==7){init_getname();}//收藏商品
	    else init_getname();//不跳转页面
	    $('hrefurl').value="";
    }else if(arr[0]==1 && toInt(arr[2])>0){
    	alert(arr[1]);
   	    top.location = path+'sys/index.jsp';
    }else if(arr[0]==1 && toInt(arr[2])==0){
   		alert(arr[1]);
    	top.location = path+'index.jsp';
    }else if(arr[0]==2){
    	top.location = path+'index.jsp';
    }else{
    	alert(arr[1]);
    }
    
}

//回调方法
function js_call3(arr)
{
    var path = trim($("path").value);
    if(arr[0]=='1'){
    	alert(arr[1]);
    	location = path+'index.jsp?v='+Math.random();
    }else{
    	alert(arr[1]);
    	//location = path+'/login.jsp?v='+Math.random();
    }
}

//登录
function js_log()
{
	var userid = $("userid").value;
	if(userid>1){
		alert('请先退出后再登录');
		return ;
	}
	var path = trim($("path").value);
    location = path+'login.jsp?v='+Math.random();
}

//注册惠商
function js_hs()
{
   var path = trim($("path").value);
   location = path+'hszc1.jsp?v='+Math.random();
}

//注册惠客
function js_hk()
{
	var path = trim($("path").value);
   location = path+'hkzc1.jsp?v='+Math.random();
}

//客服中心
function js_kf()
{
	alert("不好意思,正在建设中···");
   //location = 'kf.jsp?v='+Math.random();
}

//我的万惠
function js_back()
{
	var path = trim($("path").value);
   location = path+'sys/index.jsp?v='+Math.random();
}

//退出
function js_exit()
{
	if(!confirm('你确定要退出吗?')) return ;
	//if (js_test_mark && js_test_mark()) return ;
    var path = trim($('path').value);
    $('f').value=0;
    $('t').value=0;
    document.thisForm.target = "ifrm";
    document.thisForm.action = path+"sysctrl?v="+Math.random();
    document.thisForm.submit();
}

//万惠网
function js_whw()
{
	var path = trim($("path").value);
   location = path+'index.jsp?v='+Math.random();
}

//店铺首页
function js_dpsy()
{
	var path = trim($("path").value);

   	//location = path+'store/storemain.jsp?storeid='+$('storeid').value+'&v='+Math.random();
   	location = "http://"+$('username').value+"."+$('domain').value;
}

//购物车
function js_gwc()
{
	var id = '1';
	var userid = $("userid").value;
	var usertype = toInt(trim($('usertype').value));

	var path = trim($("path").value);
	if(userid<1){
		js_popup(id);//登录层
	}else if(usertype!=1){
		alert("只有惠客才能进行此操作");
		return ;
	}else{
    	location = path+'shopcar/shopcar.jsp?v='+Math.random();
    }
}

//我的订单
function js_wddd()
{
	var id = '2';
	var userid = $("userid").value;
	var usertype = toInt(trim($('usertype').value));
	
	var path = trim($("path").value);
	if(userid<1){
		js_popup(id);//登录层
	}else if(usertype!=1){
		alert("只有惠客才能进行此操作");
		return ;
	}else{
		alert("请登陆或注册惠付宝帐号。");
    	//location = path+'shopcar/shopcar.jsp?v='+Math.random();
    }
}

//我的积分
function js_wdjf(id)
{
	var id = '3';
	var userid = $("userid").value;
	var usertype = toInt(trim($('usertype').value));
	var path = trim($("path").value);
	if(userid<1){
		js_popup(id);//登录层
	}else if(usertype!=1){
		alert("只有惠客才能进行此操作");
		return ;
	}else{
		alert("请登陆或注册惠付宝帐号。");
    	//location = path+'shopcar/shopcar.jsp?v='+Math.random();
    }
}

//免费注册
function js_mhzc()
{
	var path = trim($("path").value);
	close();
    top.location = path+'hkzc1.jsp';

}

//商品管理
function js_spgl(id)
{
	var id = '4';
	var userid = $("userid").value;
	var usertype = toInt(trim($('usertype').value));
	
	var path = trim($("path").value);
	if(userid<1){
		js_popup(id);//登录层
	}else if(usertype!=2){
		alert("只有惠商才能进行此操作");
		return ;
	}else{
    	location = path+'sys/index.jsp?v='+Math.random();
    }
}

//店铺管理
function js_dpgl(id)
{
	var id = '5';
	var userid = $("userid").value;
	var usertype = toInt(trim($('usertype').value));
	
	var path = trim($("path").value);
	if(userid<1){
		js_popup(id);//登录层
	}else if(usertype!=2){
		alert("只有惠商才能进行此操作");
		return ;
	}else{
    	location = path+'store/storemain.jsp?storeid='+userid;
    }
}

//返回首页
function js_fhsy()
{
	var path = trim($("path").value);
   location = path+'index.jsp?v='+Math.random();
}

//找回帐号
function js_zhzh()
{
	var path = trim($("path").value);
   location = path+'findaccounts.jsp?v='+Math.random();
}

//找回帐号提交信息
function js_zhzh_save()
{
  var password = $('password').value;
  var email = $('email').value;
  var checkcode = $('checkcode').value;

  if (lenb(trim(password))<6)
  {
     alert('请输入用户密码或密码长度过短!');
     $('password').focus();
     return ;
  }
  
  if (lenb(trim(email))<0)
  {
     alert('请输入邮箱地址!');
     $('email').focus();
     return ;
  }
  
  if (!isMail(email))
  {
     alert('邮箱地址的格式不对!');
     $('email').focus();
     return ;
  }
  
  if (lenb(trim(checkcode))!= 4)
  {
    alert("验证码不能为空或长度不对");
    $('checkcode').focus();
    return;
  }
  
  $('t').value = '1';
  if (js_test_mark && js_test_mark()) return ;
  var path = trim($('path').value);
  document.thisForm.target = "ifrm";
  document.thisForm.action = path+"sysctrl?t=1&v="+Math.random();
  document.thisForm.submit();
}

//找回密码
function js_zhmm()
{
	js_findpasswd();
}

//找回密码提交信息
function js_zhmm_save()
{
  var username = $('username').value;
  var email = $('email').value;
  var checkcode = $('checkcode').value;

  if (lenb(trim(username))<1)
  {
     alert('请输入帐号或格式(长度)不对!');
     $('username').focus();
     return ;
  }
  
  if (lenb(trim(email))<0)
  {
     alert('请输入邮箱地址!');
     $('email').focus();
     return ;
  }
  
  if (!isMail(email))
  {
     alert('邮箱地址的格式不对!');
     $('email').focus();
     return ;
  }
  
  if (lenb(trim(checkcode)) != 4)
  {
    alert("验证码不能为空或长度不对");
    $('checkcode').focus();
    return;
  }
  
  //if (js_test_mark && js_test_mark()) return ;
  var path = trim($('path').value);
  document.thisForm.target = "ifrm";
  document.thisForm.action = path+"sysctrl?f=2&t=2&v="+Math.random();
  document.thisForm.submit();
}
