﻿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) {
    alert(nombreControl);
    alert(nombreControl.value);
          /*var texto =document.getElementById(nombreControl).value;*/
          var texto = nombreControl.value;
       if (texto.length>=maxCaracteres)
       {
       document.getElementById(nombreControl).value=texto.substr(0, maxCaracteres);
       }

   }

   function redirect(codDestino) {

       switch (codDestino) {
           case "-1": document.location.href = document.location.href;
               break;
           case "0": document.location.href = "registro.aspx";
               break;
//           case "1": window.open("tienda/Default.aspx", 'tienda', 'location=yes,directories=yes,status=yes,scrollbars=yes,width=1000,height=700');
//               break;
           case "2": document.location.href = "listadoRutas.aspx";
               break;
           case "3": document.location.href = "jugar.aspx";
               break;
           case "4": document.location.href = "listadoVideos.aspx";
               break;
           case "5": document.location.href = "listadoNoticias.aspx";
               break;
           case "6":
               //alert("En nueva construcción");
               //document.location.href = "#";
               document.location.href = "foro.aspx";
               break;
           case "7":
               //alert("En nueva construcción");
               //document.location.href = "#";
               document.location.href = "tablon.aspx";
               break;
           case "8": document.location.href = "galeriaFotos.aspx";
               break;
       }
   }


   function abreVentanaZoom(url, winName, width, height) {
       var features = "width=" + width + ", height=" + height + ", scrollbars=no";
       var vent = window.open(url, winName, features);
       vent.focus();

   }

   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("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,'Rincon Alpino');
            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("idUsuario").value == "0")
         {
         alert('Debes identificarte para poder denunciar un Post o Tema');
         return false;
         }
         else
         {
           return true;
         }
        }       
        