function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//--------- pla : tv larger-box ---------
function clickTabLargerBox(tab){
	if(tab=='p'){clickPrevLargerBox();return false;}
	else if(tab=='n'){clickNextLargerBox();return false;}

	var  zoneId=0;
	if(tab==1){ zoneId=363;}
	else if(tab==2){ zoneId=364;}
	else if(tab==3){ zoneId=365;}
	else if(tab==4){ zoneId=366;}
	else if(tab==5){ zoneId=367;}
	else if(tab==999){ zoneId=459;} //test
	else {  zoneId=368;}
	
	/*$.get('/banner_ads/ads_banner.php', { 'n':phpAds_random, 'what':'zone:'+zoneId,'target':'_blank','exclude':','}, function(data){
		$('#show-larger-box').html(data);
	});*/
	
	$('#show-larger-box').attr('src','/bannercode/adjs.php?n='+phpAds_random+'&zone=' +zoneId);	
	
	$('.larger-box li img').removeClass('select');
	$('.larger-box li#larger-menu'+tab+' img').addClass('select');
	
	nowTabLargerBox=tab;
}
function clickNextLargerBox(){
	var i=nowTabLargerBox+1;
	if(i>6)i=1;
	clickTabLargerBox(i);
}
function clickPrevLargerBox(){
	var i=nowTabLargerBox-1;
	if(i<1)i=6;
	clickTabLargerBox(i);
}
//--------- pla : end tv larger-box ---------

//----------- pla : tv banner ------------
var nowTabBannerTv=0;

function bannerDekdee(tID) { 
	var req = null; 
	var zoneBanner=0;
	if(tID==1) zoneBanner = 276 ;
	else if (tID==2) zoneBanner = 277 ;
	else if (tID==3) zoneBanner =  278;
	else  zoneBanner = 279 ;
	
		if(window.XMLHttpRequest){ 
				req = new XMLHttpRequest(); // สำหรับใช้ใน Firefox
		}else if (window.ActiveXObject){
				req = new ActiveXObject("Microsoft.XMLHTTP"); // สำหรับใช้ใน IE
		}

	req.onreadystatechange = function(){ 
		if(req.readyState == 4){
				document.getElementById('showBanner').innerHTML =req.responseText;
		}
	};

	var str = Math.random();

	var url="/banner_ads/ads_banner.php?n="+phpAds_random+"&what=zone:"+zoneBanner+"&target=_blank&exclude=,";
	req.open("GET",url, true); //สร้าง connection
	req.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
	req.send(null);
}

function hiddenTab(tID){
	var tabObj = document.getElementById('showBanner');
	var imgTab = document.getElementById('imgTab_'+tID);
	if (tabObj) {
		imgTab.className='';
	}
}

function showTab(tID){
	nowTabBannerTv=tID;
	var tabObj = document.getElementById('showBanner');
	var imgTab = document.getElementById('imgTab_'+tID);
	
	bannerDekdee(tID);
	imgTab.className='b-m-red';
	return false;
}

function clickTab(tID){
	for(var i=1;i<=4;i++){
		if(i != tID) hiddenTab(i);
	}
	return showTab(tID);
}

function prevTab(){
	nowTabBannerTv=nowTabBannerTv-1;
	if(nowTabBannerTv==0)nowTabBannerTv=4;
	return clickTab(nowTabBannerTv);
}

function nextTab(){
	nowTabBannerTv=nowTabBannerTv+1;
	if(nowTabBannerTv==5)nowTabBannerTv=1;
	return clickTab(nowTabBannerTv);
}
//-------- pla :end  tv banner ---------


//------ pla : box admission reality ------
var reality_blog='';
var reality_clip='';

function contentBlogReality(){
	var reality_blog_tab=document.getElementById('reality_blog_tab');
	var reality_clip_tab=document.getElementById('reality_clip_tab');
	var ardaily = document.getElementById('ardaily');
	ardaily.innerHTML=reality_blog;
	ardaily.className='';
	reality_blog_tab.className='active';
	reality_clip_tab.className='';
}

function contentClipReality(){
	var reality_blog_tab=document.getElementById('reality_blog_tab');
	var reality_clip_tab=document.getElementById('reality_clip_tab');
	var ardaily = document.getElementById('ardaily');
	ardaily.innerHTML=reality_clip;
	ardaily.className='arhotclip';
	reality_blog_tab.className='';
	reality_clip_tab.className='active';
}
//--- pla : end box admission reality ----
/* [START] Script โฆษณา สำคัญมาก ห้ามเอาออก  */
function ddAds( width , height , src , type , top , left )
{
	$( document ).ready( function(){
		ddAdsDo( width , height , src , type , top , left );
	});
}

var id_int = 0;

function ddAdsDo( width , height , src , type , top , left )
{
	var html = '<div id="dekd_ads"><iframe width="' + width + '" height="' + height + '" marginwidth="0" marginheight="0" hspace="0" frameborder="0" scrolling="no" src="' + src + '" id="dekd_ads_i" name="dekd_ads_i" ALLOWTRANSPARENCY="true"></iframe></div>';
	if( type == 'corner' )
	{
		$('body').append( html );
		if( $.browser.msie && $.browser.version == '6.0' )
		{
			$('#dekd_ads').attr( 'style' , 'position:absolute;left:0;bottom:0;z-index:10000' );
			id_int = setInterval( function(){
				$('#dekd_ads').css('bottom', "0px");
			}, 10);
		}
		else
			$('#dekd_ads').attr( 'style' , 'position:fixed;left:0;bottom:0;z-index:10000' );
		if( src != '/note/banner/cnc_corner_ads_2.html' )
			$('#dekd_ads').prepend('<a href="#" style="font-size: 13px; text-decoration: none; color: #000; padding: 5px; width: 51px; display: block; background-color:#FFF; text-shadow:1px 2px 0 #CCC; border-radius:3px 3px 0 0" onclick="return closeAds();">Close [x]</a>');
		if( src == '/note/banner/happy_lucky_draw_corner.html' )
		{
			$('#dekd_ads_i').live('mouseover',function(){
				$('#dekd_ads_i').width('600px');
				$('#dekd_ads_i').height('200px');
			});
			$('#dekd_ads_i').live('mouseout',function(){
				$('#dekd_ads_i').width(width + 'px');
				$('#dekd_ads_i').height(height + 'px');
			});
		}
	}	
	else
	{
		$('#wrapper').append( html );
		var width_wrapper = $('#wrapper').width() / 2;
		if( type != 'fix' )
		{
			id_int = setInterval( function(){
				var tTop = $(window).scrollTop() + ( ( $(window).height() /2 ) - ( height / 2 ) );
				tTop = (tTop < 23)? 23 : tTop;
				$('#dekd_ads').css('top', tTop + "px");
			}, 10);
			$('#dekd_ads').attr( 'style' , 'position:absolute;left:' + ( width_wrapper - ( width / 2 ) ) + 'px;top:50px;z-index:10000' );
			if( type != 'floating_noclose' )
				$('#dekd_ads').prepend('<div style="text-align: right; clear: both;"><a href="#" style="text-decoration: none; float: right; padding: 5px 8px; font-size: 14px; display: inline-block; -moz-border-radius: 5px 5px 0 0; -webkit-border-radius: 5px 5px 0 0; border-bottom: 1px solid rgb(238, 238, 238); background-color: rgb(255, 255, 255); color: red;text-shadow:1px 1px 1px #CCC;" onclick="return closeAds();">Close [x]</a>');
		}
		else
		{
			if( src == '/note/banner/coke_takeover.html' )
			{
				$('#dekd_ads').prepend('<div style="text-align: right; clear: both;"><a href="#" style="text-decoration: none; float: right; padding: 5px 8px; font-size: 14px; display: inline-block; -moz-border-radius: 5px 5px 0 0; -webkit-border-radius: 5px 5px 0 0; border-bottom: 1px solid rgb(238, 238, 238); background-color: rgb(255, 255, 255); color: red;text-shadow:1px 1px 1px #CCC;" onclick="return closeAds();">Close [x]</a>');
				setTimeout("closeAds()",60000);
			}
			else if( src == '/note/banner/pepsi_900_500_takeover.html' )
			{
				$('#dekd_ads').append('<div style="clear: both; text-align: center;"><a onclick="return closeAds();" style="text-decoration: none; display: inline-block; border-bottom: 1px solid rgb(238, 238, 238); -moz-border-radius: 0pt 0pt 5px 5px; -webkit-border-radius: 0 0 5px 5px; border-radius: 0 0 5px 5px; background-color: rgb(2, 64, 138); color: rgb(255, 255, 255); font-size: 16px; padding: 8px 11px;" href="#">Close [x]</a></div>');
				//setTimeout("closeAds()",60000);
			}
			if( src == '/note/banner/scool_sim_takeover.html' )
				$('#dekd_ads').attr( 'style' , 'position:absolute;right:' + Number( left ) + 'px;top:' + Number( top ) + 'px;z-index:10000' );
			else
				$('#dekd_ads').attr( 'style' , 'position:absolute;left:' + Number( left ) + 'px;top:' + Number( top ) + 'px;z-index:10000' );
		}
		if( type == 'floating' || type == 'floating_noclose' )
			$('#dekd_ads').css( 'border' ,  '1px solid #000' ).css( 'background-color' ,  '#FFF' ).css( 'width' , width + 'px' );
	}
} 

function closeAds()
{
	$('#dekd_ads').remove();
	clearInterval( id_int );
	return false;
}
/* [END] Script โฆษณา สำคัญมาก ห้ามเอาออก  */
