﻿// JScript File
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_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
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 MM_findObj(n, d) { //v4.01
  var p,i,x;
  if(!d) d=document;
  x = d.getElementById(n);
  if(!x){
      if (!(typeof a_str_contenedor == 'undefined'))
      {
        if (n.substring(0,5)!="ctl00")
        {
          n=a_str_contenedor + n;
        }
      }
      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 ocultar(x)
{
        MM_findObj(x).style.display='none';
}

function mostrar(x)
{
        MM_findObj(x).style.display='';
}

function pulsaNumero(e, ctr, negativo, entero, separador_decimal){   
   if(!separador_decimal)separador_decimal = ".";
   var car;
   var key = 0;
   var tecla;
   var numeros = "1234567890";
  
   var estado=true;

          if(document.all){          
              key = event.keyCode;                  
          }
          else if(document.layers){
              key = e.which; 
          }                
          else if(document.getElementById){       
              key = (window.Event) ? e.which : e.keyCode;          
          }             	
          tecla = String.fromCharCode(key);
		  		  
		  if(key > 32){ 
		   	if(numeros.indexOf(tecla) != -1){estado=true}		          
			else{estado = false} 
		  }
		  
          if(estado==false)
          {
            if(!entero){    
                if(tecla==",")tecla=separador_decimal;
		        if(tecla==separador_decimal){
		            var varctr = document.getElementById(ctr)			   
			        if((varctr.value).indexOf(separador_decimal) == -1)varctr.value = varctr.value + separador_decimal;
			    }
		        
		     }
		     
		     if(tecla=="-" && negativo){
		        var varctr = document.getElementById(ctr);
		        if((varctr.value).indexOf('-') == -1)varctr.value = "-" + varctr.value		   
			 }
		     
              if(document.all)
                  event.returnValue = estado;
              else
                  return estado;
          }
}

function colocarPuntos(num) {
    if(isNaN(num)){
        num = "0";
    }
    num = num.toString(); 
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    {
        num = num.substring(0,num.length-(4*i+3))+'.'+ num.substring(num.length-(4*i+3));
    }
    if (num.substring(0,2)=="-.")
    {
        num = "-" + num.substring(2,num.length);
    }
    return num;
}

function verNuevaVentana(url)
{
    width = 660;
    height = 600;
    iLeft = (window.screen.width - width ) / 2;
    iTop   = (window.screen.height - height ) / 2;
    window.open(url,"_blank","height="+height+", width="+width+", top="+iTop+", left="+iLeft+", scrollbars=YES, resizable=YES, toolbar=YES, menubar=YES, location=YES, status=YES;");
}	

function pulsa1(e, ctr, negativo, entero, separador_decimal){   
   if(!separador_decimal)separador_decimal = ".";
   var car
   var key = 0
   var tecla
   var numeros = "10"
  
   var estado=true

          if(document.all){          
              key = event.keyCode                        
          }
          else if(document.layers){
              key = e.which        
          }                
          else if(document.getElementById){       
              key = (window.Event) ? e.which : e.keyCode;          
          }             	
          tecla = String.fromCharCode(key);
		  		  
		  if(key > 32){ 
		   	if(numeros.indexOf(tecla) != -1){estado=true}		          
			else{estado = false} 
		  }
		  
          if(estado==false)
          {
            if(!entero){    
                if(tecla==",")tecla=separador_decimal;
		        if(tecla==separador_decimal){
		            var varctr = document.getElementById(ctr)			   
			        if((varctr.value).indexOf(separador_decimal) == -1)varctr.value = varctr.value + separador_decimal;
			    }
		        
		     }
		     
		     if(tecla=="-" && negativo){
		        var varctr = document.getElementById(ctr)
		        if((varctr.value).indexOf('-') == -1)varctr.value = "-" + varctr.value		   
			 }
		     
              if(document.all)
                  event.returnValue = estado;
              else
                  return estado;
          }
}

function isNumeric(num)
{
    num = formatoNumero(num);
    reNumeric =  /^(?:\+|-)?\d+$/;
    if(num=="")
    {
        return false;
    }
    else
    {
        return  reNumeric.test(num);
    }
}

function formatoNumero(valor)
{
    if (valor.toString().indexOf(".")!=-1)
    {
        valor=valor.replace(/\./g, "");
    }
    return parseInt(valor);
}

var menuids = ["sidebarmenu1"] //Enter id(s) of each Side Bar Menu's main UL, separated by commas

function initsidebarmenu() {
    for (var i = 0; i < menuids.length; i++) {
        var ultags = document.getElementById(menuids[i]).getElementsByTagName("ul")
        for (var t = 0; t < ultags.length; t++) {
            ultags[t].parentNode.getElementsByTagName("a")[0].className += " subfolderstyle"
            if (ultags[t].parentNode.parentNode.id == menuids[i]) //if this is a first level submenu
                ultags[t].style.left = ultags[t].parentNode.offsetWidth + "px" //dynamically position first level submenus to be width of main menu item
            else //else if this is a sub level submenu (ul)
                ultags[t].style.left = ultags[t - 1].getElementsByTagName("a")[0].offsetWidth + "px" //position menu to the right of menu item that activated it
            ultags[t].parentNode.onmouseover = function() {
                this.getElementsByTagName("ul")[0].style.display = "block"
            }
            ultags[t].parentNode.onmouseout = function() {
                this.getElementsByTagName("ul")[0].style.display = "none"
            }
        }
        for (var t = ultags.length - 1; t > -1; t--) { //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
            ultags[t].style.visibility = "visible"
            ultags[t].style.display = "none"
        }
    }
}

if (window.addEventListener)
    window.addEventListener("load", initsidebarmenu, false)
else if (window.attachEvent)
    window.attachEvent("onload", initsidebarmenu)
