function switchcss(obj)
{
    if(obj.className!='tag-selected')
    {
        if(obj.className!='tag-hightlight')
            obj.className = 'tag-hightlight';
        else
            obj.className = '';
    }
    
}
function changesta(obj,obj1)
{
    $("l1").className = '';
    $("l2").className = '';
    obj.className = "tag-selected";
    
    $("info1").style.display = 'none';
    $("info2").style.display = 'none';
    obj1.style.display = 'block';
}
function addcart(productid,cicun,color,counts,remark,tuap)
{
    //alert("敬爱的客户，您好，我们将于2月5日下午开始暂停一切业务，\r\n进入库存盘点期，盘点时间为一天左右，盘点完毕后，我们将会重新开启库存销售通道，\r\n感谢大家一直以来对我们的支持和关怀！值此新春佳节到来之际，云e坊全体员工祝各位春节快乐，身体健康、财源广进");
    //return;
    try
    {
        if(parseInt(counts)<=0)
        {
            alert("数量必须大于0");
            return;
        }
        //alert(1111);
        //alert(color.indexOf("[已下架]"))
        if(color!=null && color.indexOf("[已下架]")!=-1)
        {
            alert("该颜色已经下架。无法下单");
            return;
        }
        //if(confirm("您选择的尺寸是："+cicun+"，颜色是："+color+"，对吗？注意：发货以此数据为准！"))
        {
            //alert(11112);
            var strpam = 'pid='+productid+'&cicun='+cicun+'&color='+color+'&counts='+counts+'&remark='+remark+'&'+Math.random();
            //document.write('/js_s/addcart.aspx?'+strpam);
            //return;
            new Ajax.Request('/js_s/addcart.aspx', {method:'post', parameters:strpam, onComplete:fbk});
        }
    }
    catch(ex)
    {
        alert(ex.message);
    }
}
function cbjakk() {
    alert(111111);
}
function fbk(obj)
{
    if (obj.responseText == "ok") {       
        if(confirm("产品成功添加至购物车！！！\r\n\r\n\r\n点击“确定”进入购物车结帐，继续停留本页面购物，请点“取消”"))
        {
            window.location = '/user/mycart.aspx';
        }
    }
    else if(obj.responseText.indexOf("notlogin")!=-1)
    {
        var id = obj.responseText.replace("notlogin","");
        alert("您尚未登录，无法下订单，请先登录或者注册之后再下订单");
        window.location = '/login.aspx?ReturnUrl=/product_'+id+'.shtml';
    }
    else if(obj.responseText.indexOf("false")!=-1)
    {
        //alert(obj.responseText);
        alert("非常抱歉，该颜色尺码的产品库存小于您的订购数。");
    }
    else if(obj.responseText.indexOf("order")!=-1)//order
    {  
        var myorderid = obj.responseText.replace("order","");         
        
        if(confirm("产品成功添加至已有订单！！！\r\n\r\n\r\n点击“确定”查看已有订单状况，如需继续停留本页面购物，请点“取消”"))
        {
            window.location='/user/pay.aspx?id='+myorderid;
        }
    }
}
function delete_confirm(e)
{
	if(event.srcElement.outerText=="删除")
			event.returnValue=confirm("被删除记录将不可恢复，确定删除?");
}
document.onclick=delete_confirm;

function check()
{
    if(confirm("确定清空购物车？"))
    {
        return true;
    }
    return false;
}
function addfav(favid)
{
    new Ajax.Request('/js_s/addfav.aspx', {method:'post', parameters:'id='+favid+'&'+Math.random(), onComplete:fbk1});
}
function fbk1(obj)
{
    if(obj.responseText=="ok")
    {
        //window.location = '/user/';
        alert("收藏成功，您可以在用户管理中心查看到本产品");
    }
    else if(obj.responseText.indexOf("notlogin")!=-1)
    {
        if(confirm("您尚未登录，只有本站登录用户才可以收藏产品，您要登录吗？"))
        {
            window.location='/login.aspx?ReturnUrl='+obj.responseText.replace("notlogin","");
        }
    }
}
function iniprovince(obja)
{
    if(obja==null)
    {
        return;
    }
    var region = '云南,浙江,新疆,西藏,重庆,天津,四川,陕西,山东,山西,广东,上海,青海,宁夏,内蒙古,辽宁,江西,江苏,吉林,湖南,湖北,黑龙江,河南,河北,海南,贵州,广西,甘肃,福建,北京,安徽,其他'.split(',');

    for(var n=0;n<region.length;n++)
    {
        var varItem = new Option(region[n], region[n]);      
        obja.options.add(varItem); 
    }    
}
//计算运费
function calfei(prov,counts,type)
{   /*
    var zljsj = 1.0;//运费计算方式 冬装1.2 ,春装按0.30算，运费的另外一个计算地方是 productDo.cs    
    counts = (counts-parseInt(1/zljsj)) * zljsj;*/
    var emscount = counts;
    var yto13nei = 0;
    if(counts<=1.3)//圆通1.3以内算10元
    {
        yto13nei = 1;
    }
    if (counts > 0) {
        counts = counts - 1;
    }
    var xiaoshudian = counts-parseInt(counts);
    if(xiaoshudian>0.5)
    {
        counts = parseInt(counts)+1;
    }
    else if(xiaoshudian>0)
    {
        counts = parseInt(counts)+0.5;
    }
    else
    {}
    
    //if(counts>parseInt(counts))
    //{
    //    counts = parseInt(counts)+1;
    //}    
    //else if (counts==parseInt(counts))
    //{
       //alert("无小数"); 
    //}
    if(counts<0)
    {
        counts = 0;
    }
    //alert(counts);
    if(type=="ems")
       return emsCal(prov,counts);
    else if (type=="yto")
       return ytoCal(prov,counts,yto13nei);
    else if (type=="e+e")
    {
       if(emscount<=0.5)
       {
            emscount = 0;
       }
       else
       {
            emscount=emscount-0.5;
            
            var newxiaoshudian = emscount-parseInt(emscount);
            if(newxiaoshudian>0.5)
            {
                emscount = parseInt(emscount)+1;
            }
            else if(newxiaoshudian>0)
            {
                emscount = parseInt(emscount)+0.5;
            }
       }
       
       return eeeCal(prov,emscount);
    }
    else if (type=="sto")
       return stoCal(prov,counts);
    else if (type=="ano")
       return anoCal(prov,counts);
    else if(type=="zto")
       return ztoCal(prov,counts);
  else if(type=="sfexpress")
   return sfexpressp(prov,counts);
       
       //sfexpress
       
    else if(type=="self")//自提或者到付
    {
        return 0;
    }
}
//其它
function anoCal(pro,Cou)
{
    var topfeifu=0;
    var str53 = "江苏，浙江，上海";
    //var str1513 = '新疆，西藏';
    if(str53.indexOf(pro)!=-1)
    {
        topfeifu = 10+(Cou)*6;
    }
    /*
    else if(str1513.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*13;
    }
     else if(pro.indexOf("其他")!=-1)
    {
        topfeifu = 15+(Cou)*13;
    }*/
    else
    {
        topfeifu = 20+(Cou)*10;
    }
    //alert(topfeifu);
    return topfeifu;
}
//顺丰快递
function sfexpressp(pro,Cou)
{
    var topfeifu=0;
    var str53 = "江苏，浙江，上海";
    //var str1513 = '新疆，西藏';
    if(str53.indexOf(pro)!=-1)
    {
        topfeifu = 10+(Cou)*6;
    }
    /*
    else if(str1513.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*13;
    }
     else if(pro.indexOf("其他")!=-1)
    {
        topfeifu = 15+(Cou)*13;
    }*/
    else
    {
        topfeifu = 20+(Cou)*10;
    }
    //alert(topfeifu);
    return topfeifu;
}

//申通
function stoCal(pro,Cou)
{
    var topfeifu=0;
    var str53 = "江苏，浙江，上海";
    var str1513 = '新疆，西藏，青海，宁夏，内蒙古，甘肃';
    if(str53.indexOf(pro)!=-1)
    {
        if(Cou> parseInt(Cou))
        {
            Cou = parseInt(Cou)+1;
        }
        topfeifu = 5+(Cou)*1;
    }    
    else if(str1513.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*15;
    }
     else if(pro.indexOf("其他")!=-1)
    {
        topfeifu = 15+(Cou)*15;
    }
    else
    {
        topfeifu = 10+(Cou)*10;
    }
    //alert(topfeifu);
    return topfeifu;
}
//中通快递
function ztoCal(pro,Cou)
{
    var topfeifu=0;
    var str53 = "江苏，浙江，上海";
    var str1513 = '新疆，西藏，青海，宁夏，内蒙古，甘肃';
    if(str53.indexOf(pro)!=-1)
    {
        if(Cou> parseInt(Cou))
        {
            Cou = parseInt(Cou)+1;
        }
        topfeifu = 5+(Cou)*2;
    }
    else if(str1513.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*10;
    }
    else
    {      
        topfeifu = 10+(Cou)*10;
    }
    //alert(topfeifu);
    return topfeifu;
}
//圆通
function ytoCal(pro,Cou,yto13nei)
{
    var topfeifu=0;
    /*
    var str53 = "江苏，浙江，上海";
    var str1513 = '新疆，西藏';*/
    var str53 = "江苏，浙江，上海";
    var str107 = "北京，天津，河北，山东，河南，湖北，湖南，福建，广东，江西，安徽，海南";
    var str108 = "山西，陕西，重庆，云南，黑龙江";
    var str1110 = "广西，四川，辽宁，吉林，贵州，内蒙古";
    var str1515 = "新疆，西藏，青海，宁夏，甘肃";
    /*
     江浙沪区（一区） 江苏省、浙江省、上海市 5 1元/1KG 
     二区 北京，天津，河北，山东，河南，湖北，湖南，福建，广东，江西，安徽，海南 10 7元/公斤 
     三区 山西，陕西，重庆，云南，贵州，黑龙江 10 8元/1KG 
     四区 广西，四川，辽宁，吉林，甘肃，青海，内蒙古 11 10元/1KG 
     五区 新疆、西藏 15 15元/1KG 
     */
    if (str53.indexOf(pro) != -1)
    {
        if(Cou> parseInt(Cou))
        {
            Cou = parseInt(Cou)+1;
        }
        Cou = Cou-3;//3kg不收续重费
        if(Cou<=0)
        {
            Cou=0;
        }
        topfeifu = 5+(Cou)*1;
    }
    else if (str1515.indexOf(pro) != -1)
    {
        topfeifu = 15+(Cou)*15;
    }
    else
    {
          topfeifu = 9 + (Cou) * 9;
//        if(yto13nei==1)
//        {
//            topfeifu = 10;
//        }
//        else
//        {
//            topfeifu = 10 + (Cou) * 10;
//        }
    }
    /*
    else if (str108.indexOf(pro) != -1)
    {
        topfeifu = 10 + (Cou) * 10;
    }
    else if (str1110.indexOf(pro) != -1)
    {
        topfeifu = 10 + (Cou) * 10;
    }
    
    else if (str1515.indexOf(pro) != -1)
    {
        topfeifu = 15+(Cou)*15;
    }
    else if (pro.indexOf("其他") != -1)
    {
        topfeifu = 15 + (Cou) * 15;
    }*/
   
    //alert(topfeifu);
    return topfeifu;
}
//EMS e邮宝
function emsCal(pro,Cou)
{
    if(Cou> parseInt(Cou))//凑整
    {
        Cou = parseInt(Cou)+1;
    }
    var topfeifu;
    var str84 = "北京，天津，广东，山东，湖北，湖南，福建，江西，安徽";
    var str104 = "河北，山西，河南，陕西";
    var str126 = "辽宁，吉林，黑龙江，四川，重庆，广西，海南";
    var str156 = "内蒙古，宁夏，甘肃，青海，贵州，云南";
    var str1510 = '新疆，西藏';
    if(str84.indexOf(pro)!=-1)
    {
        topfeifu = 8+(Cou)*4;
    }
    else if(str104.indexOf(pro)!=-1)
    {
        topfeifu = 10+(Cou)*4;
    }
    else if(str126.indexOf(pro)!=-1)
    {
        topfeifu = 12+(Cou)*6;
    }
    else if(str156.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*6;
    }
    else if(str1510.indexOf(pro)!=-1)
    {
        topfeifu = 15+(Cou)*10;
    }
    else if(pro=="浙江"||pro=="江苏"||pro=="上海")
    {
        topfeifu = 5+(Cou)*2;
    }
    else if(pro.indexOf("其他")!=-1)
    {
        topfeifu = 15+(Cou)*10;
    }
    else
    {
        topfeifu = 15+(Cou)*10;
    }
    return topfeifu;
}

//EMS e+e
function eeeCal(pro,Cou)
{   
//alert("eee进来")
//    if(Cou> parseInt(Cou))//凑整
//    {
//        Cou = parseInt(Cou)+1;
//    }
    //alert(Cou)
   var str84 = "北京，天津，广东，山东，湖北，湖南，福建，江西，安徽";
    var str104 = "河北，山西，河南，陕西";
    var str126 = "辽宁，吉林，黑龙江，四川，重庆，广西，海南";
    var str156 = "内蒙古，宁夏，甘肃，青海，贵州，云南";
    var str1510 = '新疆，西藏';
    
    if(str84.indexOf(pro)!=-1)
    {
        topfeifu = 12+(Cou)*8;
    }
    else if(str104.indexOf(pro)!=-1)
    {
        topfeifu = 12+(Cou)*8;
    }
    else if(str126.indexOf(pro)!=-1)
    {
        topfeifu = 14+(Cou)*14;
    }
    else if(str156.indexOf(pro)!=-1)
    {
        topfeifu = 14+(Cou)*16;
    }    
    else if(str1510.indexOf(pro)!=-1)
    {
        topfeifu = 20+(Cou)*30;
    }   
    else if(pro=="浙江"||pro=="江苏"||pro=="上海")
    {
        topfeifu = 8+(Cou)*4;
    }
    else if(pro.indexOf("其他")!=-1)
    {
        topfeifu = 20+(Cou)*20;
    }
    else
    {
        topfeifu = 20+(Cou)*20;
    }
    return topfeifu;
}

function selectit(obja,province)
{
    if(obja==null)
    {
        return;
    }
    var blog = false;
	for(var b=0;b<obja.length;b++)
	{
	    if(obja.options[b].text.indexOf(province)!=-1)
	    {
	        obja.options[b].selected = true;
	        blog = true;
	        break;
	    }
	}
	if(!blog)
	{
	    selectit(obja,"其他");
	}
}
function selectvalue(obja,province)
{
    if(obja==null)
    {
        return;
    }
	for(var b=0;b<obja.length;b++)
	{
	    if(obja.options[b].value.indexOf(province)!=-1)
	    {
	        obja.options[b].selected = true;
	        break;
	    }
	}
}
function SelectAll1 (objFrm)
{
    //alert(objFrm.elements.length);
    for (var i = 0; i < objFrm.elements.length; i++){
        if (objFrm.elements[i].name == "chbELE")
            objFrm.elements[i].checked = objFrm.chkAll.checked ;       
    }
}

function SelectAll2 (objFrm)
{
    //alert(objFrm.elements.length);
    for (var i = 0; i < objFrm.elements.length; i++){
        if (objFrm.elements[i].name == "chbELE1")
            objFrm.elements[i].checked = objFrm.chkAll1.checked ;       
    }
}

function checkformsele(objFrm)
{
/*
     var flag = false;
    for (var i = 0; i < objFrm.elements.length; i++){
        var ele = objFrm.elements[i];
        if (ele.name == "chbELE" && ele.checked == true){
            flag = true;
            break;
        }
    } 
    if (!flag){
        alert("请选择需要制作的产品!");
        return false;
    }*/
    return true;
}

function swshowhtml()
{
    document.getElementById("l1v").className = "";
    document.getElementById("l2v").className = "tag-selected";   
    if(document.getElementById("showcineten").innerHTML.indexOf("src=\"/uploadpic/")!=-1)
    {
        document.getElementById("showcineten").innerHTML = document.getElementById("showcineten").innerHTML.replace(new RegExp("src=\"/uploadpic/", 'g'),"src=\"http://www.gaolou.net/uploadpic/");
    }    
    document.getElementById("showcineten").innerHTML = document.getElementById("showcineten").innerHTML.replace(new RegExp("src=\"http://www.yef88.com/uploadpic/", 'g'),"src=\"http://www.gaolou.net/uploadpic/");
    //alert(document.getElementById("showcineten").innerHTML);
}
function swshowhtmlback()
{
    document.getElementById("l1v").className = "tag-selected";
    document.getElementById("l2v").className = "";   
    document.getElementById("showcineten").innerHTML = document.getElementById("showcineten").innerHTML.replace(new RegExp("src=\"http://www.gaolou.net/uploadpic/", 'g'),"src=\"http://www.yef88.com/uploadpic/");
    //alert(document.getElementById("showcineten").innerHTML);
}