﻿    /******* Default.aspx *******/


/******************************/

var redirect;

/*Redimensiona Frame*/

function resizeIframe(idIframe) {
var miIframe = document.getElementById(idIframe);


switch(browser)
    {
        case "Firefox" : alturaPagina = miIframe.contentDocument.documentElement.clientHeight;
            
            miIframe.height = alturaPagina;
        break;
        default : 
            alturaPagina = miIframe.document.body.scrollHeight;
            miIframe.style.height = alturaPagina;
        break;
    }

}

/*********** Pop Up **********/


function ShowPopUp(header, strong, text) {
try
{
    var objHeader = $("#ctl00_headerFelicitacionDialog"); 
    objHeader[0].innerHTML = header;
    var objStrong = $("#ctl00_dialogStrong"); 
    objStrong[0].innerHTML = strong;
    var objSpan = $("#ctl00_dialogSpan"); 
    objSpan[0].innerHTML = text;
    var btn = $('#ctl00_btnAceptar');

    var popUp = document.getElementById('ctl00_mpeDialog');
    if(popUp!=null){
    popUp.show();
    btn[0].focus();}
    else{
    popUp = $find("ctl00_mpeDialog");
    popUp.show();
    btn[0].focus();
    }
}
catch(err)
{
alert(err);
}
}

function ShowPopUpRedirect(header, strong, text,ir) {
    window.onload = alert('fdgdfg');
}

function SetFocus(idControl)
{
    var btn = $('#' + idControl+ '');
    btn[0].style.display = "block";
    btn[0].focus();
}

function closePopUp() {

var popUp = $find('ctl00_mpeDialog');
popUp.hide();
    if(redirect != null && redirect != '')
    {
        window.location.href = redirect;
    }

}

function ShowPopUpRecomendation(productID, title, newsType) {

var hdnproductID = $("#ctl00_NewsRecomendation_hdnPID");
var hdnNewsTitle = $("#ctl00_NewsRecomendation_hdnNewsTitle");
var hdnNewsType = $("#ctl00_NewsRecomendation_hdnNewsType");
hdnproductID[0].value = productID;
hdnNewsTitle[0].value = title;
hdnNewsType[0].value = newsType;
var popUp = $find('ctl00_mpeRecomendation');
var btn = $('#ctl00_NewsRecomendation_btnSend');
popUp.show();
btn[0].focus();

}

function closePopUpRecomendation() {

document.getElementById('ctl00_NewsRecomendation_txtFrom').value = '';   
document.getElementById('ctl00_NewsRecomendation_txtTo').value = '';   
document.getElementById('ctl00_NewsRecomendation_txtMsg').value = '';   

var popUp = $find('ctl00_mpeRecomendation');
popUp.hide();
}


function ShowPopUpFoto(urlImage, Description) {

var img = document.getElementById('imgFoto');
img.src = "";
img.src = urlImage;

var dsc = $('#title');
dsc[0].innerHTML = Description;

var popUp = $find('mpeImageBigSection');
if(popUp!=null){
popUp.show();}
else{
popUp = $("#mpeImageBigSection");
popUp.show();
}


}

function closePopUpFoto() {
var img = $('#imgFoto');
img.src = "";
var popUp = $find('mpeImageBigSection');
if(popUp!=null){
popUp.hide();}
else{
popUp = $("#mpeImageBigSection");
popUp.hide();
}
}

/******************************/

/*********** Login **********/
function ShowLogin()
{
    ShowPopUpLogin("UnoNoticias Login","", "false");
//    HideRetrieve();
//    var hdnLogin = $("#hdnLogin");
//    var divInsideLogin = $("#insideLogin"); 

//    if(hdnLogin[0].value=="hide")
//    {
//        if(divInsideLogin[0].style.display=="none")
//        {
//            divInsideLogin[0].style.display = "inline";
//        }            
//        hdnLogin[0].value="visible";
//    }
}

function ReloadLogin()
{
var hdnLogin = $("#hdnLogin");
hdnLogin[0].value="hide";
ShowLogin();
}

function HideLogin()
{
var divInsideLogin = $("#insideLogin"); 
var hdnLogin = $("#hdnLogin");

divInsideLogin[0].style.display = "none";
hdnLogin[0].value="hide";
}

function ShowRetrieve()
{
    ShowOlvidoPass(false);
//HideLogin();
//var hdnRetrieve = $("#hdnRetrieve");
//var divInsideRetrieve = $("#insideRetrieve"); 

//if(hdnRetrieve[0].value=="hide")
//    {
//        if(divInsideRetrieve[0].style.display=="none")
//        {
//            divInsideRetrieve[0].style.display = "inline";
//        }
//            
//        hdnRetrieve[0].value="visible";
//    }
}

function HideRetrieve()
{
var divInsideRetrieve = $("#insideRetrieve"); 
var hdnRetrieve = $("#hdnRetrieve");

divInsideRetrieve[0].style.display = "none";
hdnRetrieve[0].value="hide";
}

function SetAutenticate(logged)
{
//var SwitchSignUp = document.getElementById('ctl00_SwitchSignUp');
var SwitchSignUp = $("#ctl00_SwitchSignUp");
var SwitchLogin = $("#SwitchLogin");
var SwitchForgot = $("#SwitchForgot");
var SwitchLogOut = $("#SwitchLogOut");
var insideWelcome = $("#insideWelcome");

if(logged)
    {
    SwitchSignUp[0].innerHTML = "Mi Cuenta ";
    SwitchLogin[0].style.display = "none";
    SwitchForgot[0].style.display = "none";
    SwitchLogOut[0].style.display = "inline";
    insideWelcome[0].style.display = "inline"
   
    }
else
    {
   
    SwitchSignUp[0].innerHTML = "Regístrate ";
    SwitchLogin[0].style.display = "inline";
    SwitchForgot[0].style.display = "inline";
    SwitchLogOut[0].style.display = "none";
    insideWelcome[0].style.display = "none"
    }
}
/******************************/

/******************************/

//Funciones para el login y el olvido de contraseña

function ShowPopUpLogin(title, desc, banInsComment)  {
    
    var Title = $("#ctl00_LoginCustom_hdnTitulo");
    var Desc = $("#ctl00_LoginCustom_hdnDesc");
    var InsComment = $("#ctl00_LoginCustom_hdnValInsComment");
    var popUp = $find('ctl00_mpeLogin');
    var btn = $('#ctl00_LoginCustom_btnSend');
    var btnLoad = $('#ctl00_LoginCustom_cargarInfo');
    
    Title[0].value = title;
    Desc[0].value = desc;
    InsComment[0].value = banInsComment;
    btnLoad.click();
    //popUp.show();    
    //btn[0].focus();
    
}

function LoadPopUpLogin()
{
    var popUp = $find('ctl00_mpeLogin');
    var btn = $('#ctl00_LoginCustom_btnSend');
    popUp.show();    
    btn[0].focus();
}

function closePopUpLogin(){

    document.getElementById('ctl00_LoginCustom_txtuser').value = '';   
    document.getElementById('ctl00_LoginCustom_txtpass').value = '';
    document.getElementById('ctl00_LoginCustom_errorMsg').innerHTML = '';

    var popUpL = $find('ctl00_mpeLogin');
    popUpL.hide();
}

function ShowPopUpInsComment(prodId, ocultarlogin) {
    
    var capUP = $('#ctl00_cphContenido_hdnocultarCaptchaSU');
    var capRP = $('#ctl00_RetrievePass_hdnocultarCaptchaRP');
    var capIC = $('#ctl00_InsComment_hdnocultarCaptchaIC');
    
    destroyRecaptcha();
    
     if (ocultarlogin == 'true') {
        var popUpL = $find('ctl00_mpeLogin');
        popUpL.hide();
    }
    
    var productId = $("#ctl00_InsComment_hdnProductId");
    var popUp = $find('ctl00_mpeInsertComment');
    var btn = $('#ctl00_InsComment_btnSend');
    productId[0].value = prodId;
    
    popUp.show();
    btn[0].focus();
    
    if(capUP[0] != null)
    {        
        capUP[0].value = 'true';        
    }       
    
    if(capRP[0] != null)
    {        
        capRP[0].value = 'true';        
    }       
    
    if(capIC[0] != null)
    {        
        capIC[0].value = ''; 
        showRecaptcha('divCaptchaIS');       
    }   
    
    
   
}

function closePopUpInsComment(mostrarAdv) {
    actualizarPaginado();
     
    reLoadCaptcha();
    var popUpL = $find('ctl00_mpeInsertComment');
    popUpL.hide();
    document.getElementById('ctl00_cphContenido_btnUpProgress').click();        
    if(mostrarAdv)
    { ShowPopUp('Inserción comentario','','Lo sentimos. Tu comentario no puede ser publicado debido al lenguage utilizado.\nPor favor revísalo e intenta de nuevo');}
        
}

function ShowOlvidoPass(ocultarlogin){

    var capUP = $('#ctl00_cphContenido_hdnocultarCaptchaSU');
    var capRP = $('#ctl00_RetrievePass_hdnocultarCaptchaRP');
    var capIC = $('#ctl00_InsComment_hdnocultarCaptchaIC');
    destroyRecaptcha();
    if(ocultarlogin)
    {    
        closePopUpLogin(); 
    }
    var popUp = $find('ctl00_mpeRetrievePass');
    var btn = $('#ctl00_RetrievePass_btnSend');
    popUp.show();
    btn[0].focus();
    if(capUP[0] != null)
    {        
        capUP[0].value = 'true';        
    }       
    
    if(capRP[0] != null)
    {        
        capRP[0].value = '';
        showRecaptcha('dynamic_recaptcha');        
    }       
    
    if(capIC[0] != null)
    {        
        capIC[0].value = 'true';        
    }   
    
    
    var popUp = $find('ctl00_mpeRetrievePass');
    var btn = $('#ctl00_RetrievePass_btnSend');
    popUp.show();
    btn[0].focus();
}

function closePopUpOlvidoPass(){
    
    document.getElementById('ctl00_RetrievePass_txtuser').value = '';       
    document.getElementById('ctl00_RetrievePass_errorRetrieve').innerHTML = '';
    
    reLoadCaptcha();    
    var popUpL = $find('ctl00_mpeRetrievePass');
    popUpL.hide();
}

function redirectComentarios(element){
    
    document.getElementById(element).click();
  
}

function reLoadCaptcha()
{
    var capUP = $('#ctl00_cphContenido_hdnocultarCaptchaSU');
    var capRP = $('#ctl00_RetrievePass_hdnocultarCaptchaRP');
    var capIC = $('#ctl00_InsComment_hdnocultarCaptchaIC');
    //destroyRecaptcha();
    if(capUP[0] != null)
    {        
        capUP[0].value = '';        
    }       
    
    if(capRP[0] != null)
    {        
        capRP[0].value = 'true';        
    }       
    
    if(capIC[0] != null)
    {        
        capIC[0].value = 'true';        
    }
}

function destroyRecaptcha() {
        Recaptcha.destroy();
    }
    
    function showRecaptcha(element) {    
        
        Recaptcha.create("6Le0MwgAAAAAAFEZcLeF4NUhZUfcxJkm2VBPtN89", element, {
            theme: 'clean',
            lang: 'es'
            //callback: Recaptcha.focus_response_field
        });    
    } 
    
function validateRecaptcha(campoChallenge, campoResponse)
{
    document.getElementById(campoChallenge).value = Recaptcha.get_challenge();
    document.getElementById(campoResponse).value = Recaptcha.get_response();
}

//function recargaRetrievePass(usuario, error ){
//    
//    var user = $("#ctl00_RetrievePass_txtuser");
//    var diverror = $("#ctl00_RetrievePass_errorRetrieve");    
//    user.Text = usuario;
//    diverror.innerHTML = error;
//    closePopUpOlvidoPass();
//    ShowOlvidoPass(false);

//}



/********************************/

function ShowPopUpSuggestTopic() {

var popUp = $find('ctl00_mpeSuggestTopic');
var btn = $('#ctl00_SuggestTopic_btnSend');
popUp.show();
btn[0].focus();

}

function closePopUpSuggestTopic() {
var popUp = $find('ctl00_mpeSuggestTopic');
document.getElementById('ctl00_SuggestTopic_txtUsuario').value = '';
document.getElementById('ctl00_SuggestTopic_txtEncabezado').value = '';
document.getElementById('ctl00_SuggestTopic_txtDescripcion').value = '';
document.getElementById('ctl00_SuggestTopic_errorSuggestTopic').innerHTML = '';
popUp.hide();
}

function ShowPopUpConclusionTopic(topicID) {

var popUp = $find('ctl00_mpeConclusionTopic');
var btn = $('#ctl00_ConclusionTopic_btnSend');
var productId = $("#ctl00_ConclusionTopic_hdnTopicId");
productId[0].value = topicID;
popUp.show();
btn[0].focus();

}

function closePopUpConclusionTopic() {
var popUp = $find('ctl00_mpeConclusionTopic');
document.getElementById('ctl00_ConclusionTopic_txtUsuario').value = '';
document.getElementById('ctl00_ConclusionTopic_txtEncabezado').value = '';
document.getElementById('ctl00_ConclusionTopic_txtDescripcion').value = '';
document.getElementById('ctl00_ConclusionTopic_errorConclusionTopic').innerHTML = '';
popUp.hide();
}

