﻿// JScript File
 //PROHIBIMOS BOTON DERECHO
//    var message=""; 

//    function clickIE() {if (document.all) {(message);return false;}} 
//    

//    function clickNS(e) 
//    {
//    if (document.layers||(document.getElementById&&!document.all)) 
//            if (e.which==2||e.which==3) {(message);return false;}
//    
//    }
//    
//    //Según el navegador
//    if (document.layers)  
//    {
//        document.captureEvents(Event.MOUSEDOWN);
//        document.onmousedown=clickNS;
//    }        
//    else    
//    {
//        document.onmouseup=clickNS;
//        document.oncontextmenu=clickIE;
//    } 
//    
//    document.oncontextmenu=new Function("return false");
    //FINAL DE PROHIBICION DE BOTON DERECHO
    

function cambiaCursor(tipo)
{
    document.body.style.cursor = tipo;
}

//TODO COPIAR EN JS DE AUTOS
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }


function OcultarEsperaParent()
    {
        var ventanaPadre = window.opener;
        var reloj = ventanaPadre.document.getElementById("imgEspera");
        if (reloj != null)
            reloj.style.visibility = "hidden";
    }

function padleft(val, ch, num) {
            var re = new RegExp(".{" + num + "}$");
            var pad = "";
            if (!ch) ch = " ";
            do  {
                pad += ch;
            }while(pad.length < num);
            return re.exec(pad + val)[0];
        }

function padright(val, ch, num){
            var re = new RegExp("^.{" + num + "}");
            var pad = "";
            if (!ch) ch = " ";
            do {
                pad += ch;
            } while (pad.length < num);
            return re.exec(val + pad)[0];
        }
    
function ComprobarEnter(cadena, obj, e)
{
    var tecla;
    tecla = (document.all) ? e.keyCode : e.which

    if (tecla == 13)
  {
     MostrarEspera(); 
     return false;
   } 
   else return true;
}

function Imprimir(Contenido, Titulo)
{
var inf = Contenido.innerHTML;
var sOption="toolbar=no,location=no,directories=no,menubar=no,"; 
    sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

var winprint=window.open("","",sOption); 
    winprint.document.open(); 
    winprint.document.write('<html><head runat=server><title>');
    winprint.document.write(Titulo);
    winprint.document.write('</title><link href=cssEstilos/cssEstiloWeb.css rel=stylesheet type=text/css /></head><body>'); 
    winprint.document.write('<form id=form1 runat=server><div>'); 
    winprint.document.write('<h4>');
    winprint.document.write(Titulo);
    winprint.document.write('</h4>');
    winprint.document.write('<asp:Panel ID=Panel runat=server>');
    winprint.document.write(inf);  
    winprint.document.write('</asp:Panel>');  
    winprint.document.write('</div></form>');          
    winprint.document.write('</body></html>'); 
    winprint.document.close(); 
    winprint.focus(); 
    winprint.print();
}

function MostrarEspera()
{

    var updateProgress1 = $get('ctl00_UpdateProgress1');
    updateProgress1.style.display = ''; 
//    $get("imgEspera").style.display="block";
}

function OcultarEspera()
{

    var updateProgress1 = $get('ctl00_UpdateProgress1');
    updateProgress1.style.display = 'none'; 
}

function menu_onclick() {
        MostrarEspera();
}

function AbrirVentana(pagina, ancho, alto, scroll)
{   
//    debugger
if (scroll == null)
    scroll = 'no';
else
    scroll = 'yes';

 setTimeout("AbrirVentana2('" + pagina + "'," + ancho + "," + alto + ",'" + scroll +"')", 1000); 
}

function AbrirVentana2(pagina, ancho, alto, scroll)
{
    var pagina;
        
    pagina = window.open(pagina, "self", "width="+ancho+", height="+alto+",top=33%, left=55%, scrollbars=" + scroll + ", resizable=no, directories=no; location=no, menubar=no, status=no, titlebar=no, toolbar=no");
    pagina.moveTo(screen.availWidth/2-(ancho/2),screen.availHeight/2-(alto/2));    //Centramos
    pagina.focus();
}


//MAPEOS
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function error(results)
{

    setTimeout("OcultarEspera()", 1000);
    if (results._message != null)    
        alert(results._message);
    else
        alert(results);
}

function FormatNumber(Numero, Decimales) 
{
	pot = Math.pow(10,Decimales);
	num = parseInt(Numero * pot) / pot;
	nume = num.toString().split('.');
	entero = nume[0];
	decima = nume[1];
	if (decima != undefined) {
		fin = Decimales-decima.length; }
	else {
		decima = '';
		fin = Decimales; }

	for(i=0;i<fin;i++)
	  decima+=String.fromCharCode(48); 

    if (Decimales > 0) {
	    num=entero+'.'+decima;
	} else {
	    num=entero;
	}

	return num;
}

    function Maximiza()
        {
        window.moveTo(0,0);
        window.resizeTo(screen.width, screen.height);
        MostrarEspera();
        setTimeout(OcultarEspera, 1000);
        }

function MenuI_ItemClick(menuId, itemId){
	//NO SE ACTIVA PARA CIERTAS OPCIONES
//	debugger

	//menuIntranet
//	if (igmenu_getElementById(itemId).accessKey != "mantenimientoTalleres" &&
//	    igmenu_getElementById(itemId).accessKey != "mantenimientos" &&
//	    igmenu_getElementById(itemId).accessKey != "areadescargas" &&
//	    igmenu_getElementById(itemId).accessKey != "otrosprocesos" &&
//	    igmenu_getElementById(itemId).accessKey != "proyectosautos" &&
//	    igmenu_getElementById(itemId).accessKey != "proyectosvida" &&
//	    igmenu_getElementById(itemId).accessKey != "accesoHost" &&
//	    igmenu_getElementById(itemId).accessKey != "facturatelematica" &&
//	    igmenu_getElementById(itemId).accessKey != "soportetecnico" &&
//	    igmenu_getElementById(itemId).accessKey != "listadocobros" &&
//	    igmenu_getElementById(itemId).accessKey != "siniestros" &&
//	    igmenu_getElementById(itemId).accessKey != "contabilidad" &&
//	    igmenu_getElementById(itemId).accessKey != "ayuda")
//	    
	    //menuWeb
	    if (igmenu_getElementById(itemId).accessKey != "mantenimientoTalleres" &&
	    igmenu_getElementById(itemId).accessKey != "mantenimientos" &&
	    igmenu_getElementById(itemId).accessKey != "facturatelematica" &&
	    igmenu_getElementById(itemId).accessKey != "soportetecnico" &&
	    igmenu_getElementById(itemId).accessKey != "utilidades" &&
	    igmenu_getElementById(itemId).accessKey != "comunicacion" &&
	    igmenu_getElementById(itemId).accessKey != "accesoHost" &&
	    igmenu_getElementById(itemId).accessKey != "presupuestos" &&	    
	    igmenu_getElementById(itemId).accessKey != "proyectosautos" &&
	    igmenu_getElementById(itemId).accessKey != "proyectosvida" &&   
	    igmenu_getElementById(itemId).accessKey != "Gpolizas" &&
	    igmenu_getElementById(itemId).accessKey != "contabilidad" &&
	    igmenu_getElementById(itemId).accessKey != "retirada" &&
	    igmenu_getElementById(itemId).accessKey != "ayuda")
	    
        	MostrarEspera();
}

//función que limita la entrada de caracteres por ejemplo en una caja de texto.
//Recibe cómo parámetro el evento (utilizado con el evento onkeypress) y los valores que se quieren permitir introducir
function permite(evento, permitidos)
{
    //debugger

    var numeros = "0123456789"
    var caracteres = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ"
    var caracteres_esp = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ "
    var numeros_caracteres = numeros + caracteres
    var permiteEspacio = "n"
    switch(permitidos)
    {
        case "num":
            permitidos = numeros
        break;

        case "car":
            permitidos = caracteres
        break;

        case "num_car":
            permitidos = numeros_caracteres
        break;
        
        case "car&esp":
            permitidos = caracteres_esp
            permiteEspacio = "s"
        break;
    }

    var evento = window.event
    var codigoCaracter = evento.keyCode
    var caracter = String.fromCharCode(codigoCaracter)

    if (permiteEspacio != "s")
        {
            if (caracter == " ")
                event.returnValue = false;
            else
                if (permitidos.indexOf(caracter) == -1)
                        event.returnValue = false;     
         }
     else
        if (permitidos.indexOf(caracter) == -1)
                        event.returnValue = false;  
  
}


