﻿// JavaScript Document
//Funciones a nivel de cliente 

function existe(campo) {

   if ((typeof(campo)=="undefined") || (campo==null)) {
	   return false;
   }
   else return true;
}


function TrimRight( str ) { //rutina bajada de internet
	var resultStr = "";
	var i = 0;
	
	if (str+"" == "undefined" || str == null) 
		return null;
	str += "";
	if (str.length == 0) 
		resultStr = "";
	else {
		i = str.length - 1;
		while ((i >= 0) && (str.charAt(i) == " "))
			i--;
		resultStr = str.substring(0, i + 1);
	}
	return resultStr; 
}

function TrimLeft( str ) { //rutina bajada de internet
	var resultStr = "";
	var i = len = 0;
	
	if (str+"" == "undefined" || str == null) 
		return null;
	str += "";
	if (str.length == 0) 
		resultStr = "";
	else { 
		len = str.length;
		while ((i <= len) && (str.charAt(i) == " "))
			i++;
		resultStr = str.substring(i, len);
	}
	return resultStr;
}

function Trim( str ) { //rutina bajada de internet
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}


function fnc_sale() {
var rslt=confirm("Are you sure do you want to left the application?\nWhen the window close and log out the module you will lose the changes that you haven't  been saved.");
  if (rslt) { 
    window.close();
  }
}


function fnc_ayudar(){
	alert("There is no help for this moment...")
}



function fnc_salir(){
	    
	var rslt=confirm("Are you sure want to log out?\nThe module will lose the changes that you  haven't  been saved .");
	if (rslt) { 
	    window.location.href ="./principalUser.asp?acc=logout"
		window.close();
	}  
}


function fnc_inicio(){ 
    window.location.href ="./principalUser.asp?acc=logout"
}



function fnc_desplazarPanelInfoUsuario(pAccion){
	var panelEncabezadoInfoUsuario=document.getElementById("panelEncabezadoInfoUsuario");
	var panelEncabezadoInfoUsuarioColapsado=document.getElementById("panelEncabezadoInfoUsuarioColapsado");
	var accionPanelEncabezadoInfoUsuario= document.getElementById("accionPanelEncabezadoInfoUsuario");
		
		if(!pAccion || String(pAccion)=="undefined")
			pAccion=accionPanelEncabezadoInfoUsuario.value;
			
		switch(pAccion){
			case "expandir":
				panelEncabezadoInfoUsuario.style.display="block";
				panelEncabezadoInfoUsuario.style.visibility="visible";
				panelEncabezadoInfoUsuarioColapsado.style.display="none";
				panelEncabezadoInfoUsuarioColapsado.style.visibility="hidden";
				
				accionPanelEncabezadoInfoUsuario.value="colapsar";
			break;
			case "colapsar":
				panelEncabezadoInfoUsuario.style.visibility="hidden";
				panelEncabezadoInfoUsuario.style.display="none";
				panelEncabezadoInfoUsuarioColapsado.style.display="block";
				panelEncabezadoInfoUsuarioColapsado.style.visibility="visible";
				
				accionPanelEncabezadoInfoUsuario.value="expandir";
			break;
		}
}


function fncAcentuar(palabra) {
 
    var linea= new String;
	if ((Trim(palabra) != 'null') &&  (Trim(palabra) != null)) {
		linea = palabra.replace(/á/g, "&aacute;");
		linea = linea.replace(/é/g, "&eacute;");
		linea = linea.replace(/í/g, "&iacute;");
		linea = linea.replace(/ó/g, "&oacute;");
		linea = linea.replace(/ú/g, "&uacute;");
		linea = linea.replace(/ñ/g, "&ntilde;");
		linea = linea.replace(/Ñ/g, "&Ntilde;");
		linea = linea.replace(/Á/g, "&Aacute;");
		linea = linea.replace(/É/g, "&Eacute;");
		linea = linea.replace(/Í/g, "&Iacute;");
		linea = linea.replace(/Ó/g, "&Oacute;");
		linea = linea.replace(/Ú/g, "&Uacute;");
		linea = linea.replace(/¿/g, "&iquest;");
		linea = linea.replace(/¡/g, "&iexcl;");
		linea = linea.replace(/“/g, "&ldquo;");	
		linea = linea.replace(/°/g, "&ordm;");
		linea = linea.replace(/”/g, "&rdquo;");
		linea = linea.replace(/"/g, "&quot;");
		linea = linea.replace(/`/g, "&lsquo;");
		linea = linea.replace(/´/g, "&rsquo;");	
		return(linea);
	}
	else
		return(palabra)
   
 }
 



function disableRightClick(e)
{
  var message = "";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      //alert(message);
      return false;
    }
  }
  else
  {
    //alert(message);
    return false;
  }
}


function fnc_abreVentana(url) {
	var newWindow = window.open(url,"","status, titlebar=yes, scrollbars=3,height=580,width=620");
	newWindow.focus();
}

var e;
if (document)
  disableRightClick(e)
