// JavaScript Document
function footerad(width,height,imgUrl,targetUrl,timeHide)
{
	$(document).ready(function(){
		var htmlCode = "<div id=\"footerad\" style=\"position:absolute; width:"+width+"px; height:"+height+"px; overflow:hidden; z-index:10000;\">";
		htmlCode = htmlCode + "<a href=\""+targetUrl+"\" target=\"_blank\"><img style=\"position:absolute; z-index:10001;border:none;\" src=\""+imgUrl+"\" /></a>";
		htmlCode = htmlCode + "<p style=\"position:absolute; color:#FFFFFF; background:#999999; font-family:Arial, Helvetica, sans-serif; font-size:10px; height:12px; width:25px; line-height:12px; cursor:pointer; z-index:10002;\">close</p>"
		htmlCode = htmlCode + "</div>";
		$("body").append(htmlCode);
		$("#footerad p").css("left",width-25);
		var left = $(window).width()-width;
		var top = $(window).height()-height;
		$("#footerad").css("left",left);
		$("#footerad").css("top",top);
		$("#footerad p").click(function(){
			$("#footerad").hide();
		})
		if(timeHide>0)
		{
			setTimeout("$(\"#footerad\").hide()",timeHide*1000);
		}
		$(window).resize(function(){
			left = $(window).width()-width;
			top = $(window).height()-height;
			$("#footerad").css("left",left);
			$("#footerad").css("top",top);
		});
		$(window).scroll( function() {
			left = document.documentElement.scrollLeft + document.documentElement.clientWidth-width;
			top = document.documentElement.scrollTop + document.documentElement.clientHeight-height;
			$("#footerad").css("left",left);
			$("#footerad").css("top",top);
		});
	});
} 
var floatadTimeout;
var floatadWidth;
var floatadHeight;
var bodyWidth;
var bodyHeight;
var positionWidth;
var positionHeight;
var xPos = 1;
var yPos = 1;
function floatadMove()
{
	if(xPos>0){
		positionWidth = positionWidth-1;
	}else{
		positionWidth = positionWidth+1;
	}
	if(yPos>0){
		positionHeight = positionHeight-1;
	}else{
		positionHeight = positionHeight+1;
	}
	
	if(positionWidth<=0){
		xPos = 0;
	}
	if(positionWidth>=bodyWidth){
		xPos = 1;
	}
	if(positionHeight<=0){
		yPos = 0;
	}
	if(positionHeight>=bodyHeight){
		yPos = 1;
	}
	$("#floatad").css("left",positionWidth);
	$("#floatad").css("top",positionHeight);
	floatadTimeout = setTimeout(floatadMove,20);
}
function floatad(width,height,imgUrl,targetUrl,timeHide)
{
	$(document).ready(function(){
		var htmlCode = "<div id=\"floatad\" style=\"position:absolute; width:"+width+"px; height:"+height+"px; overflow:hidden; z-index:10000;\">";
		htmlCode = htmlCode + "<a href=\""+targetUrl+"\" target=\"_blank\"><img style=\"position:absolute; z-index:10001;border:none;\" src=\""+imgUrl+"\" /></a>";
		htmlCode = htmlCode + "<p style=\"position:absolute; color:#FFFFFF; background:#999999; font-family:Arial, Helvetica, sans-serif; font-size:10px; height:12px; width:25px; line-height:12px; cursor:pointer; z-index:10002;\">close</p>"
		htmlCode = htmlCode + "</div>";
		$("body").append(htmlCode);
		$("#floatad p").css("left",width-25);
		bodyWidth = $(window).width()-width;
		bodyHeight = $(window).height()-height;
		floatadWidth = width;
		floatadHeight = height;
		positionWidth = bodyWidth;
		positionHeight = bodyHeight;
		$("#floatad").css("left",positionWidth);
		$("#floatad").css("top",positionHeight);
		$("#floatad p").click(function(){
			$("#floatad").hide();
		})
		$("#floatad").mouseover(function(){
			clearTimeout(floatadTimeout);
		})
		$("#floatad").mouseout(function(){
			floatadMove();
		})
		if(timeHide>0)
		{
			setTimeout("$(\"#floatad\").hide()",timeHide*1000);
		}
		$(window).resize(function(){
			bodyWidth = $(window).width()-width;
			bodyHeight = $(window).height()-height;
		});
		$(window).scroll( function() {
			bodyWidth = document.documentElement.scrollLeft + document.documentElement.clientWidth-width;
			bodyHeight = document.documentElement.scrollTop + document.documentElement.clientHeight-height;
		});
		floatadMove();
	});
}
