﻿/*	TVN: Advertising: funciones de retraso en carga para PROGRAMAS
	Versión: 1.0.1  10-abr-2008
	Publicaciones de DIV en este sitio:
		H)	<DIV ID='Pub_BigBanner'>
		H)	<DIV ID='Pub_Eventos'>
		I)	<DIV ID='Pub_Izquierda_1'>
		I)	<DIV ID='Pub_Izquierda_2'>
		I)	<DIV ID='Pub_Izquierda_3'>
		D)	<DIV ID='Pub_Derecha_1'>
		D)	<DIV ID='Pub_Derecha_2'>
		D)	<DIV ID='Pub_Derecha_3'>
		D)	<DIV ID='Pub_Derecha_Fin'>
		F)	<DIV ID='Pub_Layer'>
		F)	<DIV ID='Pub_Layer1x1'>
*/
var phpadsbanner="";

function Ads_Publicar() {
//-----------------------
	if (!document.phpAds_used) document.phpAds_used = ',';
	Ads_PublishZone('Pub_BigBanner', 238, 728, 90);
	Ads_PublishZone('Pub_BigBanner_i', 350, 728, 90);
//	Ads_PublishZone('Pub_Eventos',    128,205,92);
//	Ads_PublishZone('Pub_Izquierda_1', 16,120,600);
//	Ads_PublishZone('Pub_Izquierda_2', 17,120,120);
//	Ads_PublishZone('Pub_Izquierda_3',120,120,120);
 //   Ads_PublishZone('Pub_Derecha_0',  214,200,30);
    Ads_PublishZone('Pub_Derecha_1',   375,200,600);
    Ads_PublishZone('Pub_Derecha_2', 239, 200, 200);
	Ads_PublishZone('Pub_Derecha_3', 240, 200, 200);
	Ads_PublishZone('Pub_Derecha_Sky', 427, 200, 600);
	Ads_PublishZone('Pub_Derecha_1_i', 442, 200, 200);
	Ads_PublishZone('Pub_Derecha_2_i', 443, 200, 200);
//	Ads_PublishZone('Pub_Derecha_Fin',140,200,356);
//	Ads_PublishZone('Pub_Layer1x1',   107,200,356);
}

function Ads_PublishZone(bannerdiv,bannerzone,bannerwidth,bannerheight){
//--- ver: 1.0.1 -------------------------------------------------------
var ads_div,ads_src="", ads_wri="";
	if(ads_div=document.getElementById(bannerdiv)){
		if(!bannerwidth){bannerwidth=120;}
		if(!bannerheight){bannerheight=600;}

		var TOfbannerJS="",IsHtml=false;
		eval("TOfbannerJS=typeof("+bannerdiv+"JS);");
		if(TOfbannerJS=="string"){
		    if ((bannerdiv=='Pub_BigBanner') && eval(bannerdiv+"JS!=''")) hayBigBanner=true;
			eval("IsHtml=(("+bannerdiv+"JS.indexOf('<script')!=-1) && ("+bannerdiv+"JS.indexOf('expandible_tvn')==-1));");
			if(IsHtml){
			    Ads_random = new String (Math.random()); Ads_random = Ads_random.substring(2,11);
				ads_div.innerHTML="<iframe framespacing=0 frameborder=0 scrolling='no' width="+bannerwidth+" height="+bannerheight+" src='/Ads_Frame.aspx?n="+Ads_random+"&amp;ad="+bannerdiv+"JS' allowtransparency='true'></iframe>";
			} else {
				eval("ads_div.innerHTML="+bannerdiv+"JS;");
			}
			if((bannerwidth==120)||(bannerwidth==200)){
                eval("ads_div.innerHTML=\""+Ads_Separador(5,5)+"\"+ads_div.innerHTML");
            }
			Ads_axblast(bannerdiv);
		}else{
			Ads_Debug("TOBanner("+bannerdiv +"JS) no es string !\n" );
		}
	}else{
		Ads_Debug("No existe DIV='" + bannerdiv +"'" );	
	}
}
function Ads_Separador(w,h){
	return "<img src='/imagenes/pix.gif' width='"+w+"' height='"+h+"'/>";
}
function Ads_axblast(id) {
//--- ver: 1.0.0 ---------
/*	Embedded Objects Active X Warning Remover for IE. A little dutch work arround
    Use: put your embed html code (flash,movie, etc) between a div tag with an id in plain html. trigger the axblast(your_div_id); */
    if (id == undefined) { return false; }
    // Rewrite code for IE browsers only
    // Get the object HTML from div
    if (document.all && document.all[''+id+'']) { html = document.all[''+id+''].innerHTML; }
    // Write the same HTML back - couldnt be easier (-.0)
    if (document.all && document.all[''+id+'']) { document.all[''+id+''].innerHTML = html; }
}
function Ads_Debug(txt){
//-----------------------
//	alert(txt);
}


/*
function getImgSize(imgSrc)
{
var newImg = new Image();
newImg.src = imgSrc;
var height = newImg.height;
var width = newImg.width;
alert ('The image size is '+width+'*'+height);
}*/

/* Cragar banners solo cuanso estén cargadas las url... 
	document.images['Ads_Pivot1'].onload="Ads_PublishZone('Pub_Izquierda_1', 16,120,600)";
	var k=0;
	while(!document.images['Ads_Pivot1'].complete && k<=1000000){k++;}
	ads_code=document.images['Ads_Pivot1'].value;
	//ads_code=Ads_GenCode(ADS_ZONE,bannerzone,true);


*/

// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}
var uri = new Object();
getURL(uri);



var f1=document.getElementById("aspnetForm");
var fileContent='';
var theLocation='';

function readFileViaApplet(n) {
 //document.f1.t1.value='Reading in progress...';
 document.ReadURL.readFile(theLocation);
 setTimeout("showFileContent()",100);
}

function showFileContent() {
 if (document.ReadURL.finished==0) {
  setTimeout("showFileContent()",100);
  return;
 }
 fileContent=document.ReadURL.fileContent;
 //document.form1.textarea1.value=fileContent;
}


function Ads_PublishZoneBeta(bannerdiv,bannerzone,bannerwidth,bannerheight){
//-------------------------------------------------------------------
var ads_div, ads_src="", ads_code="";
	if(ads_div=document.getElementById(bannerdiv)){
		if(!bannerwidth){bannerwidth=120;}
		if(!bannerheight){bannerheight=600;}

		alert("Cargar el codigo de la imagen de '"+bannerdiv +"'\n" );
		if(bannerzone==128){
			/* metodo xmlhttp */
/*			var xmlHttp = new XMLHttpRequest();
			xmlHttp.open("GET", Ads_GenSource(ADS_ZONE,bannerzone), false);
			xmlHttp.send(null);
			ads_code = xmlHttp.responseText;
*/
			var f=document.getElementById("aspnetForm");
			/* Metodo read file ...*/
			document.ReadURL.readFile(Ads_GenSource(ADS_ZONE,bannerzone));
			var k=0;
			while( document.ReadURL.finished==0 && k<=100000){k++;}
			ads_code=document.ReadURL.fileContent;

			/* metodo modificando el src */
			//document.images.toString;
			//document.images['Ads_Pivot1'].src=Ads_GenSource(ADS_ZONE,bannerzone);
/*			var k=0;
			while(!document.images['Ads_Pivot1'].complete && k<=100000){k++;}
			ads_code= document.images['Ads_Pivot1'];  */
			/*  <img src="javascript:imgbin">  */
			//document.images['Ads_Pivot1'].src= "javascript:document.images['Ads_Pivot1']";
			//ads_code=Ads_GenCode(ADS_ZONE,bannerzone,true);
		}

		var TOfbannerJS="",IsHtml=false;
		eval("TOfbannerJS=typeof("+bannerdiv+"JS);");
		if(TOfbannerJS=="string"){
			eval("IsHtml=("+bannerdiv+"JS.indexOf('<script')!=-1);");
			if(IsHtml){
				ads_div.innerHTML="<iframe framespacing=0 frameborder=0 scrolling='no' width="+bannerwidth+" height="+bannerheight+" src='/Ads_Frame.aspx?ad="+bannerdiv+"JS' allowtransparency='true'></iframe>";
			} else {
				eval("ads_div.innerHTML="+bannerdiv+"JS;");
			}
			Ads_axblast(bannerdiv);
		}else{
			if(bannerzone==128){
				//alert("cargar el innerHtml de '"+bannerdiv +"'\n" );
				//eval("ads_div.innerHTML="+ads_scr+";");
				ads_div.innerHTML=document.images['Ads_Pivot1']; //ads_code;
				//ads_div.setActive();
				//ads_div.outerHTML=ads_code;
				//ads_div.innerHTML=ads_div.innerHTML;
				//Ads_axblast(bannerdiv);
			}else{
			/*	var x=""; eval("x="+bannerdiv+"JS;");
				eval("ads_div.innerHTML="+bannerdiv+"JS;");
				Ads_axblast(bannerdiv); */
			}
		}
	}else{
		Ads_Debug("No existe DIV='" + bannerdiv +"'" );	
	}
}

var ADS_ZONE  = 1;
var ADS_BANNER= 2;
function Ads_GenSource(ads_zb,ads_id){
//---------------------------------------
var ads_src="";
	var phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
	if(ads_zb==ADS_ZONE){
		ads_src="http://x.tvn.cl/adjs.php?n="+phpAds_random+"&amp;what=zone:"+ads_id+"&amp;exclude=" + document.phpAds_used;
	}else{
		ads_src="http://x.tvn.cl/adjs.php?n="+phpAds_random+"&amp;what="+ads_id+"&amp;exclude=" + document.phpAds_used;
	}
	if(document.referrer) ads_src+="&amp;referer=" + escape(document.referrer);
	return ads_src;
}
function Ads_GenCode(ads_zb,ads_id,full){
//---------------------------------------
var ads_src="", ads_wri="";
	var phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
	if(ads_zb==ADS_ZONE){
		ads_src="http://x.tvn.cl/adjs.php?n="+phpAds_random+"&amp;what=zone:"+ads_id+"&amp;exclude=" + document.phpAds_used;
	}else{
		ads_src="http://x.tvn.cl/adjs.php?n="+phpAds_random+"&amp;what="+ads_id+"&amp;exclude=" + document.phpAds_used;
	}
	if(document.referrer) ads_src+="&amp;referer=" + escape(document.referrer);

	ads_wri="document.write(\"<\"+\"script language='javascript' type='text/javascript' src='"+ads_src+"'><\" + \"/script>\");";

	if(full){
		var pre="<sc"+"ript language='javascript' type='text/javascript'>\n";
//				"if (!document.phpAds_used) document.phpAds_used = ',';\n"+
//				"phpAds_random=new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);\n";
		var post="</sc"+"ript>\n"
		//ads_wri+="<noscript><a href='http://x.tvn.cl/adclick.php?n="+phpAds_random+"' target='_blank'><img src='http://x.tvn.cl/adview.php?what=zone:"+ads_id+"&amp;n="+phpAds_random+"' border='0' alt=''></a></noscript>";
		return pre+ads_wri+post;
	}
	return ads_wri;
}

function Ads_PushZone(bannerdiv,bannerzone,bannerwidth,bannerheight){
//-------------------------------------------------------------------
var ads_div, ads_src="", ads_wri="";
	if(ads_div=document.getElementById(bannerdiv)){
		document.write(Ads_GenCode(ADS_ZONE,bannerzone,true));
	}else{
		Ads_Debug("No existe DIV='" + bannerdiv +"'" );	
	}
}

function Pub_PushBanner(bannerdiv,bannerwhat,bannerwidth,bannerheight){
//--- ver: 1.0.0 beta -------------------------------------------------
var ads_div,ads_src="", ads_wri="";
	if(ads_div=document.getElementById(bannerdiv)){
		document.write(Ads_GenCode(ADS_BANNER,bannerwhat,true));
	}else{
		Ads_Debug("No existe DIV='" + bannerdiv +"'" );	
	}
}

//var Pub_EventosJS = Ads_PushZone('Pub_Eventos',128,0,0);


//	Preparar lo que se publica en este sitio
//	--------------------------------------------------------------------------------------
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write ("&amp;what=zone:238");
document.write ("&amp;bannervar=Pub_BigBannerJS");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

phpAds_random = new String(Math.random()); phpAds_random = phpAds_random.substring(2, 11);
document.write("<" + "script language='JavaScript' type='text/javascript' src='");
document.write("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write("&amp;what=zone:350");
document.write("&amp;bannervar=Pub_BigBanner_iJS");
document.write("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

//phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
//document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
//document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
//document.write ("&amp;what=zone:128");
//document.write ("&amp;bannervar=Pub_EventosJS");
//document.write ("&amp;exclude=" + document.phpAds_used);
//if (document.referrer)
//    document.write ("&amp;referer=" + escape(document.referrer));
//document.write ("'><" + "/script>");
// 

//phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
//document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
//document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
//document.write ("&amp;what=zone:16");
//document.write ("&amp;bannervar=Pub_Izquierda_1JS");
//document.write ("&amp;exclude=" + document.phpAds_used);
//if (document.referrer)
//    document.write ("&amp;referer=" + escape(document.referrer));
//document.write ("'><" + "/script>");

//phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
//document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
//document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
//document.write ("&amp;what=zone:17");
//document.write ("&amp;bannervar=Pub_Izquierda_2JS");
//document.write ("&amp;exclude=" + document.phpAds_used);
//if (document.referrer)
//    document.write ("&amp;referer=" + escape(document.referrer));
//document.write ("'><" + "/script>");

//phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
//document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
//document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
//document.write ("&amp;what=zone:214");
//document.write ("&amp;bannervar=Pub_Derecha_0JS");
//document.write ("&amp;exclude=" + document.phpAds_used);
//if (document.referrer)
//    document.write ("&amp;referer=" + escape(document.referrer));
//document.write ("'><" + "/script>");



phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write ("&amp;what=zone:375");
document.write ("&amp;bannervar=Pub_Derecha_1JS");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");

phpAds_random = new String(Math.random()); phpAds_random = phpAds_random.substring(2, 11);
document.write("<" + "script language='JavaScript' type='text/javascript' src='");
document.write("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write("&amp;what=zone:427");
document.write("&amp;bannervar=Pub_Derecha_SkyJS");
document.write("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write ("&amp;what=zone:239");
document.write ("&amp;bannervar=Pub_Derecha_2JS");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

phpAds_random = new String(Math.random()); phpAds_random = phpAds_random.substring(2, 11);
document.write("<" + "script language='JavaScript' type='text/javascript' src='");
document.write("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write("&amp;what=zone:442");
document.write("&amp;bannervar=Pub_Derecha_1_iJS");
document.write("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

phpAds_random = new String(Math.random()); phpAds_random = phpAds_random.substring(2, 11);
document.write("<" + "script language='JavaScript' type='text/javascript' src='");
document.write("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write("&amp;what=zone:443");
document.write("&amp;bannervar=Pub_Derecha_2_iJS");
document.write("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write("&amp;referer=" + escape(document.referrer));
document.write("'><" + "/script>");

phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write ("&amp;what=zone:240");
document.write ("&amp;bannervar=Pub_Derecha_3JS");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");

//phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
//document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
//document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
//document.write ("&amp;what=zone:140");
//document.write ("&amp;bannervar=Pub_Derecha_FinJS");
//document.write ("&amp;exclude=" + document.phpAds_used);
//if (document.referrer)
//    document.write ("&amp;referer=" + escape(document.referrer));
//document.write ("'><" + "/script>");

/* Uso Opcional según requerimientos */
/*
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://x.tvn.cl/adjstvn.php?n=" + phpAds_random);
document.write ("&amp;what=zone:126");
document.write ("&amp;bannervar=Pub_Layer1x1JS");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
*/


/*
<table width=302 height=102 cellpadding=0 cellspacing=0 bordercolor=red border=1><tr><td>
<img src='/imagenes/pixb.gif' name='Ads_Pivot1' id='Ads_Pivot1' width=400 height=100 alt='' border=1><br />
<applet name=ReadURL code=ReadURL.class width=400 height=40></applet>
</td></tr></table>
<script language=javascript type="text/javascript">
	document.images['Ads_Pivot1'].src=Ads_GenSource(ADS_ZONE,128);
</script>
*/