/*<span id="tcm:18-490830_tcm:18-372849-32">*/

var sBAN_AntScroll = '';
var sBAN_AntResize = '';
var bBAN_EsIE6 = false;

try {
    bBAN_EsIE6 = !(window.XMLHttpRequest);
} catch (err) {
    bBAN_EsIE6 = false;
}

//******************************************************************************
// Tambien las fuciones necesarias para detectar si el plugin de flash         *
// requerido está instalado                                                    *
// --------------------------------------------------------------------------- *
// Flash Player Version Detection - Rev 1.5                                    *
// Detect Client Browser type                                                  *
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. *
//******************************************************************************
if (!hasRequestedVersion) {
    var bBAN_EsIE = false;
    if (navigator.appVersion.indexOf('MSIE') != -1) {
        bBAN_EsIE = true;
    }

    var bBAN_EsWIN = false;
    if (navigator.appVersion.toLowerCase().indexOf('win') != -1) {
        bBAN_EsWIN = true;
    }

    var bBAN_EsOPERA = false;
    if (navigator.userAgent.indexOf('Opera') != -1) {
        bBAN_EsOPERA = true
    }

    var hasRequestedVersion = DetectFlashVer(6, 0, 29);
}

//******************************************************************************
// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the *
// registry                                                                    *
// version will be set for 7.X or greater players                              *
// version will be set for 6.X players only                                    *
// version will be set for 4.X or 5.X player                                   *
// version will be set for 3.X player                                          *
// version will be set for 2.X player                                          *
//******************************************************************************
function ControlVersion() {
    var version;
    var axo;
    var e;

    try {
        axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7');
        version = axo.GetVariable('$version');
    } catch (err) {
    }

    if (!version) {
        try {
            axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
            version = 'WIN 6,0,21,0';
            axo.AllowScriptAccess = 'always';
            version = axo.GetVariable('$version');
        } catch (err) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.3');
            version = axo.GetVariable('$version');
        } catch (err) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.3');
            version = 'WIN 3,0,18,0';
        } catch (err) {
        }
    }

    if (!version) {
        try {
            axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
            version = 'WIN 2,0,0,11';
        } catch (err) {
            version = -1;
        }
    }

    return version;
}

//******************************************************************************
// JavaScript helper required to detect Flash Player PlugIn version            *
// information                                                                 *
// NS/Opera version >= 3 check for Flash plugin in plugin array                *
// WebTV 2.6 supports Flash 4                                                  *
// WebTV 2.5 supports Flash 3                                                  *
// older WebTV supports Flash 2                                                *
//******************************************************************************
function GetSwfVer() {
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins['Shockwave Flash 2.0'] || navigator.plugins['Shockwave Flash']) {
            var swVer2 = '';
            if (navigator.plugins['Shockwave Flash 2.0']) {
                swVer2 = ' 2.0';
            }

            var flashDescription = navigator.plugins['Shockwave Flash' + swVer2].description;
            var descArray = flashDescription.split(' ');
            var tempArrayMajor = descArray[2].split('.');
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];

            if (descArray[3] != '') {
                tempArrayMinor = descArray[3].split('r');
            } else {
                tempArrayMinor = descArray[4].split('r');
            }

            var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            var flashVer = versionMajor + '.' + versionMinor + '.' + versionRevision;
        }
    } else {
        if (navigator.userAgent.toLowerCase().indexOf('webtv/2.6') != -1) {
            flashVer = 4;
        } else {
            if (navigator.userAgent.toLowerCase().indexOf('webtv/2.5') != -1) {
                flashVer = 3;
            } else {
                if (navigator.userAgent.toLowerCase().indexOf('webtv') != -1) {
                    flashVer = 2;
                } else {
                    if (bBAN_EsIE && bBAN_EsWIN && !bBAN_EsOPERA) {
                        flashVer = ControlVersion();
                    }
                }
            }
        }
    }

    return flashVer;
}

//******************************************************************************
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that *
// version or greater is available                                             *
// Given 'WIN 2,0,0,11'                                                        *
// ['WIN', '2,0,0,11']                                                         *
// '2,0,0,11'                                                                  *
// ['2', '0', '0', '11']                                                       *
// is the major.revision >= requested major.revision AND the minor version     *
// >= requested minor                                                          *
//******************************************************************************
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
    versionStr = GetSwfVer();

    if (versionStr == -1) {
        return 'N';
    } else {
        if (versionStr != 0) {
            if(bBAN_EsIE && bBAN_EsWIN && !bBAN_EsOPERA) {
                tempArray = versionStr.split(' ');
                tempString = tempArray[1];
                versionArray = tempString.split(',');
            } else {
                versionArray = versionStr.split('.');
            }

            var versionMajor = versionArray[0];
            var versionMinor = versionArray[1];
            var versionRevision = versionArray[2];

            if (versionMajor > parseFloat(reqMajorVer)) {
                return 'S';
            } else {
                if (versionMajor == parseFloat(reqMajorVer)) {
                    if (versionMinor > parseFloat(reqMinorVer)) {
                        return 'S';
                    } else {
                        if (versionMinor == parseFloat(reqMinorVer)) {
                            if (versionRevision >= parseFloat(reqRevision)) {
                                return 'S';
                            }
                        }
                    }
                }
            }
        }
        return 'N';
    }
}

//******************************************************************************
// Funciones para el pintado de los banners y el control de apariciones a      *
// través de la cookie.                                                        *
//******************************************************************************
function FBANMOSTRARID (_ID) {
    var _IDOrig = _ID;

    if ((_ID == 'Top') || (_ID == 'X01') || (_ID == 'X02') || (_ID == 'X03') || (_ID == 'Middle')) {
        if (_ID == 'X03') {
            _ID = 'X02';
        }
        try {
            document.getElementById('Publicidad' + _ID).style.display = 'block';
        } catch (err) {
            return true;
        }
    }
    document.getElementById(_IDOrig).style.display = 'inline';
}

function FBANTRATARURL (_urlDestino, _escaparOut) {
    var _resultado = '';
    var iPosIni = -1;
    var iPosFin = -1;
    var _resTemp1 = '';
    var _resTemp2 = '';
    var _resTemp3 = '';

    _resultado = unescape(_urlDestino);
    _resultado += '&NoCacheIE=' + (new Date()).getTime().toString();

    try {
        iPosIni = _resultado.indexOf('?sURL=') + 6;
        iPosFin = _resultado.indexOf('&sFecha=20');
        _resTemp1 = _resultado.slice(0, iPosIni);
        _resTemp2 = _resultado.slice(iPosIni, iPosFin);
        _resTemp3 = _resultado.slice(iPosFin);

        if (_resTemp2.indexOf('/') == 0) {
            _resTemp2 = window.location.protocol + '//' + window.location.host + _resTemp2;
        }

        _resultado = _resTemp1;
        _resultado += escape (_resTemp2);
        _resultado += _resTemp3;

    } catch (err) {
        _resultado = _resultado.replace ('?sURL=/', '?sURL=' + window.location.protocol + '//' + window.location.host + '/');
    }

    if (_escaparOut == 'S') {
        _resultado = escape (_resultado);
    }

    return _resultado;
}

//D.R. Incidencia 6207 28/10/2008
/*Modificación Luis Calvo 29/10/2008 CodIncidencia 6230: Se hace la referencia del parametro _idBanner al final para crear el banner de imagen correctamente*/

function FBANIMAGEN (_urlDestino, _archivoImagen, _textoAlternativo, _modoApertura, _idBanner) {
    var _imagen = '';

    _imagen += '<a href = ' + _urlDestino + ' target =  ' +_modoApertura + ' >';
    _imagen += '<img src= ' + _archivoImagen + ' alt = ' +_textoAlternativo + '>';
    _imagen += '</a>';

    return _imagen;
}

/*FIN Modificación Luis Calvo 29/10/2008*/
//D.R. Fin Incidencia 6207 28/10/2008

function FBANFLASH (_idBanner, _urlDestino, _archivoFlash, _ancho, _alto) {
    var _flash = '';
    var sFlashVars = '';
    sFlashVars += 'clickTag=' + FBANTRATARURL (_urlDestino, 'S');

    _flash += '<object id="' + _idBanner + '"';
    _flash += ' width="' + _ancho + '"';
    _flash += ' height="' + _alto + '"';
    _flash += ' type="application/x-shockwave-flash"';
    _flash += ' codeBase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"';
    _flash += ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';

    _flash += '<param value= "' + _archivoFlash + '" name="movie"/>';
    _flash += '<param value="' + sFlashVars + '" name="flashvars"/>';
    _flash += '<param value="always" name="allowscriptaccess"/>';
    _flash += '<param value="autohigh" name="quality"/>';
    _flash += '<param value="opaque" name="wmode"/>';
    _flash += '<param value="true" name="loop"/>';
    _flash += '<param value="true" name="play"/>';
    _flash += '<param value="false" name="menu"/>';
    _flash += '<param value="true" name="swmodifyreport"/>';

    _flash += '<embed';
    _flash += ' width="' + _ancho + '"';
    _flash += ' height="' + _alto + '"';
    _flash += ' type="application/x-shockwave-flash"';
    _flash += ' pluginspage="http://www.adobe.com/go/getflashplayer"';
    _flash += ' src="' + _archivoFlash + '"';
    _flash += ' flashvars="' + sFlashVars + '"';
    _flash += ' allowscriptaccess="always"';
    _flash += ' wmode="opaque"';
    _flash += ' quality="autohigh"';
    _flash += ' loop="true"';
    _flash += ' play="true"';
    _flash += ' menu="false"';
    _flash += ' swmodifyreport="true"';
    _flash += '/>';

    _flash += '</object>';

    return _flash;
}

function FBANFLASHIMAGEN (_idBanner, _urlDestino, _archivoFlash, _ancho, _alto, _archivoImagen, _textoAlternativo, _modoApertura) {
    var _flashimagen = '';

    if (hasRequestedVersion == 'S') {
        _flashimagen = FBANFLASH (_idBanner, _urlDestino, _archivoFlash, _ancho, _alto);
    } else {
/*Modificación Luis Calvo 29/10/2008 CodIncidencia 6230: Se hace la referencia del parametro _idBanner al final para crear el banner de imagen correctamente*/
        _flashimagen = FBANIMAGEN (_urlDestino, _archivoImagen, _textoAlternativo, _modoApertura, _idBanner);
    }
/*FIN Modificación Luis Calvo 29/10/2008*/
    return _flashimagen;
}

function FBANLAYER (_codeBanner, _X, _Y, _Z, _ancho, _alto, _textoCerrar) {
    var _codeLayer = '';

    _codeLayer += '<div style="background-color: #FFFFFF; text-align: right;">';
    _codeLayer += _codeBanner;
    _codeLayer += '<br/>';
    _codeLayer += '<a style="font: 10px Arial; color: #000000; text-decoration: none;" href="javascript:FBANHIDELAYER(';
    _codeLayer += "'Position1'";
    _codeLayer += ')">';
    _codeLayer += _textoCerrar;
    _codeLayer += '</a>';
    _codeLayer += '</div>';

    document.getElementById('Position1').innerHTML = _codeLayer;
    document.getElementById('Position1').style.position = 'absolute';
    document.getElementById('Position1').style.left = _X + 'px';
    document.getElementById('Position1').style.top = _Y + 'px';
    document.getElementById('Position1').style.zIndex = _Z;
    document.getElementById('Position1').style.bgcolor = '#05f5f5';
    document.getElementById('Position1').style.visibility = 'visible';
}

function FBANINTERSTITIAL (_codeBanner, _segDuracion, _titulo, _textoCerrar) {
    var _codeLayer = '';

    _codeLayer += '<table bgcolor="#ffffff" style="width:100%; height:100%;" border="0" cellpadding="0" cellspacing="0">';
    _codeLayer += '<tr><td align="center" valign="middle">';
    _codeLayer += '<table style="width:0px; height:0px" border="0">';
    _codeLayer += '<tr><td align="center" style="font: 14px Arial; color: #000000; text-decoration: none;"><b>';
    _codeLayer += _titulo;
    _codeLayer += '</b></td></tr>';
    _codeLayer += '<tr><td align="center">';
    _codeLayer += _codeBanner;
    _codeLayer += '</td></tr>';
    _codeLayer += '<tr><td align="right">';
    _codeLayer += '<a style="font: 10px Arial; color: #000000; text-decoration: none;" href="javascript:FBANHIDEINTER(';
    _codeLayer += "'Position1'";
    _codeLayer += ')">';
    _codeLayer += _textoCerrar;
    _codeLayer += '</a>';
    _codeLayer += '</td></tr>';
    _codeLayer += '</table>';
    _codeLayer += '</td></tr>';
    _codeLayer += '</table>';

    sBAN_AntScroll = window.onscroll;
    sBAN_AntResize = window.onresize;
    window.onscroll = FBANPOSINTER;
    window.onresize = FBANPOSINTER;

    document.getElementById('Position1').innerHTML = _codeLayer;
    document.getElementById('Position1').style.position = 'absolute';
    document.getElementById('Position1').style.zIndex = 1;
    FBANPOSINTER();
    document.getElementById('Position1').style.visibility = 'visible';
    window.setTimeout("FBANHIDEINTER('Position1')", _segDuracion * 1000);

    if (bBAN_EsIE6) {
        try {
            document.getElementById('pais').style.visibility = 'hidden';
        } catch (err) {
        }
    }
}

function FBANINTERSPOPUP (_codeBanner, _segDuracion, _titulo, _textoCerrar) {
    var _features = '';
    _features += 'width=' + screen.availWidth.toString() + 'px,';
    _features += 'height=' + screen.availHeight.toString() + 'px,';
    _features += 'top=0,';
    _features += 'left=0,';
    _features += 'fullscreen=yes,';
    _features += 'menubar=no,';
    _features += 'toolbar=no,';
    _features += 'location=no,';
    _features += 'directories=no,';
    _features += 'status=no,';
    _features += 'resizable=no,';
    _features += 'scrollbars=yes';

    var _codeWindow = '';
    _codeWindow += '<html>';
    _codeWindow += '<head>';
    _codeWindow += '<title>'
    _codeWindow += _titulo;
    _codeWindow += '</title>';
    _codeWindow += '</head>';
    _codeWindow += '<body bgcolor="#ffffff" style="height: 100%; width: 100%; margin: 0px; overflow: hidden;">';
    _codeWindow += '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">';
    _codeWindow += '<tr><td align="center" valign="middle">';
    _codeWindow += '<table border="0">';
    _codeWindow += '<tr><td align="center" style="font: 14px Arial; color: #000000; text-decoration: none;"><b>';
    _codeWindow += _titulo;
    _codeWindow += '</b></td></tr>';
    _codeWindow += '<tr><td>';
    _codeWindow += _codeBanner;
    _codeWindow += '</td></tr>';
    _codeWindow += '<tr><td align="right">';
    _codeWindow += '<a style="font: 10px Arial; color: #000000; text-decoration: none;" href="javascript:window.close()">';
    _codeWindow += _textoCerrar;
    _codeWindow += '</a>';
    _codeWindow += '</td></tr>';
    _codeWindow += '</table>';
    _codeWindow += '</td></tr>';
    _codeWindow += '</table>';
    _codeWindow += '</body>';
    _codeWindow += '</html>';

    var WidowInter = null;
    WidowInter = window.open('','inters', _features);
    WidowInter.document.write(_codeWindow);
    WidowInter.setTimeout('window.close()', _segDuracion * 1000);
}

function FBANPOSINTER() {
    var iScrollX = 0;
    var iScrollY = 0;

    if (typeof(window.pageYOffset) == 'number' ) {
        //Netscape compliant
        iScrollY = window.pageYOffset;
        iScrollX = window.pageXOffset;
    } else {
        if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            //DOM compliant
            iScrollY = document.body.scrollTop;
            iScrollX = document.body.scrollLeft;
        } else {
            if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                //IE6 standards compliant mode
                iScrollY = document.documentElement.scrollTop;
                iScrollX = document.documentElement.scrollLeft;
            }
        }
    }

    document.getElementById('Position1').style.top = iScrollY.toString() + 'px';
    document.getElementById('Position1').style.left = iScrollX.toString() + 'px';

    var iAncho = 0;
    var iAlto = 0;

    if (typeof(window.innerWidth) == 'number') {
        //Non-IE
        iAncho = window.innerWidth - 17;
        iAlto = window.innerHeight;
    } else {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'
            iAncho = document.documentElement.clientWidth;
            iAlto = document.documentElement.clientHeight;
        } else {
            if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                //IE 4 compatible
                iAncho = document.body.clientWidth;
                iAlto = document.body.clientHeight;
            }
        }
    }

    document.getElementById('Position1').style.width = iAncho.toString() + 'px';
    document.getElementById('Position1').style.height = iAlto.toString() + 'px';
}

function FBANHIDEINTER (_idFormato) {
    document.getElementById(_idFormato).innerHTML = '';
    document.getElementById(_idFormato).style.position = 'absolute';
    document.getElementById(_idFormato).style.left = '0px';
    document.getElementById(_idFormato).style.top = '0px';
    document.getElementById(_idFormato).style.width = '0px';
    document.getElementById(_idFormato).style.height = '0px';

    if (bBAN_EsIE6) {
        try {
            document.getElementById('pais').style.visibility = 'visible';
        } catch (err) {
        }
    }

    document.getElementById(_idFormato).style.visibility = 'hidden';
    window.onscroll = sBAN_AntScroll;
    window.onresize = sBAN_AntResize;
}

function FBANHIDELAYER (_idFormato) {
    document.getElementById(_idFormato).innerHTML = '';
    document.getElementById(_idFormato).style.position = 'absolute';
    document.getElementById(_idFormato).style.left = '0px';
    document.getElementById(_idFormato).style.top = '0px';
    document.getElementById(_idFormato).style.width = '0px';
    document.getElementById(_idFormato).style.height = '0px';
    document.getElementById(_idFormato).style.visibility = 'hidden';
    window.onscroll = sBAN_AntScroll;
    window.onresize = sBAN_AntResize;
}

function FBANCONTAPARICION (_idBanner) {
    var sDatCookie = '';
    var sPreCookie = 'sAparBanner=';
    var sBuscar = 'id' + _idBanner + ',';

    sDatCookie = FBANDATCOOKIE (sPreCookie);

    if (sDatCookie == '') {
        sDatCookie = sPreCookie + sBuscar + '1';
    } else {
        sDatCookie = sPreCookie + FBANACTCOOKIE (sBuscar, sDatCookie);
    }

    document.cookie = sDatCookie + '; path=/';
}

function FBANDATCOOKIE (_sPrefijo) {
    var sDatos = '';
    var iPosIni = -1;
    var iPosFin = -1;

    sDatos = document.cookie.toString();
    iPosIni = sDatos.indexOf(_sPrefijo);

    if (iPosIni >= 0) {
        iPosIni = iPosIni + _sPrefijo.length;
        iPosFin = sDatos.indexOf(';', iPosIni);
        if (iPosFin < 0) {
            iPosFin = sDatos.length;
        }
        sDatos = sDatos.slice(iPosIni, iPosFin);
    } else {
        sDatos = '';
    }
    return sDatos;
}

function FBANACTCOOKIE (_sBuscar, _sDatos) {
    var sDatosSalida = '';
    var iPosIni = -1;
    var iPosFin = -1;
    var iApariciones = 0;

    iPosIni = _sDatos.indexOf(_sBuscar);

    if (iPosIni >= 0) {
        iPosIni = iPosIni + _sBuscar.length;
        iPosFin = _sDatos.indexOf(',', iPosIni);
        if (iPosFin < 0) {
            iPosFin = _sDatos.length;
        }
        iApariciones = parseInt(_sDatos.slice(iPosIni, iPosFin)) + 1;
        sDatosSalida = _sDatos.slice(0, iPosIni);
        sDatosSalida += iApariciones.toString();
        sDatosSalida += _sDatos.slice(iPosFin);
    } else {
        sDatosSalida = _sDatos + ',' + _sBuscar + '1';
    }
    return sDatosSalida;
}

//******************************************************************************
// Funciones para la creación de la llamada al servicio de banners             *
//******************************************************************************
function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl + '&NoCacheIE=' + (new Date()).getTime().toString();
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'JavaScriptId' + JSONscriptRequest.scriptCounter++;
}

JSONscriptRequest.scriptCounter = 1;

JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");
    this.scriptObj.setAttribute("language", "JavaScript");
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl);
    this.scriptObj.setAttribute("id", this.scriptId);
}

JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);
}

JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}

function addBanner (sTipoBanner) {
    var sFormato = '';

    try {
        sFormato = document.getElementById(sTipoBanner).id + ",";
    } catch (err) {
        sFormato = '';
    }

    sBAN_Formatos += sFormato ;
}

function getBanners(sURL) {
    bObj = new JSONscriptRequest(sURL);
    bObj.buildScriptTag();
    bObj.addScriptTag();
}

/*
</span>*/
