﻿// JScript File
String.prototype.replaceAll = function(
strTarget, // The substring you want to replace
strSubString // The string you want to replace in.
 ){
 var strText = this;
 var intIndexOfMatch = strText.indexOf( strTarget );
  
 // Keep looping while an instance of the target string
 // still exists in the string.
 while (intIndexOfMatch != -1){
 // Relace out the current instance.
 strText = strText.replace( strTarget, strSubString )
  
 // Get the index of any next matching substring.
 intIndexOfMatch = strText.indexOf( strTarget );
 }
  
 // Return the updated string with ALL the target strings
 // replaced out with the new substring.
 return( strText );
 }

function getImgParam(str,strParamName){
    var strReturn = "";
    var aQueryString = str.split(" ");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      if (
        aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
        var aParam = aQueryString[iParam].split("'");
        strReturn = aParam[1];
        break;
      }
    }  
  return unescape(strReturn);
}

function getVideo() {
    var listado = AdsVideo.split("><");
    if (listado.length==6) {   
        return getImgParam(listado[1].replaceAll('<','').replaceAll('>',''),'src');
    } else {
        return getImgParam(listado[0].replaceAll('<','').replaceAll('>',''),'src');
    }
}

function getLink() {
    var listado = AdsVideo.split("><");
    if (listado.length==6) {
        return getImgParam(listado[0].replaceAll('<','').replaceAll('>','').replaceAll('&amp;','&'),'href');
    } else {
        return '';
    }
}

function getLog() {
    if (AdsVideo != "") {
        var listado = AdsVideo.split("><");
        if (listado.length == 6) {
            return getImgParam(listado[4].replaceAll('<', '').replaceAll('>', '').replaceAll('&amp;', '&'), 'src');
        } else {
            return getImgParam(listado[2].replaceAll('<', '').replaceAll('>', '').replaceAll('&amp;', '&'), 'src');
        }
    }
}



if (!document.phpAds_used) document.phpAds_used = ',';

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:"+ phpAds_zone);
document.write ("&amp;bannervar="+ phpAds_banner);
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referrer)
    document.write ("&amp;referer=" + escape(document.referrer));
document.write ("'><" + "/script>")