/*
右下弹窗广告
*/
var showtime=0;
var marginL=10; //右边距
var it1;

function ShowPop(){
	var popup=document.createElement("DIV");
	popup.id="popup";
	popup.className='t';
	popup.style.height=popHeight+"px";
	popup.style.width=popWidth+"px";
	popup.style.padding="0";
	popup.style.margin="0";
	popup.style.backgroundColor="#FFFFFF";
	popup.style.position="absolute";
	popup.style.top=document.body.clientHeight+document.body.scrollTop-marginL-popHeight+"px";
	popup.style.right=marginL+"px";
	popup.innerHTML="<table cellspacing=0 cellpadding=0 width=100%><tr><td class='h'><span style='float:right;'>"+popTitle+"<a id='closeButton' title='close' onclick='hidePop();'>X</a></span></td></tr><tr class='f_one'><td style='padding:5px;'>" + popCode + "</td></tr></table>";
	var btn = findElement(popup,'a',"closeButton");
	btn.style.cssText='cursor:pointer;padding:1px 2px 1px;height:8px;width:8px;margin-left:5px;border:1px solid #9ad; font:9px Verdana; text-decoration:none;';
	
	document.body.appendChild(popup);
	it1 = setInterval("floatPop()",100);
}
function floatPop(){
	if(autoClose>0){
		showtime++;
		if(showtime > autoClose*10){
			hidePop('auto');
			return;
		}
	}
	document.getElementById("popup").style.top=document.body.clientHeight+document.body.scrollTop-marginL-popHeight+"px";
}
function hidePop(type){
	document.getElementById("popup").style.display="none";
	clearInterval(it1);
	if(typeof type=='undefined') document.cookie="hidepop=1; path=/";
}
function findElement(root,tag,id){
	var ar=root.getElementsByTagName(tag);
	for(var i=0;i<ar.length;i++){
		if(ar[i].id==id) return ar[i];
	}
	return null;
}


/*
漂浮广告1
*/
/*如何用?
例子1:
<script src="include/float.js" language="javascript"></script>
<script language="javascript">

var floatCode = '<a href="http://www.ah.gov.cn" target="_blank"><img src="http://www.ah.gov.cn/otherimages/22.gif" width="200" height="86"></a>';
ShowAd();
</script>

例子2:
<script src="include/float.js" language="javascript"></script>
<script language="javascript">

var floatCode = '<IFRAME marginWidth=0 marginHeight=0 name="biddingframe2" src="gzh.htm" frameBorder=0 scrolling=no width=200 height=90></IFRAME>';
ShowAd();
</script>
*/
var it2;
var delay = 10;
var x = 50,y = 60; //初始坐标
var xin = true,yin = true;
var step = 1;

function ShowAd(){
	document.write("<div id='floatAd' style='position:absolute'>");
	document.write(floatCode);
	document.write("<br /><a style='cursor:pointer; font-size:13px' onclick='hideAd();'><b>关闭</b></a></div>");
	obj = document.getElementById("floatAd");
	it2= setInterval("floatAd()", delay);
	obj.onmouseover=function(){clearInterval(it2)};
	obj.onmouseout=function(){it2=setInterval("floatAd()", delay)};
}
function floatAd(){
	var L=T=0;
	var R = document.body.clientWidth-obj.offsetWidth;
	var B = document.body.clientHeight-obj.offsetHeight;
	obj = document.getElementById("floatAd");
	obj.style.left = x + document.body.scrollLeft + "px";
	obj.style.top = y + document.body.scrollTop + "px";
	x = x + step*(xin?1:-1);
	if (x < L) { xin = true; x = L};
	if (x > R) { xin = false; x = R};
	y = y + step*(yin?1:-1);
	if (y < T) { yin = true; y = T };
	if (y > B) { yin = false; y = B };
}
function hideAd(){
	document.getElementById("floatAd").style.display="none";
	clearInterval(it2);
}
/*
漂浮广告2
*/
/*如何用?
例子1:
<script src="include/float.js" language="javascript"></script>
<script language="javascript">

var floatCode2 = '<a href="http://www.ah.gov.cn" target="_blank"><img src="http://www.ah.gov.cn/otherimages/22.gif" width="200" height="86"></a>';
ShowAd2();
</script>

例子2:
<script src="include/float.js" language="javascript"></script>
<script language="javascript">

var floatCode2 = '<IFRAME marginWidth=0 marginHeight=0 name="biddingframe2" src="gzh.htm" frameBorder=0 scrolling=no width=200 height=90></IFRAME>';
ShowAd2();
</script>
*/
var it21;
var delay2 = 60;
var x2 = 450,y2 = 160; //初始坐标
var w_l = true,w_r = true;
var step2 = 2;

function ShowAd2(){
	document.write("<div id='floatAd2' style='position:absolute'>");
	document.write(floatCode2);
	document.write("<br /><a style='cursor:pointer;font-size:13px' onclick='hideAd2();'><b>关闭</b></a></div>");
	obj = document.getElementById("floatAd2");
	it21= setInterval("floatAd2()", delay2);
	obj.onmouseover=function(){clearInterval(it21)};
	obj.onmouseout=function(){it21=setInterval("floatAd2()", delay2)};
}
function floatAd2(){
	var L=T=0;
	var R = document.body.clientWidth-obj.offsetWidth;
	var B = document.body.clientHeight-obj.offsetHeight;
	obj = document.getElementById("floatAd2");
	obj.style.left = x2 + document.body.scrollLeft + "px";
	obj.style.top = y2 + document.body.scrollTop + "px";
	x2 = x2 + step2*(w_l?1:-1);
	if (x2 < L) { w_l = true; x2 = L};
	if (x2 > R) { w_l = false; x2 = R};
	y2 = y2 + step2*(w_r?1:-1);
	if (y2 < T) { w_r = true; y2 = T };
	if (y2 > B) { w_r = false; y2 = B };
}
function hideAd2(){
	document.getElementById("floatAd2").style.display="none";
	clearInterval(it21);
}
/*
左右漂浮对联广告
*/
var marginTop = 120; //对顶上边距
var marginX = 15; //横向 边距
var it33;

function ShowFloat(){
	if(LeftCode!='')
		document.write("<div id=\"adLeftFloat\" style=\"position: absolute; left:"+marginX+"px; top:"+marginTop+"px;\">");
		document.write(LeftCode);
	document.write("<br /><a style='cursor:pointer;font-size:13px' onclick='hideFloat();'><b>关闭</b></a></div>");
	
	moveFloat();
}
function hideFloat(){
	clearTimeout(it33);
	if(IsElement("adLeftFloat"))
		document.getElementById("adLeftFloat").style.display = "none";
	
	return false;
}
function moveFloat(){
	if(IsElement("adLeftFloat"))
		document.getElementById("adLeftFloat").style.top = document.body.scrollTop + marginTop + 'px';
	
	it33 = setTimeout("moveFloat();",80);
}
