//////////////////////////////////////////////////////////////////
// BEGIN
//////////////////////////////////////////////////////////////////

// set the width of the ad banner
	window.onresize=ShowAdDiv;	
	function FloatTopDiv()
	{
/////////////////////////////////////////////
// Initial X and Y position of the banners !
/////////////////////////////////////////////
		startLX = ((document.body.clientWidth -1000)/2) - 107 , startLY = 0;
		startRX = ((document.body.clientWidth)/2) + 502 , startRY = 0;
		//startLX = ((document.body.clientWidth -780)/2) - 111 , startLY = 0;
		//startRX = ((document.body.clientWidth)/2) + 391 , startRY = 0;
		var d = document;
		function ml(id)
		{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			//alert(d.getElementById(id).style.left);
			el.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';};
			el.x = startRX;
			el.y = startRY;
			return el;
		}
		function m2(id)
		{
			var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			//alert(d.getElementById(id).style.left);
			e2.sP=function(x,y){this.style.left=x + 'px';this.style.top=y + 'px';};
			e2.x = startLX;
			e2.y = startLY;
			return e2;
		}
		window.stayTopLeft=function()
		{
			if (document.documentElement && document.documentElement.scrollTop)
				var pY =  document.documentElement.scrollTop;
			else if (document.body)
				var pY =  document.body.scrollTop;
			if (document.body.scrollTop > 30){startLY = 3;startRY = 3;} else {startLY = 0;startRY = 0;};
			ftlObj.y += (pY+startRY-ftlObj.y)/16;
			ftlObj.sP(ftlObj.x, ftlObj.y);
			ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
			ftlObj2.sP(ftlObj2.x, ftlObj2.y);
			setTimeout("stayTopLeft()", 10);
			//alert(ftlObj2.x);
			//alert(ftlObj2.y);
		}
		ftlObj = ml("divAdRight");
		ftlObj2 = m2("divAdLeft");
		stayTopLeft();
	}
	
	function ShowAdDiv()
	{
		var objAdDivRight = document.getElementById("divAdRight");
		var objAdDivLeft = document.getElementById("divAdLeft");		
		
		if (document.body.clientWidth < 1025)
		{
		    objAdDivRight.style.display = "none";
			objAdDivLeft.style.display = "none";
		}
		else
		{
			objAdDivRight.style.display = "block";
			objAdDivLeft.style.display = "block";
			FloatTopDiv();
		}
	}    
    function autoResize(id){
    var newheight;
    var newwidth;
    if(document.getElementById){
        newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
        newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
    }
        document.getElementById(id).height= (newheight) + "px";
        document.getElementById(id).width= (newwidth) + "px";
    }
    function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function playth(url, myimg, autostart) {
    var so = new SWFObject('js/player.swf', 'mpl', '500', '400', '9');
    so.addParam('allowfullscreen', 'true');
    so.addParam('allowscriptaccess', 'always');
    so.addVariable('stretching', 'fill');
    so.addVariable('autostart', 'fasle');
    so.addParam('wmode', 'opaque');
    if (url.indexOf('rtmp') > -1) {
        so.addVariable('streamer', url.substring(0, url.lastIndexOf("/") + 1));
        so.addVariable('file', url.substring(url.lastIndexOf("/") + 1));
    } else
        so.addVariable('file', url);

    so.addVariable('stretching', 'fill');
    so.addVariable('image', myimg);
    so.addVariable('controlbar', 'bottom');
    so.addVariable('autostart', 'fasle');
    so.write('colBigImage'); 
} 
function playpt(url, myimg, autostart) {
    var so = new SWFObject('js/player.swf', 'mpl', '500', '400', '9');
    so.addParam('allowfullscreen', 'true');
    so.addParam('allowscriptaccess', 'always');
    so.addVariable('stretching', 'fill');
    so.addVariable('autostart', 'fasle');
    so.addParam('wmode', 'opaque');
    if (url.indexOf('rtmp') > -1) {
        so.addVariable('streamer', url.substring(0, url.lastIndexOf("/") + 1));
        so.addVariable('file', url.substring(url.lastIndexOf("/") + 1));
    } else
        so.addVariable('file', url);

    so.addVariable('stretching', 'fill');
    so.addVariable('image', myimg);
    so.addVariable('controlbar', 'bottom');
    so.addVariable('autostart', 'fasle');
    so.write('colBigImage1'); 
} 
function loadthtt()
{
	document.getElementById("divthtt").style.display = "block";	
	document.getElementById("divpttt").style.display = "none";	
	playth('rtmp://123.30.84.242/live/tntv', 'images/thainguyentv.gif', false);
}
function loadpttt()
{	
	document.getElementById("divpttt").style.display = "block";	
	document.getElementById("divthtt").style.display = "none";	
	playpt('rtmp://123.30.84.242/live/tntv', 'images/thainguyentv.gif', false);
}
//////////////////////////////////////////////////////////////////
// END
//////////////////////////////////////////////////////////////////
