var Type = 'unknow';
var rightGap = 150;
var topRightGap = 10;
var leftGap = 5; 
var topLeftGap = 50;
var areaSize = 300;

///////////////////////////////////// FUNCTION ///////////////////////////////////////
function StartFloatRight()
{
	if(document.all) // Compatible with Internet Explorer & Opera
	{

		document.all.FloatingAdRight.style.pixelLeft = (document.body.clientWidth - document.all.FloatingAdRight.offsetWidth) - rightGap;

		document.all.FloatingAdRight.style.pixelTop = document.body.scrollTop + topRightGap;

		document.all.FloatingAdRight.style.visibility = 'visible';
		Type = 'all';
	}
	else if(document.getElementById) // Compatible with Firefox & Netscape
	{

		document.getElementById('FloatingAdRight').style.left = (window.innerWidth - areaSize - 20) - rightGap + 'px';

		document.all.FloatingAdRight.style.pixelTop = topRightGap;

		document.getElementById('FloatingAdRight').style.visibility = 'visible';
		Type = 'getelement';
	}
	
	if (document.all) { 
		window.onscroll = FloatBoth; 
		window.onresize = AdjustRight;
	} 
	else { 
		setInterval('FloatBoth()',100);
		setInterval('AdjustRight()',100);
	} 
}
function FloatRight() 
{
	if (Type == 'all') 
	{ 
		document.all.FloatingAdRight.style.pixelTop = document.body.scrollTop + topRightGap; 
	}
	else if (Type == 'getelement') { document.getElementById('FloatingAdRight').style.top = window.pageYOffset + topRightGap + 'px'; }
}
function AdjustRight()
{
	if(document.all) {
		document.all.FloatingAdRight.style.pixelLeft = (document.body.clientWidth - document.all.FloatingAdRight.offsetWidth) - rightGap;
	} else if(document.getElementById) {
		document.getElementById('FloatingAdRight').style.left = (window.innerWidth - areaSize - 20) - rightGap + 'px';
	}
}

function StartFloatLeft()
{
	if(document.all) // Compatible with Internet Explorer & Opera
	{

		document.all.FloatingAdLeft.style.pixelLeft = leftGap;

		document.all.FloatingAdLeft.style.pixelTop = document.body.scrollTop + topLeftGap;

		document.all.FloatingAdLeft.style.visibility = 'visible';
		Type = 'all';
	}
	else if(document.getElementById) // Compatible with Firefox & Netscape
	{

		document.getElementById('FloatingAdLeft').style.left = leftGap + 'px';

		document.all.FloatingAdLeft.style.pixelTop = topLeftGap;

		document.getElementById('FloatingAdLeft').style.visibility = 'visible';
		Type = 'getelement';
	}
	
	if (document.all) { window.onscroll = FloatBoth; } 
	else { setInterval('FloatBoth()', 100); } 
}
function FloatLeft() 
{
	if (Type == 'all') { document.all.FloatingAdLeft.style.pixelTop = document.body.scrollTop + topLeftGap; }
	else if (Type == 'getelement') { document.getElementById('FloatingAdLeft').style.top = window.pageYOffset + topLeftGap + 'px'; }
}

function FloatBoth()
{
	if (document.getElementById('FloatingAdRight')!=null)
	{
		FloatRight();
	}
	if (document.getElementById('FloatingAdLeft')!=null)
	{
		FloatLeft();
	}
}

function closeAd(adArea)
{
	adArea.style.display = 'none';
}