﻿$(document).ready(function(){

 //------------------region >category menu------------------------------------------
    var zanUrl='/product/product_list.asp?'
    if($.cookie("urlType")!=""){  
        switch($.cookie("urlType")){                
            case "homeNav":
               zanUrl='/product/product_list.asp?' 
            break;
            case "exhibitionNav":
                zanUrl='/product/product_list.asp?' 
            break;
            case "publicNav":
                zanUrl='/product/product_list.asp?';
            break;
            case "buyOfferNav":
                zanUrl='/search.asp?InfoType=buyoffer&';
            break;
            case "sellOfferNav":
                zanUrl='/search.asp?InfoType=selloffer&';
            break;
            case "myOfficeNav":
                zanUrl='/product/product_list.asp?' 
            break;
        }
    }   
       
 
    var limenu='<h2>'+cMenu+'</h2><ul>';
    $(categoryArray).each(function(n,i){
    
        limenu+="<li value='"+i[0]+"' text='"+i[3]+"'><a href=\""+zanUrl+"categoryid="+i[0]+"\">"+i[cType]+"</a></li>";
    });
    limenu+="</ul><span class=\"bottom\"><span></span></span>";
    $(".cataLog").html(limenu);
    
    
    $(".cataLog h2").siblings("ul").children().hover(function(){   
        var bodyHeight= document.body.clientHeight;
        var documentScrollTop=window.document.documentElement.scrollTop;
        var divccHeight   
        var divccTop 
          
        var livalue=$(this).attr("value");
        var limenu2='';
        $(categoryArray2).each(function(n,i){
            if(i[1]==livalue){
                limenu2+="<li style='padding-left:15px;' value='"+i[0]+"'><a style='width:150px; display:block; padding-bottom:5px; padding-top:5px;' href=\""+zanUrl+"categoryid="+i[0]+"\">"+i[cType]+"</a></li>";
            }
        });         
        if(limenu2!=''){
            limenu2="<ul>"+limenu2+"</ul>";            
           $(".cataLog_2").html(limenu2).css({"left":($(this).offset().left+$(this).width())+"px",top:$(this).offset().top+"px","z-index":3000}).show();        
        }
        else{$(".cataLog_2").hide();}     
            
        divccHeight=$("#divcc").height();
        divccTop= $("#divcc").offset().top
        if(bodyHeight<divccHeight+divccTop){    
            if(divccHeight<bodyHeight){
                $("#divcc").css("top",$(this).offset().top-(divccHeight/2));                
            }
            else{        
            $("#divcc").css("top",documentScrollTop+20);            
            }
        }
        
    },function(){$(".cataLog_2").css("margin-top",0).hide();});

    $(".cataLog_2").hover(function(){$(this).show();},function(){$(this).hide();});

 //判断ie版本60为6.0,70为7.0
    var ver=navigator.appVersion;
    var pst=ver.indexOf("MSIE");
    var first=ver.charAt(pst+5);
    var second=ver.charAt(pst+7);
    var nver=Number(first+second)
//----------------region>header
    if(nver!=60){
    var choimg;
    $(".touimg").hover(function(){
        $(this).stop().css("height","55px").attr({"src":"/ui/images/web/"+$(this).attr("value")+"-l.png"}).animate({"height":"100px"},200);
        choimg= $(this).attr("value");
    },function(){
        $(this).stop().attr("src","/ui/images/web/"+choimg+".png").animate({"height":"50px"},200);
    });          }
    
//----------------region> 首页暂时显示浮动名片
    $("#licard").click(function(){
        $("#tempDiv").show();        
    });
    $("body").dblclick(function(){
        $("#tempDiv").hide();                            
    });
    
//----------------region> effect bottom
    $(".control").toggle(function(){
        $(".controlPanel").show("fast");            
    },function(){
        $(".controlPanel").hide("fast");
    });
   
    
    if(nver==60){                
        // $(".shell").css("opacity",0);
    $(".buttomBg").hover(function(){   
       // $("html").css("overflow-y","hidden");     
        $("#"+$(this).attr("value")).css({"left":$(this).offset().left}).show().animate({"opacity":1},500).show();                                   
            $(this).addClass("bottomCurrent");
        },function(){
            $("#"+$(this).attr("value")).animate({"opacity":0},500);
            $(this).removeClass("bottomCurrent");
            //$("html").css({"overflow-y":"auto","overflow-x":"hidden"});
        });
        $(".shell").hover(function(){
            $(this).stop();//.show();        
        },function(){
            $(this).hide();
        });
    }                
    else
    {
        $(".buttomBg").hover(function(){   
           // $("html").css("overflow-y","hidden");     
            $("#"+$(this).attr("value")).css({"left":$(this).offset().left,"bottom":0-($("#"+$(this).attr("value")).height()+$(".siteBg").height())}).show()
            .animate({"bottom":31}, 300 );                                   
            $(this).addClass("bottomCurrent");
        },function(){
            $("#"+$(this).attr("value")).animate({"bottom":0-($("#"+$(this).attr("value")).height())}, 300 );
            $(this).removeClass("bottomCurrent");
            //$("html").css({"overflow-y":"auto","overflow-x":"hidden"});
        });
        $(".shell").hover(function(){
            $(this).stop();//.show();        
        },function(){
            $(this).hide();
        });
    }
//--------------------------信息拖动收藏
    var d
    var favoriteHtml=''
   // if($.cookie("shou")!=''){$("#scla").html($.cookie("shou"));}
    $(".dragBox dl dt").draggable({
        helper:'clone',
        opacity:true,
        zIndex:3000})
        .mousedown(function(){  
               var bd=$(".leftBottomBg:contains('我的收藏夹')").offset().left   
               favoriteHtml= $("#favoritesPanel").html()       
               $("#favoritesPanel").empty().css({"display":"block","bottom":"31px","left":bd,"height":"90px"}) ;                   
        });
    $("body").mouseup(function(){                
                $("#favoritesPanel").html(favoriteHtml).css({"display":"none","bottom":0}); 
        });
     $(".shell").each(function(){
        $(this).droppable({
         accept: '.dragBox dl dt',                
         hoverClass: 'ui-state-hover',             
         tolerance: 'touch',
         drop: function(event, ui) {
          //  $("body,html").css("overflow-y","auto");
           // $("#scla").html(d);
           // $.cookie("shou",d);
           // alert("on");
         },
         over:function(){// $("body,html").css("overflow-y","hidden");
         //$("#scla").css({"left":$("#shoucang").offset().left,"top":$("#shoucang").offset().top-$("#scla").height()}).show();}
            //alert("over");
            }
        }); 
     });
     
//-------------------------------go
	$("#btn_PageGo").click(function(){urlByPage($("#txt_PageGo").val());});

	$(document).keydown(function(event){  						
                if(event.keyCode==13){			
                    urlByPage($("#txt_PageGo").val());                    
                }            
            });
});