// JavaScript Document
$.fn.getAdv = function(option){
  var autoHide = option.autoHide;
  var autoFocus = option.autoFocus;
  var obj = this;
  //加载banner对象，设置属性相对定位，并处理隐藏
  var objHeight = obj.children("img").height();
  var objWidth = obj.children("img").width();
  obj.css({position:"absolute",zIndex:10,marginTop:-(objHeight),width:"100%",left:"0px",height:objHeight+20,textAlign:"center"});
  //向下加载
  var closeBtn = "<div id='closeBtn' style='position:absolute; bottom:-20px; z-index:11; right:0px; width:60px; height:40px; cursor:pointer;'><img src='Image/Close.jpg' /></div>";

  if(autoFocus){
	 var coverDiv = "<div id='cover' style='position:absolute; z-index:0; left:0px; top:0px; width:100%; height:100%; background:#000;'></div>"; 
	 $("body").append(coverDiv);
	 $("#cover").css("filter","alpha(opacity=70)");
  }  
  
  obj.animate({marginTop:"0"},1000,function(){
   if(autoHide){  
   obj.append(closeBtn);
   $("#closeBtn").toggle(function(){
      obj.animate({marginTop:-(objHeight)},1000,function(){
       $("#closeBtn").html("<img src='Image/Open.jpg' />"); 
	   $("#cover").remove();
            });        
         },function(){
		$("body").append(coverDiv);
	 $("#cover").css("filter","alpha(opacity=70)");
      obj.animate({marginTop:0},1000,function(){
       $("#closeBtn").html("<img src='Image/Close.jpg' />");
            });  
         });
   }          
  });
};

