﻿/// <reference path="../../../XIXI.JSDK/XIXIJDK_intellisense.js" />

XIXI.$(document).ready(function()
{
    //帮助栏
    XIXI.$('#helpBarSliver').css('top', 137);
    XIXI.$('#helpBarFrame').css('top', 137);
optSubmit();
    //    if (!(XIXI.$.browser.mozilla || XIXI.$.browser.msie))
    //    {
    //        XIXI.$('#helpBarSliver').css('position', "absolute");
    //        XIXI.$('#helpBarSliver').css('z-index', "8008");
    //        XIXI.$('#helpBarSliver').css('right', "0");
    //        XIXI.$('#helpBarSliver').css('overflow', "hidden");
    //        XIXI.$('#helpBarSliver').css('cursor', "pointer");
    //        XIXI.$('#helpBarSliver').css('width', "22px");

    //        XIXI.$('#helpBarSliver').find(".conent").css("width", "22px");
    //        XIXI.$('#helpBarSliver').find(".conent").css("height", "65px");
    //        XIXI.$('#helpBarSliver').find(".conent").eq(0).find("a").css("width", "20px");
    //        XIXI.$('#helpBarSliver').find(".conent").eq(0).find("a").css("height", "57px");
    //        XIXI.$('#helpBarSliver').find(".conent").eq(0).find("a").css("display", "block");

    //        XIXI.$('#helpBarFrame').css('position', "absolute");
    //        XIXI.$('#helpBarFrame').css('z-index', "8008");
    //        XIXI.$('#helpBarFrame').css('right', "0");
    //        XIXI.$('#helpBarFrame').css('overflow', "hidden");
    //        XIXI.$('#helpBarFrame').css('cursor', "pointer");
    //        XIXI.$('#helpBarFrame').css('width', "22px");
    //    }
})

//添加、删除到产品比对中
function AddCompare(obj,ProductID)
{
    if(obj.checked==true)
    {
        WY.ProductSale.Service.ProductOption.AddProductCompare(ProductID,function(result){
        });
    }
    else
    {
        WY.ProductSale.Service.ProductOption.DeleteProductCompare(ProductID,function(result){
        });
    }
}
//添加、删除到产品比对中
function AddCompare2(flag,ProductID)
{
    if(flag==true)
    {
        WY.ProductSale.Service.ProductOption.AddProductCompare(ProductID,function(result){
        });
    }
    else
    {
        WY.ProductSale.Service.ProductOption.DeleteProductCompare(ProductID,function(result){
        });
    }
}
//绑定比对商品
function BindCompare()
{
    WY.ProductSale.Service.ProductOption.GetCompareList(function(result){
        if(result==null) return;
        else
        {
            var checkedObj = XIXI.$("input[name=input_CompareProduct]");
            checkedObj.each(function(){
                for(j=0;j<result.length;j++)
                {
                    if(this.value==result[j].ProductID)
                    {
                        this.checked=true;
                    }
                }
            });
        }
    });
}
//判断某个产品是否在比对中
function ProductExistCompare(PID)
{
    WY.ProductSale.Service.ProductOption.GetCompareList(function(result){
        if(result==null)
        {
            XIXI.$('#addFavorite').css("display","block");
            return false;
        }    
        else
        {
            for(j=0;j<result.length;j++)
            {
                if(PID==result[j].ProductID)
                {
                    XIXI.$('#addFavorite').css("display","none"); return;
                }    
            }
            return XIXI.$('#addFavorite').css("display","block");
        }
    });
}
//添加产品浏览记录
function AddUserViewMethods(ProductID,Color)
{ 
    WY.ProductSale.Service.ProductOption.AddUserView(ProductID,Color,function(result){
    });
}
//添加到购物车内
function AddShopCart(ProductID)
{
     WY.ProductSale.Service.PrescriptionTService.getProcutStoce(ProductID,function(result){
        if(result)
         { 
             WY.ProductSale.Service.PrescriptionTService.AddToShoppingCart(null, null, ProductID, function(data) {
                  // alert(data);
                location.href = "/usercenter/shopingcart.html";

            });
        }else 
        {
             location.href="/detail-product-"+ProductID+".html";
        }
    });

   
}

$('#naviBox input').add($('#naviBox select')).each(function(i) {
    $(this).attr('disabled', 'disabled');
});

function optSubmit()
{
 $('#optsubmit').click(function() {
    var newEmail = $('input[name*=opt_email]').val();

    if (newEmail == '') {
        $('#opt_result').html($(this).attr("message"));
    } else {
        $.post('/AjaxSubscribe.aspx?subscribeAction=productemail',
							{ newEmail: newEmail },
							function(msg) {
							    $('#opt_result').html(msg);
							}
					);
    }
});
}

function checkScote(productID)
{
//href=\"/product/prescription-{0}.html\"
   
    WY.ProductSale.Service.PrescriptionTService.getProcutStoce(productID,function(result){
        if(result)
         { 
            location.href="/prescription-"+productID+".html";
        }else 
        {
             location.href="/detail-product-"+productID+".html";
        }
    });
}
