﻿ $(function (){
    $(".allsort .item").hoverForIE6({delay: 150});
    
    $('.pro_img03 img ').each(function() {
        $(this).LoadImage({width: 130,height: 130})
    });
    
    $('.pro_img01 img ').each(function() {
        $(this).LoadImage({width: 120,height: 120})
    });
    
    $('.pinpai_span01 img ').each(function() {
        $(this).LoadImage({width: 159,height: 107})
    });
    $('.md_img01 img ').each(function() {
        $(this).LoadImage({width: 230,height: 230})
    });

        
    $('.product_01a img ').each(function() {
        $(this).LoadImage({width: 320,height: 320})
    });
    
    
    $(".allsort .item").hoverForIE6({delay: 150});
   
   /*ranking*/
    $($(".paihang_02").get(0)).show().siblings(".paihang_02").hide();
    
    $($(".paihang_01 >ul >li ").get(0)).removeClass("normal").addClass("active").siblings("li").removeClass("active").addClass("normal"); 
    
    $(".paihang_01 >ul >li ").bind("mouseover",function() {
        $(this).removeClass("normal").addClass("active").siblings("li").removeClass("active").addClass("normal");
        $($(".paihang_02").get($(".paihang_01 >ul >li").index($(this)))).show().siblings(".paihang_02").hide()
    });
    
    
    $(".paihang_02 li").bind("mouseover",function(){
        $(".paihang_02 li").removeClass("hover");
        $(this).addClass("hover");
    })
    /*endranking*/
    
    /*cart*/
    var flag = true;
    $(".fore1").bind("mouseover",function() {
        if (flag) {
            $("#o-mycart-list").fadeIn();
        } else {
            if (flag) {
                flag = false;
                $("#o-mycart-list").fadeIn();
            } else {
                return;
            }
        }
    });
    
    $("#o-mycart-list").bind("mouseover",function() {
        if (flag) {
            $("#o-mycart-list").fadeIn();
        } else {
            if (flag) {
                flag = false;
                $("#o-mycart-list").fadeIn();
            } else {
                return;
            }
        }
    }).bind("mouseleave",function() {
        $("#o-mycart-list").fadeOut();
    });
    /*endcart*/
})
function tagmove(obj){obj.className="class_title1"}
function tagout(obj){obj.className="class_title"}

function Province(addressID,provinceId)
{
    $.ajax({
        type: "POST",
        url: "Ajax/getProvincesOrCity.ashx",
        cache:false,
        data: {
            addressID:addressID,
            provinceId:provinceId
        },
        dataType: "html",
        beforeSend: function(XMLHttpRequest){
        },
        success: function(data, textStatus) {
           $("#spanCity").html(data);
           Citys($("#City").val());
        },
        complete: function(XMLHttpRequest, textStatus) {
       
        },error: function() {}
    });
}

function Citys(id)
{
    $.ajax({
        type: "POST",
        url: "Ajax/getBorough.ashx",
        cache:false,
        data: {
            id:id
        },
        dataType: "html",
        beforeSend: function(XMLHttpRequest) {
        },
        success: function(data, textStatus) {
           $("#spanCity2").html(data);
            
        },
        complete: function(XMLHttpRequest, textStatus) {
       
        },error: function() {}
    });
}

function Province1(addressID,provinceId,BoroughId)
{
    $.ajax({
        type: "POST",
        url: "Ajax/getProvincesOrCity.ashx",
        cache:false,
        data: {
            addressID:addressID,
            provinceId:provinceId
        },
        dataType: "html",
        beforeSend: function(XMLHttpRequest){
        },
        success: function(data, textStatus) {
           $("#spanCity").html(data);
           Citys1($("#City").val(),BoroughId);
        },
        complete: function(XMLHttpRequest, textStatus) {
       
        },error: function() {}
    });
}

function Citys1(id,selectId)
{
    $.ajax({
        type: "POST",
        url: "Ajax/getBorough.ashx",
        cache:false,
        data: {
            id:id,
            selectId:selectId
        },
        dataType: "html",
        beforeSend: function(XMLHttpRequest) {
        },
        success: function(data, textStatus) {
           $("#spanCity2").html(data);
        },
        complete: function(XMLHttpRequest, textStatus) {
       
        },error: function() {}
    });
}

function favorites(id)
{
    $.ajax({type: "POST",
        url: "Ajax/favorites.ashx",
        cache:false,
        data: {id:id},
        dataType: "html",
        success: function(data, textStatus) {
           alert(data);
        }
       
    });
}
function recalc() {
    $("[id^=total_item_]").calc("qty * price", {
        qty: $("input[id^=qty_item_]"),
        price: $("[id^=price_item_]")
    },
    function(s) {
        return s.toFixed(2);
    },
    function($this) {
        var sum = $this.sum();
         $("#total_item").text(sum.toFixed(2));
        $("#grand_total").text(sum.toFixed(2)+"(不含运费)");
    });
}
	
