
// -----------------------------------------------------------------------------
// Función encargada de Pasar como parámetro el xml
//      xml:    Ruta al XML del artículo
//      tipo:   Tipo de Fotorama
function ChangeDatosFotorama(xml, tipo, ratio, thisid, aid, path, tit, ssttipo, horfec, hfclass) {

    // Si el navegador no cumple, o no se sabe, se redirecciona
    if(!isGoodBrowser()) {
        window.location.href="/prontus_nots/site/edic/base/port/fotos.html?_ts="+thisid;
        return;
    };
    var anchoFijo = 380;
    if(xml=='' || tipo=='') {
        return;
    };

    var movieUrl    = "/prontus_nots/flash/_Fotorama.swf";

    var urlFoto         = "/prontus_nots/flash/_PlayerFoto.swf";
    var urlVideo        = "/prontus_nots/flash/_PlayerVideo.swf";
    var urlAudio        = "/prontus_nots/flash/_PlayerAudio.swf";
    var urlMultimedia   = "/prontus_nots/flash/_PlayerMultimedia.swf";

    var idObj = 'idFlashFotorama';
    if(thisid) idObj = idObj + thisid;

    if(ratio=='' || ratio==null) {
        var ratio = '0.75';
    }

    if(tipo=='video') {
        var ancho = parseInt(anchoFijo) + 8;
        var alto = parseInt(parseInt(anchoFijo)*parseFloat(ratio) + 179 + 8 + 45);
        var sst_aid = 'media_videos';

    } else if(tipo=='audio') {
        var ancho = parseInt(anchoFijo) + 8;
        var alto = parseInt(parseInt(anchoFijo)*parseFloat(ratio) + 229 + 8);
        var sst_aid = 'media_audios';

    } else if(tipo=='multimedia') {
        var ancho = parseInt(anchoFijo) + 8;
        var alto = parseInt(parseInt(anchoFijo)*parseFloat(ratio) + 179 + 8);
        var sst_aid = 'media_multimedia';

    } else if(tipo=='foto') {
        var ancho = parseInt(anchoFijo) + 8;
        var alto = parseInt(parseInt(anchoFijo)*parseFloat(ratio) + 179 + 8);
        var sst_aid = 'media_fotos';

    } else {
        return;
    };

    var flashvars = "xml=" + xml
          + "&tipo=" + tipo
          + "&urlFoto=" + urlFoto
	      + "&urlVideo=" + urlVideo
	      + "&urlAudio=" + urlAudio
	      + "&urlMultimedia=" + urlMultimedia;

    var params1 = '';
    var params2 = '';
    var miTitDiv = '<div class="titular-media"><span class="'+hfclass+'-media">'+horfec+'</span>'+tit+'</div>'+"\n";
    var miDiv = document.getElementById('idDivFotoramaMain');
    if(miDiv) {
        var strSwf = getStringObject(movieUrl, idObj, ancho, alto, flashvars, params1, params2);
        miDiv.innerHTML = miTitDiv + strSwf;
    };
    if(window.sst7_click) {
        sst7_click(sst_aid, path, tit,'por');
    };

    if(window.location.href.indexOf('#PlayerMedia')!=-1) {
        window.location.href=window.location.href;
    } else {
        window.location.href=window.location.href+'#PlayerMedia';
    };
    return;
};

// -----------------------------------------------------------------------------
// Función encargada de Pasar como parámetro los valores al Flash de Video
function ChangeDatosPlayerVideo(xml, wvideo, hvideo, thisid, aid, path, tit, ssttipo, horfec, hfclass) {

    // Si el navegador no cumple, o no se sabe, se redirecciona
    if(!isGoodBrowser()) {
        window.location.href="/prontus_media/site/edic/base/port/videos.html?_ts="+thisid;
        return;
    };

    var anchoFijo = 380;
    if(xml=='') {
        return;
    };

    var movieUrl = "/prontus_nots/flash/_PlayerVideo.swf";
    var ancho = '280';
    var alto = '158';
    var idObj = 'idFlashVideo';
    if(thisid) idObj = idObj + thisid;

    // Ajustando el ALTO y ANCHO según proporciones
    if(wvideo != '') ancho = wvideo;
    if(hvideo != '') alto = hvideo;
    var anchoVideo = parseInt(ancho);
    var altoVideo = parseInt(alto);
    var anchoReal = anchoFijo;
    var altoReal;
    if(anchoVideo!='' && anchoVideo!=0) {
        altoReal = Math.floor(380*(altoVideo/anchoVideo));
    } else {
        altoReal = Math.floor(380*(0.75));;
    };
    anchoReal = anchoReal + 8;
    altoReal = altoReal + 8 + 45;

    var flashvars = "xml=" + xml
            + "&start=stop"
            + "&vol=90";

    var params1 = '';
    var params2 = '';
    // Se obtiene la descripción, si existe...
    var divTxtSrc = document.getElementById('txtVideo'+thisid);
    var desc = '';
    if(divTxtSrc) {
        desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
    };
    var myframe = document.getElementById('Mediaiframe');
    if(myframe) {
        divTxtSrc = myframe.contentDocument.getElementById('txtVideo'+thisid);
        if(divTxtSrc) {
            desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
        };
    };
    var miTitDiv = '<div class="titular-media"><span class="'+hfclass+'-media">'+horfec+'</span>'+tit+'</div>'+"\n";
    var miDiv = document.getElementById('idDivVideoMain');
    var idDiv = 'idDivVideoMain';
    if(miDiv) {
        var strSwf = getStringObject(movieUrl, idObj, anchoReal, altoReal, flashvars, params1, params2);
        miDiv.innerHTML = miTitDiv + strSwf + "\n" + desc;
    };
    if(window.sst7_reload) {
        sst7_click('media_videos', path, tit,'por');
    };
    if(window.location.href.indexOf('#PlayerMedia')!=-1) {
        window.location.href=window.location.href;
    } else {
        window.location.href=window.location.href+'#PlayerMedia';
    };
    return;
};

// -----------------------------------------------------------------------------
// Función encargada de Pasar como parámetro el xml al Flash de Audio
function ChangeDatosPlayerAudio(xml, thisid, img, wimg, himg, aid, path, tit, ssttipo, horfec, hfclass) {

    // Si el navegador no cumple, o no se sabe, se redirecciona
    if(!isGoodBrowser()) {
        window.location.href="/prontus_media/site/edic/base/port/audios.html?_ts="+thisid;
        return;
    };

    if(xml=='') {
        return;
    };

    var movieUrl = "/prontus_nots/flash/_PlayerAudio.swf";
    var ancho = '390';
    var alto = '50';
    var idObj = 'idFlashAudio';
    if(thisid) idObj = idObj + thisid;
    var flashvars = "xml=" + xml
            + "&start=start"
            + "&vol=90";

    var params1 = '';
    var params2 = '';

    var divImg = '';
    if(img) {
        if(wimg!='' && himg!='') {
            divImg = "<div style='margin-bottom:10px;'>\n";
            divImg = divImg + "  <img src='"+img+"' width='"+wimg+"' height='"+himg+"' border='0' alt='Imagen Audio' title='Imagen Audio'>\n</div>";
        } else {
            divImg = "<div style='margin-bottom:10px;'>\n";
            divImg = divImg + "  <img src='"+img+"' border='0' alt='Imagen Audio' title='Imagen Audio'>\n</div>";
        };
    } else {
      divImg = "<div style='margin-bottom:10px;'>\n";
      divImg = divImg + "  <img src=\"/common/imag/media/microfono-380.jpg\" border='0' alt='Imagen Audio' title='Imagen Audio'>\n</div>";
    };

    // Se obtiene la descripción, si existe...
    var desc = '';
    var divTxtSrc = document.getElementById('txtAudio'+thisid);
    if(divTxtSrc) {
        desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
    } else {
        var myframe = document.getElementById('Mediaiframe');
        if(myframe) {
            divTxtSrc = myframe.contentDocument.getElementById('txtAudio'+thisid);
            if(divTxtSrc) {
                desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
            };
        };
    };
    var miTitDiv = '<div class="titular-media"><span class="'+hfclass+'-media">'+horfec+'</span>'+tit+'</div>'+"\n";
    var miDiv = document.getElementById('idDivAudioMain');
    if(miDiv) {
        var strSwf = getStringObject(movieUrl, idObj, ancho, alto, flashvars, params1, params2);
        miDiv.innerHTML = miTitDiv + divImg + "\n" + strSwf + "\n" + desc;
    };
    if(window.sst7_reload) {
        sst7_click('media_audios', path, tit,'por');
    };

    if(window.location.href.indexOf('#PlayerMedia')!=-1) {
        window.location.href=window.location.href;
    } else {
        window.location.href=window.location.href+'#PlayerMedia';
    };
    return;
};


// -----------------------------------------------------------------------------
// Función encargada de Pasar como parámetro el xml al Flash de Multimedia
function ChangeDatosMultimedia(xml, wswf, hswf, thisid, aid, path, tit, ssttipo, horfec, hfclass) {

    // Si el navegador no cumple, o no se sabe, se redirecciona
    if(!isGoodBrowser()) {
        window.location.href="/prontus_media/site/edic/base/port/multimedia.html?_ts="+thisid;
        return;
    };

    if(xml=='') {
        return;
    };

    var movieUrl = "/prontus_nots/flash/_PlayerMultimedia.swf";
    var ancho = '380';
    var alto = '285';
    var idObj = 'idFlashMultimedia';
    if(thisid) idObj = idObj + thisid;

    // Ajustando el ALTO y ANCHO según proporciones
    if(wswf != '' && hswf != '') {
        ancho = wswf;
        alto = hswf;
    };
    var anchoVideo = parseInt(ancho);
    var altoVideo = parseInt(alto);
    var anchoReal = 380;
    var altoReal;
    if(anchoVideo!='' && anchoVideo!=0) {
        altoReal = 380*(altoVideo/anchoVideo);
    } else {
        altoReal = 285;
    };
    anchoReal = anchoReal;
    altoReal = altoReal;

    var flashvars = "xml=" + xml;

    var params1 = '';
    var params2 = '';
    // Se obtiene la descripción, si existe...
    var divTxtSrc = document.getElementById('txtMultimedia'+thisid);
    var desc = '';
    if(divTxtSrc) {
        desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
    };
    var myframe = document.getElementById('Mediaiframe');
    if(myframe) {
        divTxtSrc = myframe.contentDocument.getElementById('txtMultimedia'+thisid);
        if(divTxtSrc) {
            desc = "<div class=\"texto-portmedia\">" + divTxtSrc.innerHTML + "</div>";
        };
    };
    var miTitDiv = '<div class="titular-media"><span class="'+hfclass+'-media">'+horfec+'</span>'+tit+'</div>'+"\n";
    var miDiv = document.getElementById('idDivMultimediaMain');
    if(miDiv) {
        var strSwf = getStringObject(movieUrl, idObj, anchoReal, altoReal, flashvars, params1, params2);
        miDiv.innerHTML = miTitDiv + strSwf + "\n" + desc;
    };

    if(window.sst7_reload) {
        sst7_click('media_multimedia', path, tit,'por');
    };

    if(window.location.href.indexOf('#PlayerMedia')!=-1) {
        window.location.href=window.location.href;
    } else {
        window.location.href=window.location.href+'#PlayerMedia';
    };
    return;
};


// -----------------------------------------------------------------------------
// Función encargada de encontrar el objeto Flash
function getFlashMovieObject(movieName) {

    if (window.document[movieName]) {
        return window.document[movieName];
    };
    if (navigator.appName.indexOf("Microsoft Internet")==-1) {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
    } else {
        return document.getElementById(movieName);
    };
};

// -----------------------------------------------------------------------------
// Para la detección específica de Browser sobre redimensionar el Object
// Sólo válida para estas funciones de
function isGoodBrowser() {

    if(navigator.userAgent.indexOf('MSIE')!=-1) {
        // Very Bad Browser... xD
        return false;
    } else if(navigator.userAgent.indexOf('Gecko')!=-1) {
        // Super "Wen" Browser... xD
        if(navigator.userAgent.indexOf('Firefox')!=-1) {
            return true;
        } else {
            return false;
        };
    } else if(navigator.userAgent.indexOf('Opera')!=-1) {
        if(parseInt(navigator.appVersion ) >= 9) {
            return true;
        } else {
            return false;
        };
    } else {
        // Browser Desconocido
        return false;
    };
    // Por si las moscas
    return false;
};

