$(function(){
showMenu();
setNavStyle();
getDateTime();
Links();
})

$(function(){
		   

								
							
		    $(window).scroll(function(){
									  
							   	var QQ_State=getCookie("QQ_State");
						
								
								
								if($("#qq").is(":animated"))
								{
							//$("#qq").stop(true);
								}
							
								if(QQ_State==2)
								{
									
									$("#qq").css("top",$(window).height()+$(window).scrollTop()-30)
								
								
								}
								else
								{
								
									var top=$(window).scrollTop()+100;
									$("#qq").animate({top:top},{duration:5,easing:"linear",queue:true})
								}
								
								
									  
									  })
			
			$("#qq #qqTop #qq_hide").click(function(){ 
													$(this).parent().parent().hide()
													 setCookie("QQ_State","0");
													 $(this).hide()
													 $("#qq_open").show()
													
													})
			
			$("#qq #qqTop #qq_open").click(function(){ 
														$(this).parent().parent().css("top",$(window).scrollTop()+100)
														 setCookie("QQ_State","1");
														 $(this).hide()
													    $("#qq_small").show()
													     $("#qqBody").show()
														$("#qqFooter").show()
														}
														
													)
			
			
			$("#qq #qqTop #qq_small").click(function(){ 
													 
													 $(this).parent().parent().animate({ 
																					   top:$(window).height()-$(this).height() -10 +$(window).scrollTop()
																					   },200,function(){
																						   
																						     setCookie("QQ_State","2");
																						      $("#qq_small").hide()
																						      $("#qqBody").hide()
																						      $("#qqFooter").hide()
													                                         $("#qq_open").show()
																						     
																						     
																																	   })
													 
													 })
			
		   })
//____________________________

function Links()
{
$("#Footer1_links_sel").bind("change",function(){
 var url=$("#Footer1_links_sel option[selected]").val();
 if(url!="0")
 {
 window.open(url)
 }
})
}


function getDateTime()
{
 var c=new Date();
 $("#datetimespan").html(c.toLocaleDateString());

}


function showMenu() 
{
$("#menu_top_ul ul:eq(0)").show()
$("#menu_top_ul li").each(function(){

$(this).bind("click",
function(){ 
		$("#menu_top_ul ul").slideUp()
		$("ul",this).slideToggle()
			})
}
)
}

function setNavStyle()
{
$("#header #right li img").hover(
function()
{
 $(this).css("opacity","0.5")
}
,
 function()
 {
  $(this).css("opacity","1")
 }
)
}




//是否已经安装QQ
  function qqInstalled() {
      try {
            new ActiveXObject("QQ.QQAPI");
            return true;
      }
      catch (e) {
       alert("您还没有安装QQ");
            return false;
      }
  }
  //是否已经MSN
function messengerInstalled() {
      try {
            new ActiveXObject("MSNMessenger.P4QuickLaunch");
            return true;
      }
      catch (e) {
      alert("您还没有安装MSN");
      this.href="#";
            return false;
      }
  }



//等比缩小图片
function DrawImage(ImgD,FitWidth,FitHeight){
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
         if(image.width/image.height>= FitWidth/FitHeight){
             if(image.width>FitWidth){
                 ImgD.width=FitWidth;
                 ImgD.height=(image.height*FitWidth)/image.width;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             }
         } else{
             if(image.height>FitHeight){
                 ImgD.height=FitHeight;
                 ImgD.width=(image.width*FitHeight)/image.height;
             }else{
                 ImgD.width=image.width; 
                ImgD.height=image.height;
             } 
        }
     }
 }



//操作COOKIE
function  setCookie(name,value)  
 {  
     var Days = 30;   //此cookie将被保存30天  
     var exp = new Date(); 
     exp.setTime(exp.getTime() + Days*24*60*60*1000);  
     document.cookie = name + "=" + escape(value) 
		+ ";expires=" + exp.toGMTString();  
 }  
 function getCookie(name)  
 {  
     var arr,reg=new RegExp("(^|)"+name+"=([^;]*)(;|$)");  
     if(arr=document.cookie.match(reg))
	return unescape(arr[2]);  
     else
	return null;  
 }  
 function delCookie(name)  
 {  
     var exp = new Date();  
     exp.setTime(exp.getTime() - 1);  
     var cval=getCookie(name);  
     if(cval!=null) {
	document.cookie= name + "="+cval
		+";expires="+exp.toGMTString();
	}
 }

