﻿$(function(){ 
//头部广告
if($(".topadvS").find("img").size()>0)
{
 
setTimeout(function(){
   var hh= $(".topadvS").find("img").height();  
   $(".topadvS").animate({"height":'toggle'},3000);
       setTimeout(function(){
           $(".topadvS").animate({"height":'0px'},3000);
       },10000);
   },1000);
 
}
// 
     var len  = $(".zkM_index > li").length;
	 var index_Move = 0;
	 var adTimer;
	 $(".zkM_index li").mouseover(function(){
		index_Move  =   $(".zkM_index li").index(this);
		if(adTimer)clearTimeout(adTimer);
		showImg(index_Move);		
	 }).eq(0).mouseover();	
	 
	 //滑入 停止动画，滑出开始动画.
	 $('.zkMove').hover(function(){
			 if(adTimer)clearTimeout(adTimer);
		 },function(){
          setTiem_fun();
	 }).trigger("mouseleave");
	 
    function setTiem_fun()
    {
			     adTimer = setTimeout(function(){
			        showImg(index_Move)
				    index_Move++;
				    if(index_Move==len){index_Move=0;}
			      } , 4500);
    }
      // 通过控制top ，来显示不同的幻灯片
function showImg(index_Mo){
        var adHeight = $(".zkMove li").height();
		$(".zkMove").stop(true,false).animate({top : -adHeight*index_Mo},1000,function(){
		setTiem_fun();
		});
		$(".zkM_index li").removeClass("on").eq(index_Mo).addClass("on");
} 

});


$(function(){
//浮动广告关闭
   if($(".closeAf").size()>0)
   {
      
      $(".closeAf").each(function(){
         var _this=$(this);
         var _pare=$(this).parent("div");
         _pare.bind("mouseover",function(){
              _this.css({"display":""});
         });
          _pare.bind("mouseout",function(){
                _this.css({"display":"none"});
           }); 
           _this.bind("click",function(){
              _pare.css({"display":"none"});
           });
         
      });
   }
   
   
   //炸屏广告
   if($(".floatCenter").size()>0)
   {
    function centerPopWin() { 
 
	    var width = $(".floatCenter").width(); 
		var height = $(".floatCenter").height();   
		var theBody = document.getElementsByTagName("BODY")[0]; 
		var scTop = parseInt(getScrollTop(),10);
		var scLeft = parseInt(theBody.scrollLeft,10);		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		var _tops=scTop + ((fullHeight - height) / 2);
		var _lefts=scLeft + ((fullWidth - width) / 2);
		if(_tops<0){_tops=0;}
		$(".floatCenter").css({"top":_tops+"px","left":_lefts+"px"}) 
}
 
    addEvent(window, "resize", centerPopWin);
    addEvent(window, "scroll", centerPopWin);
    window.onscroll = centerPopWin;
centerPopWin();
   }   
   
   
   
});//end function

//functions
//得到滚动条top
function getScrollTop() {
	if (self.pageYOffset) // all except Explorer
	{		return self.pageYOffset;	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{		return document.documentElement.scrollTop;	}
	else if (document.body) // all other Explorers
	{		return document.body.scrollTop;	}
}
//得到页面高
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
//得到页面宽
function getViewportWidth() {
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}
function addEvent(obj, evType, fn){
 if (obj.addEventListener){
    obj.addEventListener(evType, fn, false);
    return true;
 } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
 } else {
    return false;
 }
}
