﻿var prefijoPagina="ctl00_ContentPlaceHolder1_";

function abreVentana(url,winName,width,height) {   
    var alto= (screen.height / 2) - (height/2);
    var ancho= (screen.width / 2) - (width/2);
    var features="width="+width+", height="+height+", scrollbars=yes,top=" + alto  + ",left=" + ancho;
    var vent= window.open(url, winName, features);    
    vent.focus();
    return false;
}

function confirmarBorrado()
{
  return confirm('Se va proceder a eliminar el registro seleccionado');
}
  
   function OnClientCommandExecuting(editor, args) {
            var name = args.get_name();
            var val = args.get_value();
            if (name == "Emoticons") {
                editor.pasteHtml("<img src='" + val + "'>");
                //Cancel the further execution of the command as such a command does not exist in the editor command list
                args.set_cancel(true);
            }
        }    
function controlCaracteres(nombreControl,maxCaracteres)
      {
       var texto =document.getElementById(nombreControl).value;
       if (texto.length>=maxCaracteres)
       {
       document.getElementById(nombreControl).value=texto.substr(0, maxCaracteres);
       }

   }

 
   function abreBasesLegales() {    
      
       
       var url = "basesLegalesJuego.pdf";
       var winName = "basesLegalesJuego";
       var features = "width=600, height=750, scrollbars=auto";
       var vent = window.open(url, winName, features);
       vent.focus();
       
   }
   
   function enviarClick(hayAsunto) {
    if (hayAsunto) {
        var textoAsunto = document.getElementById('ctl00_ContentPlaceHolder1_' + nuevoAsunto).Content;
        if (textoAsunto.length = 0) {
            return alert('Es obligatorio especificar un asunto para el mensaje');
        }
    } else {
        var textoMensaje = document.getElementById('ctl00_ContentPlaceHolder1_' + nuevoMensaje).Content;
        if (textoAsunto.length = 0) {
            return alert('Es obligatorio especificar un mensaje');
        }
    }
}

function controlCaracteresComentarios(nombreControl, maxCaracteres) {
    var texto = document.getElementById(nombreControl).value;
    if (texto.length >= maxCaracteres) {
        document.getElementById(nombreControl).value = texto.substr(0, maxCaracteres);
    }

}

        function OnClientCommandExecuting(editor, args) {
            var name = args.get_name();
            var val = args.get_value();
            if (name == "Emoticons") {
                editor.pasteHtml("<img src='" + val + "'>");
                //Cancel the further execution of the command as such a command does not exist in the editor command list
                args.set_cancel(true);
            }
        }

        function mostrarRad(quePanel)
        {
            if (document.getElementById( "ctl00_idUsuario").value != 0)
            {   
                if (document.getElementById("visibleRad" + quePanel).value=="0")
                {
                    document.getElementById("panelNuevo" + quePanel).style.display="inline";
                    document.getElementById("visibleRad" + quePanel).value="1";
                    if(quePanel==1){quePanel=2}else{quePanel=1;}
                    if (document.getElementById("visibleRad" + quePanel).value=="1"){
                        document.getElementById("panelNuevo" + quePanel).style.display="none";
                        document.getElementById("visibleRad" + quePanel).value="0"
                    }
                }
            }
            else{
                    alerta('Es necesario estar identificado para poder publicar');
                } 
        } 
        
        function alerta(texto){
            radalert(texto,330,160,'Consumópolis');
            return false;
        }
        
        function ocultarRad(quePanel)
        {            
            if (document.getElementById("visibleRad" + quePanel).value=="1")
            {
                document.getElementById("panelNuevo" + quePanel).style.display="none";
                document.getElementById("visibleRad" + quePanel).value="0" 
            }       
        }
        
        function denunciar()
        {
            if (document.getElementById("ctl00_idUsuario").value == "0")
         {
         alert('Debes identificarte para poder denunciar un Post o Tema');
         return false;
         }
         else
         {
           return true;
         }
     }

     function cambiaidioma(qIdioma) {
         var urlActual = document.location.href;
         var partesUrl = urlActual.split("idioma=");
         if (partesUrl.length > 1) {
             var newURL = partesUrl[0] + "idioma=" + qIdioma + partesUrl[1].substring(3);
             document.location.href = newURL;
         }
         else {
             if (document.location.href.split("?") > 1) {
                
                 document.location.href = document.location.href + "&idioma=" + qIdioma;
             }
             else {
             
                 document.location.href = document.location.href + "?idioma=" + qIdioma;
             }
             
             
         }
          }
        