﻿// var AC_FL_RunContent = 0; 
// var DetectFlashVer = 0; 

var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 115;


//  será acaso mejor usar:  getQSValue(param)  ?????
var params = getLETioParams();
var gamsrv = getParam(params, "gamsrv"); // "ca-pub-9536814112534437";
var gamslt = getParam(params, "gamslt"); // "La_Mega_-_Bogota";
var gs = getParam(params, "gs");

function include_dom(script_filename) {
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);
    return false;
}
// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006 www.cryer.co.uk
function IncludeJavaScript(jsFile) {
    //document.write('<script type="text/javascript" src="' + jsFile + '"></script>'); 
    document.write(unescape("%3Cscript src='" + jsFile + "' type='text/javascript'%3E%3C/script%3E"));
}
// IncludeJavaScript('scripts/LETio_RunActiveContent.js');
// IncludeJavaScript('./LETio_XT.js');

IncludeJavaScript('http://www.letio.com/mp/v1.0/LETio_RunActiveContent.js');
IncludeJavaScript('http://www.letio.com/mp/v1.0/LETio_ActiveX.js');
IncludeJavaScript('http://www.letio.com/mp/v1.2/LETio_XT.js');
IncludeJavaScript('http://partner.googleadservices.com/gampad/google_service.js');
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
IncludeJavaScript(gaJsHost + "google-analytics.com/ga.js");




// include_dom('http://www.letio.com/mp/v1.0/LETio_RunActiveContent.js');
//  include_dom('http://www.letio.com/mp/v1.0/LETio_ActiveX.js');


var LETioTrackers = new Array();
function getLETioTracker(StationTrackerCode) {
    if (LETioTrackers[StationTrackerCode] == null) {
        LETioTrackers[StationTrackerCode] = _gat._getTracker(StationTrackerCode);
        LETioTrackers[StationTrackerCode]._initData();
        LETioTrackers[StationTrackerCode]._setSessionTimeout("18000");
    }
    return LETioTrackers[StationTrackerCode];
}
function StationTracker(StationTrackerCode, section) {
    var LETioTracker = getLETioTracker(StationTrackerCode);
    LETioTracker._trackPageview(section);
}
function EventTracker(StationTrackerCode, category, action, opt_label, opt_value) {
    var LETioTracker = getLETioTracker(StationTrackerCode);
    LETioTracker._trackEvent(category, action, opt_label, opt_value)
}

var LETio_winRef = null;
function LETio_flotante(width, height, url) {
    try { LETio_winRef.close() } catch (e) { }
    LETio_winRef = window.open(url,
             'LETioWindow', 'status=no,toolbar=no,scrollbars=no,titlebar=yes,menubar=no,resizable=yes,' +
		     'width=' + width + ',height=' + height + ',directories=no,location=no,top=50,left=100');
}

function LETio_Direct(player, left, top, width, height, idPlayer, flashvars, allowfullscreen) {
    if (player == "miniRadio") {
        var params = getLETioParams();
        if (params != null)
            flashvars = params; // window.location.search.replace("ltgs", "gs"); // "gs=" + gs;
    }
    document.write(getText_LETio_private(player, left, top, width, height, idPlayer, flashvars, allowfullscreen));
}


var divLP_MiniRadio = "LETio";
var LETio_w = 400;
var LETio_h = 341;
var LETio_fs = true;
var LETio_div = "LETio";
var LETio_player = "miniRadio";
var LETio_idPlayer = "ML";
var LETio_flashvars = "";

function LETio_divLP(player, divLP, divUF, left, top, width, height, idPlayer, flashvars, allowfullscreen) {
    LETio_flashvars = flashvars;
    LETio_w = width;
    LETio_h = height;
    LETio_fs = allowfullscreen;
    LETio_div = divLP;
    LETio_player = player;
    LETio_idPlayer = idPlayer; // Es usado en LETio_XT.js    
    if (LETio_player == "miniRadio") {
        divLP_MiniRadio = LETio_div;
        var params = getLETioParams();
        if (params != null)
            flashvars = params;
    }
    var obj = document.getElementById(divLP);
    obj.innerHTML = getHTMLcode(idPlayer, flashvars);
    try {
        var obj2 = document.getElementById(divUF);
        obj2.innerHTML = "";
        obj2.style.visibility = "hidden";
    } catch (e) { }
}

function getHTMLcode(idPlayer, flashvars) {
    LETio_flashvars = flashvars;
    var HTMLcode = "";
    var jw = false;
    isEsc = (document.URL.toLowerCase().indexOf('chemos.com', 0) > 0);
    isCol = (document.URL.toLowerCase().indexOf('mbia.com', 0) > 0) || (document.URL.toLowerCase().indexOf('mbiaya.com', 0) > 0);    
    if (LETio_player == "miniRadio") {
        gs = getParam(flashvars, "gs");
        if ((gs >= 9000 && gs <= 9060)|| (gs == 7120)) 
            HTMLcode = getText_JW(gs);
        else if ((isCol)
                  && ((gs != 5070) && (gs != 5088))  //se escluyen las de colombia.com
                  && ((gs < 7300) || (gs > 7399))    //se excluyen las de cdr
                 )
            HTMLcode = getText_JW(gs);
        else
            HTMLcode = getText_LETio_private(LETio_player, 0, 0, LETio_w, LETio_h, idPlayer, flashvars, LETio_fs);
    }
    else
        HTMLcode = getText_LETio_private(LETio_player, 0, 0, LETio_w, LETio_h, idPlayer, flashvars, LETio_fs);
    return getLETio_Sign(flashvars) + HTMLcode;
}
function jsPlay(idPlayer, flashvars) {
    LETio_flashvars = flashvars;
    gs = getParam(flashvars, "gs");
    isEsc = (document.URL.toLowerCase().indexOf('chemos.com', 0) > 0);
    isCol = (document.URL.toLowerCase().indexOf('mbia.com', 0) > 0) || (document.URL.toLowerCase().indexOf('mbiaya.com', 0) > 0);
    if (((isCol) && ((gs != 5070) && (gs != 5088))   )
       || (gs >= 9000 && gs <= 9060) || (gs == 7120)) {
        HTMLcode = getText_JW(gs);
        var obj = document.getElementById(LETio_div);
        obj.innerHTML = HTMLcode;
        return;
    }
    // call same method at flash ExternalInterface callback
    //      var o=document.getElementById(idPlayer);
    var o = getFlashMovie(idPlayer); //.jsPlay(flashvars));
    if (o != null && typeof (obj) != "undefined")
        o.jsPlay(flashvars);
    else {
        HTMLcode = getHTMLcode(idPlayer, flashvars);
        var obj = document.getElementById(LETio_div);
        obj.innerHTML = HTMLcode;
    }
    //      alert(o.id);

    //      var obj=getFlashMovie(idPlayer);
    //       if(typeof(obj) != "undefined"))          
    //          obj.jsPlay(flashvars);
    //       else
    //           alert("No encuentro la movie con ese name");
}
function getText_LETio_private(player, left, top, width, height, idPlayer, flashvars, allowfullscreen) {
    LETio_flashvars = flashvars;
    var cmd = 'wmode';
    var cmdvalue = 'transparent';
    if (allowfullscreen) {
        cmd = 'allowfullscreen';
        cmdvalue = 'true';
    }
    if (player == "SMP") {
        var v = getParam(flashvars, "v");
        var ap = (getParam(flashvars, "ap") == "0" ? "false" : "true");
        LETio_flashvars =  "autoPlay=" + ap +
        "&src=rtmp://r34.letio.com/oflaDemo/"+v;
    } 
    var codplayer =
  AC_FL_RunContent(
    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
    'WIDTH', width,
    'HEIGHT', height,
    'src', 'http://www.letio.com/mp/' + player,
    'movie', 'http://www.letio.com/mp/' + player,
    'allowScriptAccess', 'always',
    'name', idPlayer,
    'id', idPlayer,
    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    'quality', 'best',
    'flashvars', LETio_flashvars + '&w=' + width + "&h=" + height,
    cmd, cmdvalue,
    'bgcolor', '#000000'
    );
    if (top == '' || left == '')
        return codplayer;

    var retorno =
    "<div style='top:" + top + "px; left:" + left + "px; width:" + width + "px; height:" + height + "px; position:absolute; display:block; '>"
  + codplayer
  + "</div>";

    return retorno;
    //   AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','100','height','22','src','button1','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','button1' ); //end AC code
}

var LETioaudiowinRef = null;
function LETio_popup_player(width, height, url) {
    try { LETioaudiowinRef.close() } catch (e) { }
    LETioaudiowinRef = window.open(url,
             'LETioAudioWindow', 'status=no,toolbar=no,scrollbars=no,titlebar=yes,menubar=no,resizable=yes,' +
		     'width=' + width + ',height=' + height + ',directories=no,location=no,top=50,left=200');
}


function getFlashMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}

function jsChangeDisplay(width, height, url) {
    var obj = document.getElementById(divLP_MiniRadio + "_Display");
    var left = (336 - width) / 2;
    var top = (280 - height) / 2;
    if (obj != null)
        obj.innerHTML =
    //'<ins style="display:inline-table;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px"' +
    //'<ins style="display:block;border:none;height:250px;margin:0;padding:0;position:relative;visibility:visible;width:300px"' +
'<iframe allowtransparency="true" frameborder="0" width="' + width + '" height="' + height + '" hspace="0" vspace="0" ' +
'        marginheight="0" marginwidth="0" scrolling="no" style="left:' + left + ';position:relative;top:' + top + '"' +
'        id="LETio_Display_iFrame" ' +
'        src="' + url + '">' +
'</iframe>';
    //'</ins>' +
    //'</ins>';
}


/*
var audiowinRef=null;
function player_flotante(width,height,url)
{
try{
var obj=document.getElementById("divPlayer");
obj.innerHTML="<br>"; } catch (e) {}
try {audiowinRef.close()} catch (e) {}
audiowinRef = window.open(url, 
'audioWindow', 'status=no,toolbar=no,scrollbars=no,titlebar=yes,menubar=no,resizable=yes,'+
'width='+width+',height='+height+',directories=no,location=no,top=50,left=200');
}
function player_embedded(width,height,url)
{
var obj=document.getElementById("divPlayer");
try {audiowinRef.close()} catch (e) {}
obj.innerHTML=	
"<iframe id='frameplayer' width="+width+" height="+height+" scrolling='no' frameborder='0'  ALLOWTRANSPARENCY='true'>"+
"</iframe>"; 	
var obj2=document.getElementById("frameplayer");
obj2.src=url;
}
*/







function LETio_WMP_RadioPlayer(idPlayer, URLStream) {
    document.write(getText_WMP_RadioPlayer(idPlayer, URLStream));
}
function LETio_divWMPRadioPlayer(divLETioPlayer, idPlayer, URLStream) {
    var obj = document.getElementById(divLETioPlayer);
    obj.innerHTML = getText_WMP_RadioPlayer(idPlayer, URLStream);
    obj = null;
}

function getText_WMP_RadioPlayer(idPlayer, URLStream) {
    return AC_AX_RunContent('id', idPlayer, 'style', 'LEFT: 0px; TOP: 0px', 'type',
'application/x-mplayer2', 'height', '49', 'standby', 'Loading Microsoft Windows Media Player components...',
'width', '350', 'align', 'baseline', 'border', '0', 'classid', 'CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95',
'name', 'MediaPlayer', 'viewastext', 'VIEWASTEXT',
'autostart', '1', 'audiostream', '-1', 'autosize', '0', 'animationatstart', '0', 'allowscan', '-1',
'allowchangedisplaysize', '-1', 'autorewind', '0', 'balance', '0', 'baseurl', '',
'bufferingtime', '0', 'captioningid', '', 'clicktoplay', '0', 'cursortype', '0',
'currentposition', '-1', 'currentmarker', '0', 'defaultframe', 'datawindow',
'displaybackcolor', '0', 'displayforecolor', '16777215', 'displaymode', '0', 'displaysize', '4',
'enabled', '-1', 'enablecontextmenu', '0', 'enablepositioncontrols', '-1', 'enablefullscreencontrols', '0',
'enabletracker', '-1',
'filename', URLStream,
'invokeurls', '-1', 'language', '-1', 'mute', '0', 'playcount', '1', 'previewmode', '0',
'rate', '1', 'samilang', '', 'samistyle', '', 'samifilename', '', 'selectionstart', '-1', 'selectionend', '-1',
'sendopenstatechangeevents', '-1', 'sendwarningevents', '-1', 'senderrorevents', '-1',
'sendkeyboardevents', '0', 'sendmouseclickevents', '0', 'sendmousemoveevents', '0',
'sendplaystatechangeevents', '1', 'showcaptioning', '0', 'showcontrols', '1',
'showaudiocontrols', '1', 'showdisplay', '0', 'showgotobar', '0', 'showpositioncontrols', '1',
'showstatusbar', '-1', 'showtracker', '0', 'transparentatstart', '0', 'videoborderwidth', '0', 'videobordercolor', '0', 'videoborder3d', '0',
'volume', '1', 'windowlessvideo', '0'); //end AC code
}

function getLETioParams() {
    params = null;
    if (getSharpValue('ltgs') != null)
        params = getSharpParams();
    else if (getSharpValue('gs') != null)
        params = getSharpParams();
    else if (getQueryValue('ltgs') != null)
        params = getQueryParams();
    else if (getQueryValue('gs') != null)
        params = getQueryParams();
    if (params != null)
        params = params.replace('ltgs', 'gs');
    return params;
}
function getQSValue(ji) {
    var qsValue = getSharpValue(ji);
    if (qsValue == null)
        qsValue = getQueryValue(ji);
    return qsValue;
}
function getQueryValue(ji) {
    hu = getQueryParams();
    return getParam(hu, ji);
}
function getQueryParams() {
    return window.location.search.substring(1);
}
function getSharpValue(ji) {
    hu = getSharpParams();
    return getParam(hu, ji);
}
function getSharpParams() {
    hu = window.location.hash;
    if (hu == null)
        return null;
    du = hu.split("?");
    if (du.length <= 1)
        return null;
    return du[1];
}

function getParam(hu, ji) {
    if (hu == null)
        return null;
    gy = hu.split("&");
    for (i = 0; i < gy.length; i++) {
        ft = gy[i].split("=");
        if (ft.length > 1 && ft[0] == ji)
            return ft[1];
    }
    return null;
}

function addBookmark(title, url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else if (document.all) {
        window.external.AddFavorite(url, title);
    } else if (window.opera && window.print) {
        return true;
    }
}


function setasHome(url) {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(url);
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("Dale Ok y luego presiona Ctrl-D para que seamos tu página de inicio");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', url);
    }
}

        