		/*
			BoycePopAD - 浮动跟屏广告
			Date:2010-08-19
			Author:boyce(youngsoul@126.com|277841301)
			跟屏方式：
			tl:左上角
			tr:右上角
			ml:左中边
			mr:右中边
			bl:左下角
			br:右下角
			mm:屏幕中央
		*/
		var extra = 0;
		function BoycePopAD(jqAD,pos){	
		
			var adPos = pos;
			BoycePopAD.ie6 = getIE6();
			var adIframe;
			
			var topP;
			var leftP;
			var maxWidth = jqAD.width();
			var outWidth = jqAD.outerWidth();
			
			extra += 1;
			
			BoycePopAD.init = function(){
				var zindex = 999990 + extra;
				var zindex2 = 999990 - extra;
				var div = "BoycePopIframe" + extra;
				var divID = "#BoycePopIframe" + extra;
				
				var frameStr = "<iframe frameborder='0' scrolling='no' id=" + div + "></iframe>";
				
				if(BoycePopAD.ie6){
					jqAD.css({position:"absolute","z-index":zindex,overflow:"hidden"});
					jqAD.before(frameStr);
					adIframe = jQuery(divID);
					adIframe.css({position:"absolute","z-index":zindex2});
				}else{
					jqAD.css({position:"fixed","z-index":zindex});
				}
				posIt();
				
			}
			
			function posIt(){
				switch (adPos){
					case "tl":
						topP = 0;
						leftP = 0;
						break;
					case "tr":
						topP = jQuery(window).scrollTop();
						leftP = document.documentElement.clientWidth - jqAD.outerWidth();
						break;
					case "ml":
						topP = (document.documentElement.clientHeight - jqAD.outerHeight()) / 2;
						leftP = 0;
						break;
					case "mr": 
						topP = (document.documentElement.clientHeight - jqAD.outerHeight()) / 2;
						leftP = document.documentElement.clientWidth - jqAD.outerWidth();
						break;
					case "bl":
						topP = document.documentElement.clientHeight - jqAD.outerHeight();
						leftP = 0;
						break;
					case "br":
						topP = document.documentElement.clientHeight - jqAD.outerHeight();
						leftP = document.documentElement.clientWidth - jqAD.outerWidth();
						break;
					case "mm":
						topP = (document.documentElement.clientHeight - jqAD.outerHeight()) / 2;
						leftP = (document.documentElement.clientWidth - jqAD.outerWidth()) / 2;
						break;
					default: alert("请使用正确的对齐方式：tl,tr,ml,mr,bl,br,mm中的一种"); break;
				}
				followPos();
			}
			//固定跟屏			
			function followPos(){				
				if(BoycePopAD.ie6){
					jqAD.css({top:topP, left:leftP});					
					adIframe.css({top:topP, left:leftP, width:jqAD.width(), height:jqAD.height()});					
					jQuery(window).scroll(function(){
						var windowBottom = jQuery(window).scrollTop() + topP;
						adIframe.animate({top:windowBottom},{duration:400, queue:false});
						jqAD.animate({top:windowBottom},{duration:400, queue:false});
					})
				}else{
					jqAD.css({top:topP, left:leftP});
				}
			}
			
			this.close = function(){
				jqAD.hide();
			}
			
			this.minSize = function(w,jqCon){
				var targetPos = jqAD.position().left + outWidth - w;
				jqAD.animate({width:w},{duration:"fast",queue:false});
				jqAD.animate({left:targetPos},{duration:"fast",queue:false});				
				jqCon.hide()
				if(BoycePopAD.ie6){
					adIframe.animate({left:targetPos},{duration:"fast",queue:false});
					adIframe.animate({width:w},{duration:"fast",queue:false});
				}
			}
			
			this.maxSize = function(w,jqCon){
				var targetPos = jqAD.position().left - outWidth + w;
				jqAD.animate({width:maxWidth},{duration:"fast",queue:false});
				jqAD.animate({left:targetPos},"fast",function(){jqCon.show();});
				
				
				if(BoycePopAD.ie6){
					adIframe.animate({left:targetPos},{duration:"fast",queue:false});
					adIframe.animate({width:maxWidth},{duration:"fast",queue:false});
				}
			}
			
			function addLoad(func,var1,var2){				
				var oldLoad = window.onload;
				if(typeof window.onload != "function"){
					window.onload = function(){
						func(var1,var2);
					}
				}else{
					window.onload = function(){
						oldLoad();
						func(var1,var2);
					}
				}
			}
			//end addLoad
			
			function getIE6(){
				var browser=navigator.appName;
				var b_version=navigator.appVersion;
				var version=b_version.split(";"); 
				var trim_Version=version[1].replace(/[ ]/g,""); 
				if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") {return false; } else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") {return true; }	
			}
			//end getIE6
			BoycePopAD.init();
			jQuery(window).resize(function(){
				posIt();
			})
		}
