(function($) {
	$.fn.jFloat = function(o) {

			o = $.extend({
					top:60,  //广告距页面顶部距离
					left:0,//广告左侧距离
					right:0,//广告右侧距离
					width:100,  //广告容器的宽度
					height:360, //广告容器的高度
					minScreenW:800,//出现广告的最小屏幕宽度，当屏幕分辨率小于此，将不出现对联广告
					position:"left", //对联广告的位置left-在左侧出现,right-在右侧出现
					allowClose:true //是否允许关闭
			}, o || {});
	var h=o.height;
		var showAd=true;
		var fDiv=$(this);
		if(o.minScreenW>=$(window).width()){
				fDiv.hide();
				showAd=false;
		 }
		 else{
		 fDiv.css("display","block")
				 var closeHtml='';
				 switch(o.position){
						 case "left":
									if(o.allowClose){
										 fDiv.prepend(closeHtml);
					 $(".closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					 h+=20;
				}
									fDiv.css({position:"absolute",left:o.left+"px",top:o.top+"px",width:o.width+"px",height:h+"px"});
									break;
						 case "right":
									if(o.allowClose){
										 fDiv.prepend(closeHtml)
					 $(".closeFloat",fDiv).click(function(){$(this).hide();fDiv.hide();showAd=false;})
					 h+=20;
				}
									fDiv.css({position:"absolute",left:"auto",right:o.right+"px",top:o.top+"px",width:o.width+"px",height:h+"px"});
									break;
					};
			};
			function ylFloat(){
					if(!showAd){return}
					var windowTop=$(window).scrollTop();
					if(fDiv.css("display")!="none")
							fDiv.css("top",o.top+windowTop+"px");
			};

		$(window).scroll(ylFloat) ;
		$(document).ready(ylFloat);

	};
})(jQuery);

(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

(function($){
	$.fn.extend({
		menu: function(options) {
			var defaults = {
				menuObj: null,
				zindex:false,
				pos:3
			};
			var options = $.extend(defaults, options);
			return this.each(function() {
				var o =options;
				var obj = $(this);
				var menuBody=o.menuObj;
				var pos=o.pos;
				if (menuBody==undefined) {
					menuBody=$(this).next();
				}
				var posAttr=$(this).attr("pos");
				var xfix=0,yfix=0;
				if (posAttr!=undefined) {
					var posArr=posAttr.split(",");
					pos=parseInt(posArr[0]);
					if (posArr.length>0) {
						xfix=parseInt(posArr[1]);
					}
					if (posArr.length>1) {
						yfix=parseInt(posArr[2]);
					}
					if (isNaN(xfix)) xfix=0;
					if (isNaN(yfix)) yfix=0;
				}
				var cwidth=$(this).width();
				var cheight=$(this).height();
				menuBody.bgiframe();
				var timer;
				obj.mouseover(function() {
					if (timer!=undefined) {
						clearTimeout(timer);
					}
					var offset=$(this).offset();
					var cleft=offset.left;
					var ctop=offset.top;
					if (pos==4) {
						menuBody.css({left:cleft-cwidth-xfix,top:ctop+yfix,position:"absolute","z-index":"9999"});
					}
					if (pos==3) {
						menuBody.css({left:cleft+xfix,top:ctop+cheight+yfix,position:"absolute","z-index":"9999"});
					}
					if (pos==2) {
						menuBody.css({left:cleft+cwidth+xfix,top:ctop+yfix,position:"absolute","z-index":"9999"});
					}
					menuBody.css("display","block");
				});
				obj.add(menuBody).mouseout(function(){
					timer=setTimeout(function(){hidDiv(menuBody)},100);
				});
				var hidDiv=function(obj){
					obj.css("display","none");
				}
				menuBody.mouseover(function() {
					clearTimeout(timer);
				});
			});
		}
	});
})(jQuery);

$(function(){
	$('#qqService').css("display","block");
	$("._menu").menu({'menuObj':$('#qqServicePan')});
	$("#qqService").jFloat({
		 position:"right",
		 top:0,
		 height:143,
		 width:44,
		 right:0
	 });
});
