function intervalCheckLogin(){var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.lastIndexOf("#"));if(url.indexOf("/user/login.aspx?ReturnUrl=")!=-1||url.indexOf("/user/reg.aspx?ReturnUrl=")!=-1||url.indexOf("/user/login.htm?ReturnUrl=")!=-1||url.indexOf("/user/reg.htm?ReturnUrl=")!=-1){var str1=(base64de(url.substring(url.indexOf("?ReturnUrl=")+11)));if(str1!=""){url=str1;}}ajax("get","/user/ajax.aspx?type=interval_check_login&rd="+Math.random(),"",function OnHandler(){if(xmlHttp.readyState == 4){if(xmlHttp.responseText=='ok')window.location=url;}});}


function MallAddCart(type,id){

function fun1(results){

if(results=="nologin"){
TINY.box.show("<div class=\"msgok\" style=\"background-position: 0px 4px;*background-position:0px 2px;\">请您先登录后再购物，<a href=\"/user/login.htm\" target=\"_blank\" style=\"color:#f30\">[立即登录]</a></div>",0,300,23,0,5);return;  
}

if(results=="err"){
TINY.box.show("<div class=\"msgok\" style=\"background-position: 0px 4px;*background-position:0px 2px;\">购物失败！</div>",0,300,23,0,3);return;  
}

if(results=="lock"){
TINY.box.show("<div class=\"msgok\" style=\"background-position: 0px 4px;*background-position:0px 2px;\">商品未审核，不能购买！</div>",0,300,23,0,3);return;  
}

if(type==0&&results=="has"){
TINY.box.show("<div class=\"msgok\" style=\"background-position: 0px 4px;*background-position:0px 2px;\">购物车已经有了这个宝贝！<a href=\"/mall/cart.aspx\" target=\"_blank\" style=\"color:#f30\">[查看购物车]</a></div>",0,300,23,0,5);return;  
}

if(type==1)window.location="cart.aspx";
else{
document.getElementById("view_cart_added").innerHTML=results;
document.getElementById("view_cart_added").className="view_cart_added";
}

}

ajax("post","view_cart_added.aspx?act=ajax&type="+type+"&rd="+Math.random(),"id="+id,function OnHandler(){if(xmlHttp.readyState == 4){fun1(xmlHttp.responseText);}});

}


function mall_list_search(){
var obj=document.getElementById("mall_k");var k=obj.value;
var price1=document.getElementById("mall_p1");var k1=price1.value;
var price2=document.getElementById("mall_p2");var k2=price2.value;
var regNum =/[^\d]/;
if(regNum.test(k1)){alert("请输入整数价格！");return false;}
if(regNum.test(k2)){alert("请输入整数价格！");return false;}
    
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.lastIndexOf("#"));

    if(true)    
    {
        if(location.href.indexOf("mall_k=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="mall_k"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            url=url.replace("mall_k="+p2,"mall_k="+escape(k));
        }
        else {
            if(url.indexOf("?")==-1)url+="?mall_k="+escape(k);
            else url+="&mall_k="+escape(k);
        }        
    }
     if(true)    
    {
        if(location.href.indexOf("mall_p1=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="mall_p1"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            url=url.replace("mall_p1="+p2,"mall_p1="+escape(k1));
        }
        else {
            if(url.indexOf("?")==-1)url+="?mall_p1="+escape(k1);
            else url+="&mall_p1="+escape(k1);
        }        
    }
      if(true)    
    {
        if(location.href.indexOf("mall_p2=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="mall_p2"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            url=url.replace("mall_p2="+p2,"mall_p2="+escape(k2));
        }
        else {
            if(url.indexOf("?")==-1)url+="?mall_p2="+escape(k2);
            else url+="&mall_p2="+escape(k2);
        }        
    }
window.location=url;

}

function mall_search(){
var obj=document.getElementById("mall_wordkey");var k=obj.value;
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.lastIndexOf("#"));

    if(location.href.indexOf("/mall/list.aspx")==-1)
    {
        url="/mall/list.aspx?mall_wordkey="+escape(k);
    }
    else
    {
        if(location.href.indexOf("mall_wordkey=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="mall_wordkey"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            url=url.replace("mall_wordkey="+p2,"mall_wordkey="+escape(k));
        }
        else {
            if(url.indexOf("?")==-1)url+="?mall_wordkey="+escape(k);
            else url+="&mall_wordkey="+escape(k);
        }        
    }
window.location=url;
}


function mall_list_orderby(F)
{
var S="";
if(F=="time"){
if(document.getElementById("sort_time").className=="sort_time1")S="t2";
else if(document.getElementById("sort_time").className=="sort_time2")S="t1";
else if(document.getElementById("sort_time").className=="sort_time3")S="t1";
}
else if(F=="price"){
if(document.getElementById("sort_price").className=="sort_price1")S="p2";
else if(document.getElementById("sort_price").className=="sort_price2")S="p1";
else if(document.getElementById("sort_price").className=="sort_price3")S="p1";
}
if(S=="")return;
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.lastIndexOf("#"));
    if(true)    
    {
        if(location.href.indexOf("mall_orderby=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="mall_orderby"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            url=url.replace("mall_orderby="+p2,"mall_orderby="+escape(S));
        }
        else {
            if(url.indexOf("?")==-1)url+="?mall_orderby="+escape(S);
            else url+="&mall_orderby="+escape(S);
        }        
    }
window.location=url;
}

function mall_list_viewtype(){
var S="1";
var url=location.href;if(url.indexOf("#")!=-1)url=url.substring(0,url.lastIndexOf("#"));
    if(true)    
    {
        if(location.href.indexOf("viewtype=")!=-1){
            var arr1 = location.search.substr(1).split("&");var p1="";p2="";for(i=0;i<arr1.length;i++){if([arr1[i].split("=")[0]].toString()=="viewtype"){p1=arr1[i].split("=")[0];p2=arr1[i].split("=")[1];}}
            if(p2=="1")S="0";else S="1"; url=url.replace("viewtype="+p2,"viewtype="+escape(S));
        }
        else {
            if(url.indexOf("?")==-1)url+="?viewtype="+escape(S);
            else url+="&viewtype="+escape(S);
        }        
    }
window.location=url;
}

function mall_search_keydown(e)
{
var theEvent=window.event||e;var keyNum=theEvent.keyCode||theEvent.which;
if(keyNum==13)mall_search();
}