// JavaScript Document
   $(function(){
		$("input[name='SearchText']").css("color","#D4D0C8").val("Enter Keywords").click(function(){
			$(this).val('').css("color","#000");
		}).blur(function(){
			if($(this).val()==''){
				$(this).css("color","#D4D0C8").val("Enter Keywords");
			}
		});	
		
			if($.cookie('categoryid')!=null && $.cookie('categoryname')!=null&&$.cookie('searchtype')!=null){
            $("#txtCategory").val($.cookie('categoryname'));
			$("#hideCategory").val($.cookie('categoryid'));	
			
			$("#hideSearchType").val($.cookie('searchtype'));
			$("#infoType").val($.cookie('searchtypename'));
						
		}
		
		$("#infoType").click(function(){
            var	top=$(this).offset().top+2;
			var height=$(this).height();
			var left=$(this).offset().left;
		    var vli="<div id='divTypeC' style=\"background-color:#FFFFFF;border:1px solid #C3BEBA;width:102px;position:absolute; left:"+left+"px;top:"+(top+height)+"px;z-index:3000\">";		    
		    vli+="<ul><li  style=\"line-height:18px;padding:0px 5px 0px 5px;cursor:pointer\" val='product'>Product</li>";
		    vli+="<li style=\"line-height:18px;padding:0px 5px 0px 5px;cursor:pointer\" val='selloffer'>Selling Offer</li>";
		    vli+="<li style=\"line-height:18px;padding:0px 5px 0px 5px;cursor:pointer\" val='buyoffer'>Buying Offer</li></ul>";
		    $("body").append(vli);
		    $("#divTypeC").find("li").bind("click",function(){
				$("#infoType").val($(this).text());
				$("#hideSearchType").val($(this).attr("val"));
				$("#divTypeC").remove();
				
				$.cookie('searchtype',$("#hideSearchType").val(),{path:'/'});
				$.cookie('searchtypename',$("#infoType").val(),{path:'/'});
				
			}).bind("mouseover",function(){$(this).css("background-color","#cccccc");})
			.bind("mouseout",function(){$(this).css("background-color","#fff");});
		});
		
		$("#txtCategory").click(function(){
		    var	top=$(this).offset().top+2;
			var height=$(this).height();
			var left=$(this).offset().left;
			var vli="<div id='divSearchC' style=\"background-color:#FFFFFF;border:1px solid #C3BEBA;position:absolute; left:"+left+"px;top:"+(top+height)+"px;z-index:3000\"><ul>";
			vli+="<li style=\"line-height:18px;padding:0px 5px 0px 5px;cursor:pointer\" value='0'>All Categories</li>";
			$(categoryArray).each(function(){
				var t=$(this)[cType].toString();
				var v=$(this)[0].toString();
				vli+="<li style=\"line-height:18px;padding:0px 5px 0px 5px;cursor:pointer\" value='"+v+"'>"+t+"</li>"
			});
			vli+="</ul></div>";
			$("body").append(vli);
			$("#divSearchC").find("li").bind("click",function(){
				$("#txtCategory").val($(this).text());
				$("#hideCategory").val($(this).attr("value"));
				$("#divSearchC").remove();
				
				$.cookie('categoryid',$(this).attr("value"),{path:'/'});
				$.cookie('categoryname',$(this).text(),{path:'/'});					
				$.cookie('searchtype',$("select[name='InfoType']").val(),{path:'/'});
				
			}).bind("mouseover",function(){$(this).css("background-color","#cccccc");})
			.bind("mouseout",function(){$(this).css("background-color","#fff");});			
		});	
		
		$("#btnSearch").click(function(){
		    if($("input[name='SearchText']").val()=='Enter Keywords'){
		        $("input[name='SearchText']").val('');    
		    }    
		});	
		
		$(document).click(function(event){			
			if(event.target.id!='divSearch' && event.target.id!='txtCategory'){
				$("#divSearchC").remove();				
			};
			if(event.target.id!='divTypeC' && event.target.id!='infoType'){
				$("#divTypeC").remove();				
			};
		});	
		
		if($.cookie("loginStatus")==1){
		    $.get("/dialog/messageCount4Ajax.asp?NN="+Math.random(),function(result){		
		        if(result!=0){
	                var arr=result.split('|');		        
                    $("#newMessage").html("("+arr[0].toString()+")").attr("href","/dialog/list.asp?listType="+arr[1].toString()).parents("span").addClass("msgglobalNav");		    
                }
		    });		       			    
		}	
		$(".homeNav,.exhibitionNav,.publicNav,.buyOfferNav,.sellOfferNav,.myOfficeNav").click(function(){
		    $.cookie("urlType",$(this).attr("class").toString());
		});		
		
		$(".post a,.post1").click(function(){	
		    turl=$(this).attr("href");
		    if($.cookie("loginStatus")==null || $.cookie("loginStatus")==0){		                                    	        
                floatLogin();		            
                return false;       
		    }		   
		});						
	});
	 //结果处理
    function ajaxSuccess(result){
        if(result==1){		                                
            $("#floatDiv,#divBottom").remove();$("body").css("overflow-y","visible");$("html").css("overflow-y","auto");
           
            $("#register,#spanLogin").remove();	
            $("#labWelcome").after(" <span class=\"warn\">"+$.cookie("En%5FwebName")+"</span>&nbsp;&nbsp;").show();
            $("#endLogin").show();	                                
            $("#textareaMsg").val('').css({"font-size":"12px","color":"black"}).removeAttr("readonly");    
        }		         
        else if(result==-1)
        {alert(cWrongCode);}
        else{
          alert(cLoginInfo);                                          
        }  
    }