// JavaScript Document

	var play = 1;
		
	var maxTop = window.pageYOffset;
	var maxBottom = window.pageYOffset;
	var maxLeft = window.pageXOffset;
	var maxRight = window.pageXOffset;
	
	var terminei = 0;
	
	var speed = 15;
	
	var orientY = 1;
	var orientX = 1;	
	
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		maxLeft = window.innerWidth-30;
		maxBottom = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		maxLeft = document.documentElement.clientWidth-30;
		maxBottom = document.documentElement.clientHeight ;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		maxLeft = document.body.clientWidth-30;
		maxBottom = document.body.clientHeight;
	}
	/* TEM ALGO ESTRANHO COM A FUNÇÃO, NÃO FUNCIONA DIREITO NO IE... */
	function fnMotionVert(banner, orient)
	{
		var bannerTop = parseInt(banner.style.top.substr(0, banner.style.top.length - 2));
		var bannerBottom = parseInt(banner.style.top.substr(0, banner.style.top.length - 2)) + parseInt(banner.style.height.substr(0, banner.style.height.length - 2));
		
		if(bannerBottom<maxBottom && bannerTop>0)
		{
			banner.style.top = String(parseInt(banner.style.top.substr(0, banner.style.top.length - 2)) + orient) + "px";
		} 
		else 
		{
			if(1==orientY)
			{
				banner.style.top = String(parseInt(banner.style.top.substr(0, banner.style.top.length - 2)) - 1) + "px";
				orientY = -1;
			} 
			else 
			{
				banner.style.top = String(parseInt(banner.style.top.substr(0, banner.style.top.length - 2)) + 1) + "px";
				orientY = 1;
			}
		}
	}
	
	function fnMotionHor(banner, orient)
	{
		var bannerLeft = parseInt(banner.style.left.substr(0, banner.style.left.length - 2));
		var bannerRight = parseInt(banner.style.left.substr(0, banner.style.left.length - 2)) + parseInt(banner.style.width.substr(0, banner.style.width.length - 2));
				
		if(bannerRight<maxLeft && bannerLeft>0)
		{
			banner.style.left = String(parseInt(banner.style.left.substr(0, banner.style.left.length - 2)) + orient) + "px";
		} 
		else 
		{
			if(1==orientX)
			{
				banner.style.left = String(parseInt(banner.style.left.substr(0, banner.style.left.length - 2)) - 1) + "px";
				orientX = -1;
			} 
			else 
			{
				banner.style.left = String(parseInt(banner.style.left.substr(0, banner.style.left.length - 2)) + 1) + "px";
				orientX = 1;
			}
		}
	}
	
	function fnBannerMotion(id)
	{
		var banner = document.getElementById(id);
		if("hidden"==banner.style.visibility) banner.style.visibility = "visible";
		fnMotionVert(banner, orientY);
		fnMotionHor(banner, orientX);
		if(1==play) setTimeout("fnReload('"+id+"')", speed);
	}
	
	function fnReload(id)
	{
		fnBannerMotion("bannerCar");
	}
	
	function fnOverBanner(obj)
	{
		if(!terminei)
		{
			obj.style.cursor="pointer";
			obj.style.cursor="hand";
			play=0;
		}
	}
	
	function fnOutBanner(obj)
	{
		if(!terminei)
		{
			obj.style.cursor="auto";
			play=1;
			fnBannerMotion("bannerCar");
		}
	}
	
	function fnFecharBanner(id)
	{
		play=0;
		
		$(function(){
			
			$("#bannerCar").fadeOut();
			$("#FlashID2").fadeOut();
			
		});
		
		//document.getElementById("bannerCar").style.visibility='hidden';
		//document.getElementById("FlashID2").style.visibility='hidden';
		terminei=1;
		//alert(id);
	}
