﻿// JScript 文件
function SelWholesale()
{
    var TypeCount=document.getElementsByName("TxtWholesale"); 
    
    for(var i=1;i<TypeCount.length;i++)
    {         
        if(TypeCount[i].checked)
        {
            if(TypeCount[i].value=="1")
            {
                DivWholesale.style.display="";
            }
            else
            {
                 DivWholesale.style.display="none";
            }
        }
    }
}


function SelRetailPrice()
{
    if(document.getElementsByName("RetailPriceSet")[2].checked)
    {
       DivRetailPrice.style.display="";
    }
    else
    {
        DivRetailPrice.style.display="none";
    }
}


function SelColor(input_val,img_val)
{
    //WinOpen("../../common/SelColor.aspx?input_val="+input_val+"&img_val="+img_val+"","","380","300");
    WinOpenDialog("../../common/SelColor.aspx?input_val="+input_val+"&img_val="+img_val+"","360","330");
}

function SetShopParam()
{
    var data = XmlHttpPostMethodText("../info/GetColumn.aspx","ColId="+$('ddlColId').value);
    if(data== "")
    {
        return; 
    }  
    else
    {
        var param = data.split('$');
        if(param.length==7)
        {  
            $('txtPageType_'+(param[0]-1)).checked=true; 
            $('txtTemplatePath').value = param[1];
            if(param[6]=="True")
            {
                $('chkBoxIsAllowComment').checked=true;
            }
       } 
    }   
}

//标题类型
function SetTitleType(obj){
    var temp=obj;
    if(temp==1){
        $('rbComm').checked=true;
        ShowImgUrl.style.display="none";
    }
    else if(temp==2){
        $('rbImg').checked=true; 
        ShowImgUrl.style.display=""; 
    }
}

//检测标题
function CheckTitle(TableName)
{
    var title = $("txtTitle").value.trim();
    if(title.length==0) 
    {
          alert('检测的标题必须填写');
          $("txtTitle").focus();
          return;
    } 
     var flag = CheckHas("../common/CheckHas.aspx",title,"Title",TableName)
     if(!flag)
     {
          alert("该标题不存在！"); 
          $("txtTitle").focus();
     }  
     else
     {
         alert("该标题已经存在！"); 
         $("txtTitle").focus();
     }
}

//检测标题
function CheckProductNum(TableName)
{
    var ProductNum = $("txtProductNum").value.trim();
    if(ProductNum.length==0) 
    {
          alert('检测的商品编号必须填写');
          $("txtProductNum").focus();
          return;
    } 
     var flag = CheckHas("../common/CheckHas.aspx",ProductNum,"ProductNum",TableName)
     if(!flag)
     {
          alert("该商品编号不存在"); 
          $("txtProductNum").focus();
     }  
     else
     {
         alert("该商品编号已经存在"); 
         $("txtProductNum").focus();
     }
}

function GetShopModelHtml(ChId,Id)
{
    system_shop_SetShop.GetModelHtmlValue(ChId,Id,CallBack)
}

function GetShopModelHtmlUser(ChId,Id)
{
    user_info_SetShop.GetModelHtmlValue(ChId,Id,CallBack)
}

function BuyCart(RootPath,ChId,Id)
{
    var data = XmlHttpPostMethodText(""+RootPath+"/user/shop/BuyCart.aspx","ChId="+ChId+"&Id="+Id);
    if(data== "")
    {
        return; 
    }  
    else
    {      
        switch(data)
        {
            case "1":
                document.location.href=""+RootPath+"/user/shop/ShoppingCart.aspx";
                return;
                break;
            case "NoSale":
                alert("该商品目前还不支持销售操作");
                return;
                break;
            case "2":
                alert("成功加入购物车");
                return;
                break;
            case "NotLogin":
                alert("请登陆后使用");
                return;
                break;
            case "NoStorageNum":
                alert("该商品库存数量不足，不能够购买");
                return;
                break;
            case "NoUserShop":
                alert("你购物车中已经有另一人商品\n\n请下订单/取消购物车中商品后才能购买该商品")
                return;
                break;
            default:
                document.location.href=data;
                return;
                break;
        }
    }
}

function PaymentUserLogin()
{    
    if($("UserLogin1").checked)
    {
        $("Div_UserLogin2").style.display="none";
        $("Div_UserLogin1").style.display="";
    }
    else
    {
        $("Div_UserLogin2").style.display="";
        $("Div_UserLogin1").style.display="none";
    }
}