

var adRWidth=180;
 var adLWidth=805;
	function FloatTopDiv()
	{
		startX = document.body.clientWidth - adRWidth, startY = 0;
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		var d = document;
			
		if (document.body.clientWidth < 780) startX = -adRWidth;

		
		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			if(d.layers)el.style=el;
			el.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el.x = startX;
			el.y = startY;
			return el;
		}
		
		window.stayTopLeft=function()
		{
			
			if (document.documentElement && document.documentElement.scrollTop)
				var pY = ns ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY = ns ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop > 2){startY = 0} else {startY = 0};
			ftlObj.y += (pY + startY - ftlObj.y)/8;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			setTimeout("stayTopLeft()", 1);
		}
		ftlObj = ml("divAdRight");
		stayTopLeft();
	}

function FloatTopDiv2()
	{
		startX2 = document.body.clientWidth - adLWidth, startY2 =0;
		var ns2 = (navigator.appName.indexOf("Netscape") != -1);
		var d2 = document;
			
		if (document.body.clientWidth < 780) startX2 = -adLWidth;

		
		function ml2(id)
		{
			var el2=d2.getElementById?d2.getElementById(id):d2.all?d2.all[id]:d2.layers[id];
			if(d2.layers)el2.style=el2;
			el2.sP=function(x,y){this.style.left=x;this.style.top=y;};
			el2.x = startX2;
			el2.y = startY2;
			return el2;
		}
		
		window.stayTopLeft2=function()
		{
			if (document.body.clientWidth < 780)
			{
				ftlObj2.x = - 115;ftlObj2.y = 0;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY2 = ns2 ? pageYOffset : document.documentElement.scrollTop;
			else if (document.body)
				var pY2 = ns2 ? pageYOffset : document.body.scrollTop;

			if (document.body.scrollTop >2){startY2 = 0} else {startY2 =0};

			if (document.body.clientWidth >= 1024)
			{
				ftlObj2.x = 0;ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/8;	ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			else
			{			
			
			ftlObj2.x = startX2;
			ftlObj2.y += (pY2 + startY2 - ftlObj2.y)/8;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			}
			}
			setTimeout("stayTopLeft2()", 1);
		}
		
		ftlObj2 = ml2("divAdLeft");
		stayTopLeft2();
		
	}



	function ShowAdDiv()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		var objAdDivLeft = document.getElementById("divAdLeft");
		objAdDivLeft.style.display="block"
		objAdDivRight.style.display="block"
		if (document.body.clientWidth < 780)
		{
			objAdDivRight.style.left = - adRWidth;
			objAdDivLeft.style.left = - adLWidth;
		}
		else
		{
			objAdDivLeft.style.left = 0;
			objAdDivRight.style.left = document.body.clientWidth - adRWidth;
		}
		FloatTopDiv();
		//FloatTopDiv2();
	}
	//ShowAdDiv();
		
	//quang cao chay 2 ben, fix cho FF
	function setPosition(r) {
        // create by uoon
        var store = {
            ram : {
                top : 0,
                left : 0,
                right : 0,
                bottom : 0
            },
            rom : {
                element: null,
                minWidth: 0,
                minHeight: 0,
                top : null,
                left : null,
                right : null,
                bottom : null
            }
        };

        for (var i in r) {store.rom[i] = r[i];}
        
        var element = document.getElementById(store.rom.element);
        
        if (!element) {
            alert("Please check the argument: 'element'.");
            return false;
        }

        for (i in store) {element[i] = store[i];}

        element.rom.move = function() {
            
            
                if (window.innerHeight) {
                    var htmlTag = document.getElementsByTagName("html")[0];
                    var topPage = window.pageYOffset;
                    var leftPage = window.pageXOffset;
                    var rightPage = leftPage + window.innerWidth - element.offsetWidth;
                    if (htmlTag.scrollHeight > window.innerHeight) rightPage -= 17;
                    var bottomPage = topPage + window.innerHeight - element.offsetHeight;
                    if (htmlTag.scrollWidth > window.innerWidth) bottomPage -= 17;
                    var browserHeight = window.innerHeight;
                    var browserWidth = window.innerWidth;
                } else {
                    if (document.documentElement && document.documentElement.clientWidth) {
                        var topPage = document.documentElement.scrollTop;
                        var leftPage = document.documentElement.scrollLeft;
                        var browserHeight = document.documentElement.clientHeight;
                        var browserWidth = document.documentElement.clientWidth;
                    } else if (document.body) {
                        var topPage = document.body.scrollTop;
                        var leftPage = document.body.scrollLeft;
                        var browserHeight = document.body.clientHeight;
                        var browserWidth = document.body.clientWidth;
                    }
                    var rightPage = leftPage + browserWidth - element.offsetWidth;
                    var bottomPage = topPage + browserHeight - element.offsetHeight;
                }
                
                if ((browserWidth < element.rom.minWidth) || (browserHeight < element.rom.minHeight)) element.style.display = "none";
                else element.style.display = "block";
                
                element.style.position = "absolute";
            
                if (element.rom.top != null) {
                    var Condition = (Math.abs(topPage + element.rom.top - element.ram.top) < 2 || !element.firstTime);
                    if (Condition) element.ram.top = topPage + element.rom.top;
                    else element.ram.top += ((topPage + element.rom.top - element.ram.top) / 20);
                    element.style.top = element.ram.top + "px";
                }
                if (element.rom.left != null) {
                    var Condition = (Math.abs(leftPage + element.rom.left - element.ram.left) < 2 || !element.firstTime);
                    if (Condition) element.ram.left = leftPage + element.rom.left;
                    else element.ram.left += ((leftPage + element.rom.left - element.ram.left) / 20);
                    element.style.left = element.ram.left + "px";
                }
                if (element.rom.right != null) {
                    var Condition = (Math.abs(rightPage - element.rom.right - element.ram.right) < 2 || !element.firstTime);
                    if (Condition) element.ram.right = rightPage - element.rom.right;
                    else element.ram.right += ((rightPage - element.rom.right - element.ram.right) / 20);
                    element.style.left = element.ram.right + "px";
                }
                if (element.rom.bottom != null) {
                    var Condition = (Math.abs(bottomPage - element.rom.bottom - element.ram.bottom) < 2 || !element.firstTime);
                    if (Condition) element.ram.bottom = bottomPage - element.rom.bottom;
                    else element.ram.bottom += ((bottomPage - element.rom.bottom - element.ram.bottom) / 20);
                    element.style.top = element.ram.bottom + "px";
                }
                element.firstTime = true;
                setTimeout("document.getElementById('"+element.id+"').rom.move()", 20);
                
        };
        element.rom.move();
    };

setPosition({element: "divAdRight", top: 0, right:-6, minWidth: 1100});
setPosition({element: "divAdLeft", top: 0, left: 1, minWidth: 1100});
   
