﻿
// 获取浏览器版本
//if ( $.browser.msie )
// if ($.browser.version == '6.0') {
//    var objIEVersion = $('#IEVersionMessage');
//    var showContent = "您的IE浏览器版本较低，建议升级到<b>IE7.0</b>或以上版本。";
//    showContent += "<span style=\"color: Red; cursor: pointer; font-weight: bold;\" onclick=\"javascript:$('#IEVersionMessage').hide();\">[X]</span>";
//    objIEVersion.html(showContent);
//    objIEVersion.show();
//    objIEVersion.css("filter","alpha(opacity=75,style=1)");
//    objIEVersion.css("opacity","0.75");
//    setTimeout("hideIEVersionMessage()",20000);
// };

spcialShow();

setTimeout("specailHide()",10000)

function spcialShow(){
    $('#SpecialShow').slideDown(2000);
}
function specailHide(){
    $('#SpecialShow').slideUp(2000);
}
function hideIEVersionMessage() {
     $('#IEVersionMessage').hide();
}
 
 // 获取商品分类及品牌信息
 function getCategoryBrands(myflag){
    var objIndexCategories = $('.goodscate');
    var objIndexBrands = $('.goodsbrand');
    $.get("/Product/Handler/GetIndexShowCategories.ashx",{flag:myflag},function(data){
        if ('' != data) {
            var className = '';
            if ('0' == myflag) {   
                objIndexCategories.html(data);
                className = 'goodscate';
            } else {
                objIndexBrands.html(data);
                className = 'goodsbrand';
            } 
           
           $("." + className + " h3>a").each(function(){              
               $(this).bind("mouseover",function(){
                   $(this).css({background:"url(/SiteCommon/Images/h3_bg.gif) no-repeat","text-decoration":"none"});
                   $(this).next(".subnav").show(); 
               });             
               $(this).bind("mouseleave",function(){
                   $(this).css({background:""});
                   $(this).next(".subnav").hide(); 
               });
               $(this).next(".subnav").bind("mouseover",function(){
                   $(this).show();
                   $(this).prev("a").css({background:"url(/SiteCommon/Images/h3_bg.gif) no-repeat","text-decoration":"none"});
               });
               $(this).next(".subnav").bind("mouseleave",function(){
                   $(this).hide();
                   $(this).prev("a").css({background:""});
               });
           });
        }
    });
 }

// 加载首页Tab促销商品
function getTabPromotionProducts(){
    $.get("/Product/Handler/GetIndexTabProducts.ashx",function(data){
        if ('' != data) {
           
             $('#Tab01').html(data.split("{")[0]);
             $('#Tab02').html(data.split("{")[1]);
             $('#Tab03').html(data.split("{")[2]);
             $('#Tab04').html(data.split("{")[3]);
             $('#Tab02').hide();
             $('#Tab03').hide();
             $('#Tab04').hide();
        }
    });
}

// 加载首页分类促销商品
function getCategoryPromotionProducts(){
    $.get("/Product/Handler/GetIndexCategoriesPromotion.ashx",function(data){
        if ('' != data) {
             $('#botcontent').html(data.split("{")[0]);
             $('#botcontent2').html(data.split("{")[1]);
             $('#Div11').html(data.split("{")[2]);
             $('#Div12').html(data.split("{")[3]);
             $('#Div21').html(data.split("{")[4]);
             $('#Div22').html(data.split("{")[5]);
             $('#Div31').html(data.split("{")[6]);
             $('#Div32').html(data.split("{")[7]);
                          
             $('#botcontent2>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#botcontent2>ul .acitve').next().removeClass('acitve');
                 $('#botcontent2').hide();
                 $('#botcontent').show();
             })   
            $('#botcontent2>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#botcontent>ul .acitve').removeClass('acitve');
                $('#botcontent').hide();
                $('#botcontent2').show();
            })
             $('#botcontent>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#botcontent>ul .acitve').next().removeClass('acitve');
                 $('#botcontent2').hide();
                 $('#botcontent').show();
             })
             $('#botcontent>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#botcontent2>ul .acitve').removeClass('acitve');
                $('#botcontent').hide();
                $('#botcontent2').show();
            }) 
            /*div11~div12*/
            $('#Div12>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div11>ul .acitve').next().removeClass('acitve');
                 $('#Div112').hide();
                 $('#Div11').show();
            })   
           $('#Div12>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div11>ul .acitve').removeClass('acitve');
                $('#Div11').hide();
                $('#Div12').show();
           })
           $('#Div11>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div11>ul .acitve').next().removeClass('acitve');
                 $('#Div12').hide();
                 $('#Div11').show();
            })
            $('#Div11>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div12>ul .acitve').removeClass('acitve');
                $('#Div11').hide();
                $('#Div12').show();
           })
           /*div21-div22*/
           $('#Div22>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div21>ul .acitve').next().removeClass('acitve');
                 $('#Div22').hide();
                 $('#Div21').show();
           })   
          $('#Div22>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div21>ul .acitve').removeClass('acitve');
                $('#Div21').hide();
                $('#Div22').show();
          })
          $('#Div21>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div21>ul .acitve').next().removeClass('acitve');
                 $('#Div22').hide();
                 $('#Div21').show();
           })
           $('#Div21>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div22>ul .acitve').removeClass('acitve');
                $('#Div21').hide();
                $('#Div22').show();
          })
          /*div21-div22*/
           $('#Div32>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div31>ul .acitve').next().removeClass('acitve');
                 $('#Div32').hide();
                 $('#Div31').show();
           })   
          $('#Div32>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div31>ul .acitve').removeClass('acitve');
                $('#Div31').hide();
                $('#Div32').show();
          })
          $('#Div31>ul .acitve').bind("mouseover",function(){
                 $(this).addClass('acitve');
                 $('#Div31>ul .acitve').next().removeClass('acitve');
                 $('#Div32').hide();
                 $('#Div31').show();
           })
           $('#Div31>ul .acitve').next().bind("mouseover",function(){
                $(this).addClass('acitve');
                $('#Div32>ul .acitve').removeClass('acitve');
                $('#Div31').hide();
                $('#Div32').show();
          })
        }
    });
}

function hidePopup(){
    $('#BackgroundPopup').hide();
    $('.tipspopup').hide()
}

function getFriendlyTips(){
 $.get("/FriendlyTips/Handler/GetFriendlyTips.ashx",function(data){
        if ('' != data) {
            if(data.split('{')[0] != '')
                $('#BabyPhoto').attr("src",data.split('{')[0]);
            $('#PersonalInfo').html(data.split('{')[1]);
            $('#WeatherInfo').html(data.split('{')[2]);
            $('#HolidayInfo').html(data.split('{')[3]);
            $('#BabyInfo').html(data.split('{')[4]);
            $('#SeasonGreeting').html(data.split('{')[5]);
            $('.milk').html(data.split('{')[7]);
            $('#Milk01').attr("href",data.split('{')[8]);
            $('#Milk02').attr("href",data.split('{')[6]);
            
            $('.diaper').html(data.split('{')[10]);
            $('#Diaper01').attr("href",data.split('{')[11]);
            $('#Diaper02').attr("href",data.split('{')[9]);
            
            $('.flyheart').html(data.split('{')[13]);
            $('#Flyheart01').attr("href",data.split('{')[14]);
            $('#Flyheart02').attr("href",data.split('{')[12]);
        }
  });
}

function showPopup(){
    var objPopup = $('.tipspopup');
    var objBackPopup = $('#BackgroundPopup');
    var visibleWinWidth = document.documentElement.clientWidth;
    var visibleWinHeight = document.documentElement.clientHeight;
    var fullWinWidth = document.body.scrollWidth;
    var fullWinHeight = document.body.scrollHeight;

    objBackPopup.css({"z-index":"2","font-weight":"normal","padding-top":"10px","text-align":"center",position: "absolute"});
    objBackPopup.css({left:"0px",top:"0px",background:"#f6f6f6",width:fullWinWidth,height:fullWinHeight});
    objBackPopup.css("filter","alpha(opacity=85,style=1)");
    objBackPopup.css("opacity","0.85");
    objPopup.css("z-index","3");
    objPopup.css({left:visibleWinWidth/2-454,top:visibleWinHeight/2-155});
    objBackPopup.show();
    objPopup.show();
    
    window.onresize = function() {
        var visibleWinWidth = document.documentElement.clientWidth;
        var visibleWinHeight = document.documentElement.clientHeight;
        objBackPopup.css({width:fullWinWidth,height:fullWinHeight});
        objPopup.css({left:visibleWinWidth/2-454,top:visibleWinHeight/2-155});
    }
}

// 页面加载事件方法
$(document).ready(function(){
    $('.tipspopup').hide();
    getCategoryBrands('0');
    getCategoryBrands('1');
    
    // 显示分页促销商品
    getTabPromotionProducts();
    
    // 显示分类促销商品
    getCategoryPromotionProducts();
    
    // 获取温馨提示信息
    getFriendlyTips();
    
    $('#botcontent2').hide();
    $('#Div12').hide();
    $('#Div22').hide();
    $('#Div32').hide();

    $('#ProductBrands').hide();
    
    $('#CategoriesList').mouseover(function(){
       $('#CategoriesList').addClass("goods now");
       $('#BrandList').removeClass("goods now");
       $('.catatitle').css("background","url(/SiteCommon/Images/categories.gif) no-repeat");
       $('#ProductBrands').hide();
       $('#ProductCategories').show();
    });
    
    $('#BrandList').mouseover(function(){
       $('#CategoriesList').removeClass("goods now");
       $('#BrandList').addClass("goods now");
       $('#ProductBrands').addClass("goodscate");
       $('.catatitle').css("background","url(/SiteCommon/Images/categories_o.gif) no-repeat");
       $('#ProductBrands').show();
       $('#ProductCategories').hide();
    }); 
    
    $('#ModANav01').bind("mouseover",function(){  
        $('#Tab01').show();
        $('#Tab02').hide();
        $('#Tab03').hide();
        $('#Tab04').hide();
        $(this).addClass("now");
        $('#ModANav02').removeClass("now");
        $('#ModANav03').removeClass("now");
        $('#ModANav04').removeClass("now");
    })
    
    $('#ModANav02').bind("mouseover",function(){  
        $('#Tab01').hide();
        $('#Tab02').show();
        $('#Tab03').hide();
        $('#Tab04').hide();
        $(this).addClass("now");
        $('#ModANav01').removeClass("now");
        $('#ModANav03').removeClass("now");
        $('#ModANav04').removeClass("now");
    })
    
    $('#ModANav03').bind("mouseover",function(){  
        $('#Tab01').hide();
        $('#Tab02').hide();
        $('#Tab03').show();
        $('#Tab04').hide();
        $(this).addClass("now");
        $('#ModANav01').removeClass("now");
        $('#ModANav02').removeClass("now");
        $('#ModANav04').removeClass("now");
    })
    $('#ModANav04').bind("mouseover",function(){  
        $('#Tab01').hide();
        $('#Tab02').hide();
        $('#Tab03').hide();
        $('#Tab04').show();
        $(this).addClass("now");
        $('#ModANav01').removeClass("now");
        $('#ModANav02').removeClass("now");
        $('#ModANav03').removeClass("now");
    })
    
    $('.tips').bind("click",function(){
        showPopup();
    })
    
    $('#hotline').attr("title","点击进行问题咨询");
    $('#hotline').css("cursor","pointer");
    $('#hotline').bind("click",function(){
        window.location.href='/Professor/';
    })
});


      

