var IE4, NS4, gs_LayerObj, gs_StyleObj;
var hexa = "0123465789ABCDEF";

	function SetBrowser()
{
  if (document.all)
     IE4=true;
  else
     IE4=false;

  gs_BVersion = parseInt(navigator.appVersion);

  if (document.layers)
     NS4=true;
  else
     NS4=false;

  gs_LayerObj = (NS4) ? 'document':'document.all';
  gs_StyleObj = (NS4) ? '':'.style';

}

function MuestraLayer( as_NomLayer )
{
  if (! gs_StyleObj) SetBrowser();
  
  var ls_Mostrar = (NS4)?'show':'visible';

  eval ( gs_LayerObj + '["' + as_NomLayer + '"]' + gs_StyleObj + '.visibility=ls_Mostrar');
  
}

function NumeroDecimal()
{
	if(window.event.keyCode > 57 || window.event.keyCode < 48 &&  window.event.keyCode != 44)
	{
		window.event.keyCode=0;
	}
	return window.event.keyCode;
		
}

function OcultaLayer( as_NomLayer )
{
  if (! gs_StyleObj) SetBrowser();

  var ls_Ocultar = (NS4)?'hide':'hidden';

  eval (gs_LayerObj + '["' + as_NomLayer + '"]' + gs_StyleObj+'.visibility=ls_Ocultar');
  
}

function GetUbicObj(as_object,ao_doc)
{
  var p,i,x;
  
  if(!ao_doc)
    ao_doc=top;

  if( ( p=as_object.indexOf("?") ) > 0 && parent.frames.length)
  {
    ao_doc=parent.frames[as_object.substring(p+1)].document;
    as_object=as_object.substring(0,p);
  }
  
  if( !(x=ao_doc[as_object]) && ao_doc.all)
    x=ao_doc.all[as_object];
    
  for (i=0;!x && i < ao_doc.forms.length;i++)
    x=ao_doc.forms[i][as_object];
    
  for(i=0; !x && ao_doc.layers && i < ao_doc.layers.length;i++)
    x=GetUbicObj(as_object,ao_doc.layers[i].document);

  return x;
}

function GetUbicHeader()
{
  var x

  if (x = parent.Body)
      x = parent.Header.document;
  else
      x = document;

  return x.all ? x.all:x;
}



function hd_addlink()
{ //caption, action, help, width, islayer
  var ln_poslink, ls_newHTML, lo_ubic,a=hd_addlink.arguments;
  var ls_caption, ls_action, ls_help,ls_width, lb_islayer;
  
  if ((ls_caption=a[0])==null)
     ls_caption = 'Sin Caption';
     
  if ((ls_action=a[1])==null)
     ls_action = 'alert("Sin action");return false;';

  if ((ls_help=a[2])==null)
     ls_help = '';

  if ((ls_width=a[3])==null)
     ls_witdh = '*';

  if ((ls_islayer=a[4])==null)
     ls_islayer = false;

  lo_ubic = GetUbicHeader();

  ln_poslink = lo_ubic.hd_coll_links.gmaxlink++;
  
  if (ls_action=='*')
  {
     ls_action='parent.CambiaLayer('+ln_poslink+')'
  }
  
  ls_newHTML = "<A class='linkheader' href=''";
  ls_newHTML += " onclick='" + ls_action + ";return false;'";
  ls_newHTML += " onmouseover='self.status=\"" + ls_help + "\";return true;'";
  ls_newHTML += " onmouseout='self.status=\"\";return false;'";
  ls_newHTML += " alt='" + ls_help + "'>";
  ls_newHTML += ls_caption;
  ls_newHTML += "</A>";

  lo_ubic.hd_tb_links[ln_poslink].width   = "" + ls_width;
  lo_ubic.hd_tb_links[ln_poslink].islayer = ls_islayer;
  lo_ubic.hd_links[ln_poslink].innerHTML = ls_newHTML;

return false;
}

function GetKeyCode()
{
	return window.event.keyCode;
}




			function GetFieldGldLengthRut(rut)
			{

				if(rut.value=="")

				{
				rut.value=0 

				}


				if (rut.value=="0")
				{
					return true

				}


				if(rut.value.length <= 6)
				{
					alert("Rut no valido")	
					rut.focus()
					return false

				}
				return true
			}

			function GetFieldGldRut(rut,digito,e)
			{
				var ln_ret;
				var ln_key;
				var ls_cadena;

				ln_key = (document.all) ? e.keyCode : e.which;
				
				if((ln_key > 47 && ln_key < 58)  || (ln_key > 95 && ln_key < 106))
				{
					if(ln_key > 95 && ln_key < 106)
					{
						ln_key = ln_key - 48;
					}
					ln_ret = ln_key;
				}
				else
				{
					ln_ret = 0;
				}
								
				if(rut.value.length >= 12 && ln_ret > 0)
				{
					ln_ret = 0;
					ln_key = 0;
				}
			
				if(ln_key == 46 || ln_key == 8)
				{
					ln_ret=ln_key;
					ln_key=0;
					
					if (rut.value == "" || rut.length == 1)
					{
						document.getElementById(digito).value = " ";
					}
					else
					{
						ls_cadena = rut.value;
						document.getElementById(digito).value = GetDgvRut(ls_cadena.substr(0, ls_cadena.length -1));
					}					
				}

				if(ln_key == 13 || ln_key == 9 || ln_key == 37 || ln_key == 39)
				{
						ln_key=0;
						if (rut.value == "")
						{
							rut.value = 0;
							document.getElementById(digito).value = "";
							ln_ret = 0;
							rut.focus();
						}
						else
						{
							document.getElementById(digito).value = GetDgvRut(rut.value);
							ln_ret =-1;
						}
				}

                if(ln_key > 0 && ln_ret > 0 && (rut.value + String.fromCharCode(ln_ret)) != "")
				{
					document.getElementById(digito).value = GetDgvRut(rut.value+ String.fromCharCode(ln_ret));
				}
			
				if(ln_ret == 0)
				{
					return false;
				}
				else
				{
					return true;
				}					
			}			

			function GetFieldGldRut_Nom(rut,digito)
			{
				var ln_ret
				var ln_key
				var ls_cadena

				ln_key = GetKeyCode()
                
				if((ln_key > 47 && ln_key < 58)  || (ln_key > 95 && ln_key < 106))
				{
					if(ln_key > 95 && ln_key < 106)
					{
						ln_key = ln_key - 48
					}
					ln_ret = ln_key
				}
				else
				{
					ln_ret = 0
				}
				
				
				if(document.getElementById(rut).value.length >= 12 && ln_ret > 0)
				{
					ln_ret = 0
					ln_key = 0
				}
			
				if(ln_key == 46 || ln_key == 8)
				{
					ln_ret=ln_key
					ln_key=0
					
					if (document.getElementById(rut).value == "" || document.getElementById(rut).length == 1)
					{
						document.getElementById(digito).value = ""
					}
					else
					{
					ls_cadena = document.getElementById(rut).value
					//alert(ls_cadena+"--"+ls_cadena.length+"--"+ls_cadena.substr(0, ls_cadena.length -1))
					document.getElementById(digito).value = GetDgvRut(ls_cadena.substr(0, ls_cadena.length -1))
					}
					
				}

				if(ln_key == 13 || ln_key == 9 || ln_key == 37 || ln_key == 39)
				{
						ln_key=0
						if (document.getElementById(rut).value == "")
						{
							alert("Debe ingresar un Rut de Cliente")
							document.getElementById(digito).value = ""
							ln_ret = 0
							document.getElementById(rut).focus()
						}
						else
						{
							document.getElementById(digito).value = GetDgvRut(document.getElementById(rut).value)
							ln_ret =-1
						}
				}

				//alert(ln_key + "--" +ln_ret + "--"+(document.getElementById(rut).value + String.fromCharCode(ln_ret)) )
                if(ln_key > 0 && ln_ret > 0 && (document.getElementById(rut).value + String.fromCharCode(ln_ret)) != "")
				{
					document.getElementById(digito).value = GetDgvRut(document.getElementById(rut).value+ String.fromCharCode(ln_ret))
				}
			
				if(ln_ret == 0)
				{
					return false
				}
				else
				{
					return true
				}
				//return ln_ret
					
			}

function GetFieldRut()
			{
				var ln_ret
				var ln_key
				var ls_cadena

				ln_key = GetKeyCode()
				if((ln_key > 47 && ln_key < 58)  || (ln_key > 95 && ln_key < 106))
				{
					if(ln_key > 95 && ln_key < 106)
					{
						ln_key = ln_key - 48
					}
					ln_ret = ln_key
				}
				else
				{
					ln_ret = 0
				}

				if(document.form1.an_rut_cliente.value.length >= 12 && ln_ret > 0)
				{
					ln_ret = 0
					ln_key = 0
				}

				if(ln_key == 46 || ln_key == 8)
				{
					ln_ret=ln_key
					ln_key=0
					
					if (document.form1.an_rut_cliente.value == "" || document.form1.an_rut_cliente.length == 1)
					{
						document.form1.ac_digito.value = ""
					}
					else
					{
					ls_cadena = document.form1.an_rut_cliente.value
					//alert(ls_cadena+"--"+ls_cadena.length+"--"+ls_cadena.substr(0, ls_cadena.length -1))
					document.form1.ac_digito.value = GetDgvRut(ls_cadena.substr(0, ls_cadena.length -1))
					}
				}

				if(ln_key == 13 || ln_key == 9)
				{
						ln_key=0
						if (document.form1.an_rut_cliente.value == "")
						{
							alert("Debe ingresar un Rut de Cliente")
							document.form1.ac_digito.value = ""
							ln_ret = 0
							document.form1.an_rut_cliente.focus()
						}
						else
						{
							document.form1.ac_digito.value = GetDgvRut(document.form1.an_rut_cliente.value)
							ln_ret =-1
						}
				}

				//alert(ln_key + "--" +ln_ret + "--"+(document.form1.an_rut_cliente.value + String.fromCharCode(ln_ret)) )
                if(ln_key > 0 && ln_ret > 0 && (document.form1.an_rut_cliente.value + String.fromCharCode(ln_ret)) != "")
				{
					document.form1.ac_digito.value = GetDgvRut(document.form1.an_rut_cliente.value+ String.fromCharCode(ln_ret))
				}
			
			if(ln_ret == 0)
				{
					return false
				}
				else
				{
					return true
				}
				//return ln_ret
			} 

function GetDgvRut(crut)
{
  var dvr = '0';

  suma = 0;
  mul  = 2;
  if(crut.length==0)
  {
	dvr="";
	return dvr;
  }		

  if(crut=='0')
  {
	dvr="";
	return dvr;
  }		

  for (i= crut.length-1 ; i >= 0; i--)
  {
    suma = suma + crut.charAt(i) * mul;
    if (mul == 7)
      mul = 2;
    else
      mul++;
  }


  res = suma % 11;
  if (res==1)
    dvr = 'K';
  else if (res==0)
    dvr = '0';
  else
{
    dvi = 11-res;
    dvr = dvi + "";
  }

   return dvr;
}



function CambiaLayer(NroLayer)
{

  var ciclo,ln_maxlink,lo_ubic, ctalayer;
  
  ctalayer=0;
  
  lo_ubic = GetUbicHeader();
  
  ln_maxlink = lo_ubic.hd_coll_links.gmaxlink ;

/*
  if (parent.Body.Tabs[0].style)
     alert("Existe el [obj.style]");
  else
     alert("No existe el [obj.style]");
*/
  
  for (ciclo=ctalayer=0; ciclo < ln_maxlink;ciclo++)
    if (lo_ubic.hd_tb_links[ciclo].islayer == true)
       parent.Body.Tabs[ciclo].style.visibility = "hidden";

  for (ciclo=ctalayer=0; ciclo < ln_maxlink;ciclo++)
  {
    if (lo_ubic.hd_tb_links[ciclo].islayer == true)
      if (ctalayer++==NroLayer)
        parent.Body.Tabs[NroLayer].style.visibility = "visible";
  }    

return false;
}


function hd_settitulo(as_caption)
{
  var lo_ubic;
  
  lo_ubic = GetUbicHeader();

  lo_ubic.hd_titulo.innerHTML = as_caption;

  return false;
}

function hd_setboton(as_caption)
{
  var lo_ubic;
  
  lo_ubic = GetUbicHeader();

  lo_ubic.hd_boton.innerHTML = as_caption;
  
  return false;
}

function hd_setbotonera(as_caption)
{
  var lo_ubic;
  
  lo_ubic = GetUbicHeader();

  lo_ubic.hd_botonera.innerHTML = as_caption;

  return false;
}


        
function DecToHexa(DecNb) 
{
	x = Math.floor(DecNb / 16);
    h = hexa.charAt(x);
    x = DecNb % 16;
    h += hexa.charAt(x);
    return h;
}
/*

Como Ocupar Funcion Degrade:
	1.- colocar el siguiente codigo entre <head>....</head>
	
		<script Language="JavaScript" src="../Inc/utiles.js"></script>
		
	2.-	Los tres primeros valores de este c?o corresponden a valores RGB del color de 
		inicio (aqu?rojo 255,0,0). Los tres siguientes valores corresponden a valores 
		RGB del color sombreado final (aqu?azul 0,0,255). Coloque simplemente su texto 
		entre comillas despu?de estos valores.
		
		<SCRIPT LANGUAGE = "JavaScript">
			Degrade(255,0,0,0,0,255,"a multi-colored, shadowed text! ");
		</SCRIPT>
*/

function Degrade(dr,dg,db,fr,fg,fb,texte) 
{
	steps = texte.length;
    cr = dr; cg = dg; cb = db;
    sr = (fr - dr) / steps;
    sg = (fg - dg) / steps;
    sb = (fb - db) / steps;
    for (var x = 0; x <= steps; x++) 
    {
		document.write('<FONT COLOR="#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb) + '">');
        document.write(texte.charAt(x));
        document.write('</FONT>');
        cr += sr; cg += sg; cb += sb;
	}
}

/*
	Como Ocupar: Permite colocar en Color cuando te posicionas con el mouse
	<table onMouseover="changeto('flyover_colour')" onMouseout="changeback('default_colour')">
		Aqui van las celdas TR y TD
	</table>


*/
function changeto(highlightcolor)
{
	source=event.srcElement
	if (source.tagName=="TR"||source.tagName=="TABLE"||source.tagname=="INPUT")
		return
	while(source.tagName!="TD")
		source=source.parentElement
		if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
		source.style.backgroundColor=highlightcolor
}
function changeback(originalcolor)
{
	if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")
		return
	if (event.toElement!=source)
		source.style.backgroundColor=originalcolor
}


var winheight=100
var winsize=100
var x=5
var mylocation2

function go(mylocation,name,ancho,alto,scroll)
{
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	opciones = 'height='+ alto + ',width=' + ancho + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
	win2=window.open(mylocation,"",opciones)
	//function NewWindow(pagina,titulo,ancho,alto,scroll)
	//win = top.open(pagina,titulo,opciones)
	//onclick="NewWindow(this.href,'name','650','450','yes');return false"
  	if (!document.layers&&!document.all)
	{
		win2.location=mylocation
		return
	}
	win2.resizeTo(0,0)
	win2.moveTo(LeftPosition,TopPosition)
	go2(ancho,alto)
}
function go2(ancho,alto)
{
	LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-alto)/2 : 0;
	//if (winheight>=screen.availHeight-3)
	if (winheight>=TopPosition-3)
		x=0
	win2.resizeBy(10,x)
	winheight+=10
	winsize+=10
	//alert(winsize)
	//alert(screen.width)
	//if (winsize>=screen.width-5)
	if (winsize>=650)
	{
		//win2.location="www.google.cl"
		winheight=100
		winsize=100
		x=5
		return
	}
	tiempo="go2(" + ancho + "," + alto + ")"
	setTimeout(tiempo,10)
}


		function Numero()
		{
			if(window.event.keyCode > 57 || window.event.keyCode < 48)
			{
				window.event.keyCode=0;
			}
			return window.event.keyCode;
		
		}
		
		function NumeroHora()
		{//alert(window.event.keyCode);//alert(window.event.shiftKey);
		    s_key=window.event.keyCode;
		    if(window.event.shiftKey&&s_key==58)
		    {
		        window.event.keycode=s_key;
		        return window.event.keyCode;
		     }   
			if(window.event.keyCode > 57 || window.event.keyCode < 48 )
			{
				window.event.keyCode=0;
			}
			
			return window.event.keyCode;    
		
		}
		
		
    		function Texto(objeto)
		{

			if ((window.event.keyCode > 64 && window.event.keyCode < 91) || (window.event.keyCode > 96 && window.event.keyCode < 123))
			{
				return window.event.keyCode;	
			}
			window.event.keyCode=0;
		}				
		
		
		
		function ValidaIngresoRUT(elemrut)
		{
			if (elemrut.value=="")
			{
				alert ("Rut no Ingresado");
				return false;
			}
			return true;
		}
		
	//formatCurrency(num) : Formatea numero a moneda
//          Uso: var moneda=formatCurrency(1500.9) //devuelve moneda='1.500,9'

    function formatCurrency(num)
    {
        //alert(num)
        var lb_isneg=false;
        if(parseFloat(num)<0)lb_isneg=true;
        num = num.toString();
        num=num.replace('.','');
        num=num.replace(',','.');
        if(isNaN(num)){
            num = "0";
            return num;
            }
        var rexp=/[1234567890]/g;
       // var rexp=/\d+/g;
        var ar=num.match(rexp)
        
        if(!ar||ar.length<1)return 0;
        ret='';
        ar=ar.reverse(); 
        for(i=0;i<ar.length;i++)
        {
               if((i+1)%3==0&&i!=ar.length-1)ar[i]='.'+ar[i];
               ret=ar[i]+ret;
        }
        if(lb_isneg)ret='-'+ret;
        return ret;
    }
		
		
		function formatDecimal(num)
		{
			
		if(num=="")
		 {
	 	  num =0 
	 	 }
	 	 else
		{
		  num = parseFloat(num)
		  //alert(num)
		  dec= num-parseInt(num)
		  num=num-dec
	 	 dec=dec.toString()
	 	 if(dec.length>0)
	 	 {dec=dec.slice(2,dec.length);
	 	 
	 	 }
	 	 else{dec='';}
	 	 
	 	 
		  num=num.toString()
		  num = num.replace(/\ |\,/g,'');
		  num=num.replace(/\ |\./g,'');
		  

		  
		  cents = Math.floor((num*100+0.5)%100);
		  
		  if(cents < 10) 
		    cents = "0" + cents;
		    
		  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(dec.length>0){
		  return (num+','+dec.slice(0,2) )}
	    else{return (num);}
		} 
		
		
		function LimpiaIngresoCero(objeto)
		{
		  //ValidaIngresoNum
			if ((objeto.value==0) || (objeto.value=="0"))
			{
				objeto.value=""
				//objeto.style.background="#cccccc"
				objeto.style.backgroundColor="#ffd794";
				objeto.style.textdecoration="underline";
				objeto.style.color="blue";
			}
		}
		
			function HabilitaIngresoCero(objeto)
			{
			  //ValidaIngresoNum
				if (objeto.value=="")
				{
					objeto.value=0
				}
				objeto.style.background="white"
				objeto.style.color="black";
			}
		
		function NumeroDVRUT()
		{
			// 75	=	K
			// 107	=	k
			if((window.event.keyCode > 57 || window.event.keyCode < 48)& window.event.keyCode!=107 & window.event.keyCode!=75)
			{
				window.event.keyCode=0;
			}
			
			if(window.event.keyCode==107)
			{
				window.event.keyCode=75;
			}
			
			
			return window.event.keyCode;
			
		}
		
		function NumeroTel()
		{
			// 40 = (
			// 41 = )
			// 45 = -
			if((window.event.keyCode > 57 || window.event.keyCode < 48)& window.event.keyCode!=40 & window.event.keyCode!=41 & window.event.keyCode!=45)
			{
				window.event.keyCode=0;
			}
			return window.event.keyCode;
		}

		function NumeroExp()
		{
			// 40 = (
			// 41 = )
			// 45 = -
			if((window.event.keyCode > 57 || window.event.keyCode < 48) && window.event.keyCode!=45)
			{
				window.event.keyCode=0;
			}
			return window.event.keyCode;
		}
		
		function Fecha()
		{

			if((window.event.keyCode > 57 || window.event.keyCode < 48) && window.event.keyCode!=45)
			{
				window.event.keyCode=0;
			}
			
	
			return window.event.keyCode;		
		}



		function Fecha30()
		{
			var fecha, hoy,rehoy;                    
			proxima = new Date(hoy.getYear(),hoy.getMonth()+1 ,hoy.getDate())
			return true;               
		}

		function ComparaFecha(elem){

			if(!ValidaFecha(elem)){
				return false;
			}

			
			var fecha, hoy,rehoy;                    //Declare variables.
			hoy= new Date();
			var s=elem.value;
			var re=/-/g;
			var i=s.search(re);
			var dia=s.substr(0,i);
			s=s.substr(i+1);
			i=s.search(re);
			var mes=s.substr(0,i)-1;
			var ano=s.substr(i+1);
			fecha = new Date(ano,mes,dia);
			rehoy = new Date(hoy.getYear(),hoy.getMonth() ,hoy.getDate()) 
			if(Date.parse(fecha) < Date.parse(rehoy))
			{
				alert("La fecha ingresada debe ser mayor o igual que Hoy");
				return false;
			}
			return true;               

		}


	function ValidaFecha(elem)
	{
			if (elem.value.length == 0) 
			{
				//alert("Fecha no Puede Ser vacia");
				//return false;
			}

			var iDate = Date.parse(elem.value);
			if (isNaN(iDate))
			{
				alert("Fecha no v" + "a" + "lida Debe ser dd-mm-aaaa");
				elem.value=""
				return false;
			}
			
			var Meses = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
			var Dias = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
			var s=elem.value;
			var re=/-/g;
			var i=s.search(re);
			var dia=s.substr(0,i);
			s=s.substr(i+1);
			i=s.search(re);
			var mes=s.substr(0,i);
			var ano=s.substr(i+1);
	
			if( parseInt(ano) > 2050)
			{
				alert("Fecha incorrecta");
				elem.value=""
				return false;
			}


			if( parseInt(mes) > 12)
			{
				alert("Fecha incorrecta");
				elem.value=""
				return false;
			}

			if( parseInt(dia) > Dias[parseInt(mes)-1])
			{
				alert("Fecha incorrecta");
				elem.value=""
				return false;
			}
			if(dia.length == 1)
			{
				dia="0"+dia;
			}	
			if(mes.length == 1)
			{
				mes="0"+mes;
			}	

			if(ano.length <= 2)
			{
				if(ano.length == 1)
				{
					ano= "0" + ano;
				}
				if(parseInt(ano) > 50)
				{
					ano= "19" + ano;
				}
				else
				{
					ano= "20" + ano;
				}
				
			}	

			elem.value=dia + "-" + mes + "-" + ano;
			return true;
	}
	function validaRut(elemrut,elemdv)
		{
			var ls_dgv;
			var ls_rut;
			//var ls_rut = rut;
			
			if (elemdv.value=="")
			{
				alert ("Digito Verificador no Ingresado");
				return false;
			}
			
			ls_rut=(elemrut.value + elemdv.value);
				ls_rut = ls_rut.replace(/[-. ]/g, "");
				ls_dgv = ls_rut.substring( ls_rut.length - 1, ls_rut.length );
				ls_rut = ls_rut.substring( 0, ls_rut.length - 1 );
				ls_dgv = ls_dgv.toUpperCase();
				if ( calculaRutDv( ls_rut ) == ls_dgv && calculaRutDv( ls_rut ) != '')
				{
					return true;
				}
				else 
				{
					alert("El rut ingresado no es correcto");
					return false;
				}
		}

		function PintaDigVerif(rut)
		{
			if ( calculaRutDv( rut ) != '')
			{
				document.MyForm.Rut.value = rut
				document.MyForm.DigVerif.value = calculaRutDv( rut )
				return true;
			}
		}

		function calculaRutDv(as_rut )
		{
			var ln_rut
			var li_multiplicador	//2,3,4,5,6,7,2,... (0->5)+2 --> mod 6
			var lc_digito
			var li_digito
			var li_lenrut
			var li_i		
			var li_suma	
			
			//if (form1.RUTABOGADO.value=="")
			//{
			//	//alert ("Rut no Ingresado");
			//	return false;
			//}
			//if (form1.DIGVERPROCURADOR.value=="")
			//{
			//	//alert ("Digito Verificador no Ingresado");
			//	return false;
			//}
	
			ln_rut = as_rut.replace(/[-. ]/g, "");
			if (isNaN(ln_rut) || ln_rut==0 || ln_rut=="")
			{
				alert("El Rut ingresado no es un valor numerico");
				document.MyForm.Rut.value = ""
				document.MyForm.Rut.focus()
				return false;
			}
			else
			{
				li_multiplicador = 0;
				li_suma          = 0;
				li_lenrut        = ln_rut.length;
				for( li_i = li_lenrut; li_i > 0; li_i-- )
				{
					li_digito        = ln_rut.substring( li_i - 1, li_i );
					li_suma          = li_suma + li_digito * (li_multiplicador + 2);
					li_multiplicador = (li_multiplicador + 1) % 6;
				}

				li_suma = li_suma  % 11;
				li_suma = 11 - li_suma;
  
				switch( li_suma ) 
				{
					case 10: lc_digito = 'K'; break;
					case 11: lc_digito = '0'; break;
					default:	lc_digito = li_suma;
				}
				return lc_digito;
			}
		}	
		
		
	    function EnviaDatos(wMenu,WOpcion)
		{
			//alert("Prueba")
			window.parent.HeaderEjecutivos.MenuContexto.innerHTML=wMenu
			window.parent.HeaderEjecutivos.MenuOpcionContexto.innerHTML=WOpcion
	    }
	    function EnviaDatos2(wMenu,WOpcion)
		{
			//alert("Prueba")
			window.parent.parent.parent.HeaderEjecutivos.MenuContexto.innerHTML=wMenu
			window.parent.parent.parent.HeaderEjecutivos.MenuOpcionContexto.innerHTML=WOpcion
	    }
	    
		function ColorFila(aTable,acolor) 
		{
		var lbgrColor
	
		lbgrColor = aTable.style.backgroundColor
	
		source=event.srcElement
		if (source.tagName=="TABLE"||source.tagname=="INPUT")
			return

		while(source.tagName!="TR")
   		    source=source.parentElement

			if (source.style.backgroundColor!=acolor&&source.id!="ignore")

			for (i=0; i < aTable.rows.length; i++) {
					if (aTable.rows(i).style.backgroundColor!=lbgrColor)
						aTable.rows(i).style.backgroundColor = lbgrColor;
			}

			source.style.backgroundColor=acolor
		}

		function BarraContextoMenu(wMenu,wOpcion,wSeleccion)
		{
			//alert("Menu->" + wMenu )
			//alert("Opcion->" + wOpcion )
			//alert("Seleccion->" + wSeleccion )
			
			//document.write('<FONT COLOR="#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb) + '">');
			//document.write(texte.charAt(x));
			//document.write('</FONT>');
			
			if ((wMenu!="") && (wMenu!=""))
			{
			 document.write('<table WIDTH="100%" HEIGHT="45" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" bgcolor=#7AA1E6>');
				document.write('<tr>');
			      document.write('<td width="1%"></td>');
			      document.write('<td width="20%" ><font color="WHITE" style="background-repeat:repeat-x; font-size:16pt; font-family:Tahoma" title="' + wMenu + '">');
			    	document.write('<img width="30" height="30" src="../images/xpicon1_s.gif"/>');
			    	document.write('<i>' + wMenu + '</i></font>');
			      document.write('</td>');
			      document.write('<td width="50%"><font color="WHITE" style="background-repeat:repeat-x; font-size:10pt;font-family:bold tahoma " title="' + wOpcion + '">');
			    	document.write('<img width="20" height="20" src="../images/fl1.gif"/>');
			      	document.write('<b><I>' + wOpcion + '</I></b></font>');
			      document.write('</td>');
			    document.write('</tr>');
			 document.write('</table>');
			 document.write('<table WIDTH="100%" HEIGHT="20" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" bgcolor=#6699cc>');
			    document.write('<tr>');
			      document.write('<td>');
			    	document.write('<font color="WHITE" style="background-repeat:repeat-x; font-size:10pt;font-family:bold tahoma " title="' + wSeleccion + '">');
			    	document.write('<img width="20" height="20" src="../images/Point04.ico"/>');
			    	document.write('<I>' + wSeleccion + '</I></font>');
			      document.write('</td>');
			    document.write('</tr>');
			 document.write('</table>');
			}
			 
	    }
	function Asigna_FechaDtPicker(Ano, Mes, Dia, Objeto)
	{
		var tiempo = new Date(Ano, Mes-1, Dia)
		Objeto.Year  = tiempo.getFullYear();
		Objeto.Day   = 1;
		Objeto.Month = tiempo.getMonth()+1;
		Objeto.Day   = tiempo.getDate();
 	}
 	
	

	function CompararFechasDtPicker(elem1,elem2,mensaje){

	if(!ValidaFechaDtPicker(elem1)){
		return false;
	}
	if(!ValidaFechaDtPicker(elem2)){
		return false;
	}

	var fecha1, fecha2, hoy, rehoy;                    
	//var s1=elem1.value;
	var s1=elem1;
	var re=/-/g;
	var i1=s1.search(re);
	var dia1=s1.substr(0,i1);
	s1=s1.substr(i1+1);
	i1=s1.search(re);
	var mes1=s1.substr(0,i1)-1;
	var ano1=s1.substr(i1+1);

	//var s2=elem2.value;
	var s2=elem2;
	var re=/-/g;
	var i2=s2.search(re);
	var dia2=s2.substr(0,i2);
	s2=s2.substr(i2+1);
	i2=s2.search(re);
	var mes2=s2.substr(0,i2)-1;
	var ano2=s2.substr(i2+1);
	fecha1 = new Date(ano1,mes1,dia1);
	fecha2 = new Date(ano2,mes2,dia2) ;
	//alert("fecha1->" + fecha1)
	//alert("fecha2->" + fecha2)
	if(Date.parse(fecha1) > Date.parse(fecha2))
	{
		alert(mensaje);
		return false;
	}
	return true;
	}               


	
	
	
	function ValidaFechaDtPicker(elem)
	{
			if (elem.length == 0) 
			{
				alert("Fecha no Puede Ser vacia");
				return false;
			}

			var iDate = Date.parse(elem);
			if (isNaN(iDate))
			{
				alert("Fecha no v" + "a" + "lida Debe ser dd-mm-aaaa");
				//elem.value=""
				return false;
			}
			
			var Meses = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
			var Dias = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
			//var s=elem.value;
			var s=elem;
			var re=/-/g;
			var i=s.search(re);
			var dia=s.substr(0,i);
			s=s.substr(i+1);
			i=s.search(re);
			var mes=s.substr(0,i);
			var ano=s.substr(i+1);
	
			if( parseInt(ano) > 2050)
			{
				alert("Fecha incorrecta");
				//elem.value=""
				return false;
			}

			if( parseInt(mes) > 12)
			{
				alert("Fecha incorrecta");
				//elem.value=""
				return false;
			}

			if( parseInt(dia) > Dias[parseInt(mes)-1])
			{
				alert("Fecha incorrecta");
				//elem.value=""
				return false;
			}
			if(dia.length == 1)
			{
				dia="0"+dia;
			}	
			if(mes.length == 1)
			{
				mes="0"+mes;
			}	

			if(ano.length <= 2)
			{
				if(ano.length == 1)
				{
					ano= "0" + ano;
				}
				if(parseInt(ano) > 50)
				{
					ano= "19" + ano;
				}
				else
				{
					ano= "20" + ano;
				}
				
			}	

			//elem.value=dia + "-" + mes + "-" + ano;
			return true;
	}

	function DisplayFechaDtPicker(Objeto)
	{
		var tiempo = new Date(Objeto.value); 
		var dn = new Number(Objeto.value);
		
		var dia = "00" + tiempo.getDate();
		dia = dia.substr( dia.length - 2, 2 );
		var mes = "00" + (tiempo.getMonth() + 1);
		mes = mes.substr( mes.length - 2, 2 )
		var ano = "0000" + tiempo.getFullYear()
		ano = ano.substr( ano.length - 4, 4 );

		var fecha = ano + mes + dia
		return fecha
	}

	function DisplayFechaDtPicker_DDMMYYYY(Objeto)
	{
		var tiempo = new Date(Objeto.value); 
		var dn = new Number(Objeto.value);
		
		var dia = "00" + tiempo.getDate();
		dia = dia.substr( dia.length - 2, 2 );
		var mes = "00" + (tiempo.getMonth() + 1);
		mes = mes.substr( mes.length - 2, 2 )
		var ano = "0000" + tiempo.getFullYear()
		ano = ano.substr( ano.length - 4, 4 );

		var fecha = dia + "-" +  mes + "-" + ano
		return fecha
	}


	function ComparaFechaDtPicker(elem){

		if(!ValidaFechaDtPicker(elem)){
			return false;
		}

			
		var fecha, hoy,rehoy;                    //Declare variables.
		hoy= new Date();
		//var s=elem.value;
		var s=elem;
		var re=/-/g;
		var i=s.search(re);
		var dia=s.substr(0,i);
		s=s.substr(i+1);
		i=s.search(re);
		var mes=s.substr(0,i)-1;
		var ano=s.substr(i+1);
		fecha = new Date(ano,mes,dia);
		rehoy = new Date(hoy.getYear(),hoy.getMonth() ,hoy.getDate()) 
		if(Date.parse(fecha) < Date.parse(rehoy))
		{
			alert("La fecha ingresada debe ser mayor o igual que hoy");
			return false;
		}
		return true;               
	}
	
		function ActivaTabs()
		{
			//alert("Menu->" + wMenu )
			//alert("Opcion->" + wOpcion )
			//alert("Seleccion->" + wSeleccion )
			
			//document.write('<FONT COLOR="#' + DecToHexa(cr) + DecToHexa(cg) + DecToHexa(cb) + '">');
			//document.write(texte.charAt(x));
			//document.write('</FONT>');
			document.write('<HTML>');
			document.write('<HEAD>');
			   document.write('<link REL="stylesheet" HREF="css/StyleTabs.css" TYPE="text/css">');
			   document.write('<script Language="JavaScript" src="js/StyleTabs.js"></script>');
			document.write('</HEAD>');
			document.write('<BODY>');
				document.write('<div class="tabBox" style="clear: both;">');
				document.write('</div>');
			document.write('</BODY>');
			document.write('</HTML>');
	    }

   	function cuentacaracteres(obj_area,obj_input,tope)
	{ 
		var string_observacion
		if (obj_area.value.length<=tope)
		{
			obj_input.value=obj_area.value.length 
		}
		else
		{
			string_observacion=obj_area.value
			obj_area.value=string_observacion.substring(0,tope)
		}
	} 


function QuitaBoton(tid)
	{
	 //---------------------------------------
	 //Quita un Boton de la botonera
	 //-Asume: tabla id='botonera' con al menos un <tr>
	 //-Parametros: id del boton a eliminar
	 //-Ej: QuitaBoton('elBoton')
	 //-------------------------------------
		var tabla=document.getElementById('botonera')
		if(document.getElementById(tid))
		{
			
			tabla.rows[0].removeChild(document.getElementById(tid))
			return true
		}
		else	
		{
			//alert('El Boton no existe')
			return false
		}
	  
	}//QuitaBoton
	
	function AgregaBoton(nimage,src,alt,oncl,antesde,classname,tablaid)
	{
	 //---------------------------------------
	 //Agrega un Boton de la botonera
	 //-Asume: tabla id='botonera' con al menos un <tr>
	 //-Parametros: 
	 //			nimage=id del boton a crear
	 //			src= source de la imagen del boton
	 //			alt= tooltip del boton
	 //			oncl= accion a realizar OnClick
	 //			antesde= id del boton que va despues del
	 //					nuevo boton.Si no se especifica
	 //					o no existe el boton se crea al 
	 //					final de la tabla
	 //-Ej: AgregaBoton('nuevoBoton','images/boton.gif','mi boton','return alert("boton")','previoboton')
	 //-------------------------------------
	  if(document.getElementById(nimage))
	  {
			//alert('El Boton ya existe')
			return false
	  }
	  
	  var ntd=document.createElement('td')
	  ntd.setAttribute('id',nimage)
	  ntd.setAttribute('width','3%')
	  ntd.setAttribute('align','right')
	  if(classname==null)
	  {
	   	  ntd.className="header"
	  }else{ 	  
		  ntd.className=classname
		}  
		
	  ntd.style.cursor="HAND"
	  ntd.innerHTML="<Div Style='Border:None;Width:1%;' onMouseOver='this.style.border=\"2px outset\";this.style.backgroundColor=\"#ffd497\";' onMouseOut='this.style.border=\"none\";this.style.backgroundColor=\"transparent\";'><img src='"+src+"' alt='"+alt+"' onClick='"+oncl+"' /></Div>"
	  if(tablaid==null)
	  {
	   	  var tabla=document.getElementById('botonera')
	  }else{ 	  
		  var tabla=document.getElementById(tablaid)
		}  
	
	  //var tabla=document.getElementById('botonera')
	  if(document.getElementById(antesde))
	  {
		//tabla.rows[0].insertBefore(ntd,document.getElementById(antesde))
        el=document.getElementById(antesde);
        lrow=el.parentNode;
        lrow.insertBefore(ntd,el)
        //lrow.previousSibling.lastChild.colspan=lrow.previousSibling.lastChild.colspan?lrow.previousSibling.lastChild.colspan+1:2;
		}else{
		tabla.rows[0].appendChild(ntd)
		}
	  return true
	}//AgregaBoton
	
	function AgregaSep(nimage,antesde,tipo,src)
	{
	 //---------------------------------------
	 //Agrega un Boton Separador de la botonera
	 //-Asume: tabla id='botonera' con al menos un <tr>
	 //-Parametros: 
	 //			nimage=id del separador a crear
	 //			antesde= id del boton que va despues del
	 //					separador.Si no se especifica
	 //					o no existe el separador se crea al 
	 //					final de la tabla
	 //			tipo=1:imagen,2:blanco
	 //-Ej: AgregaSep('sep','botonanterior',1,'images/sep.ico')
	 //-------------------------------------
	  if(document.getElementById(nimage))
	  {
			//alert('El Boton ya existe')
			return false
	  }
	  
	  var ntd=document.createElement('td')
	  ntd.setAttribute('id',nimage)
	  ntd.setAttribute('width','1%')
	  ntd.setAttribute('align','right')
	  ntd.className="header"
	  
	  if((src==null)||(src==""))
	  {
		src="images/sep.ico"
	  }
	  switch(tipo)
	  {  case 1:{ ntd.innerHTML="<img src='"+src+"' />";break;}
	     case 2:{ ntd.setAttribute('width','3%')
				ntd.innerHTML="&#160;&#160;";
				break;
				}
		default:{ ntd.innerHTML="<img src='"+src+"' />";break;}
	 }		
	  var tabla=document.getElementById('botonera')
	  if(document.getElementById(antesde))
	  {
		tabla.rows[0].insertBefore(ntd,document.getElementById(antesde))
		}else{
		tabla.rows[0].appendChild(ntd)
		}
	  return true
	}//AgregaSep
	
	function HabDesRolGestor(rolgestor,parametro,objeto)
	{
		if (rolgestor==parametro)
		{
			 //alert("Prueba Usuario " + parametro + " no tiene acceso a Financiamiento")
			 objeto.style.display = "none"
		}
	}
	
	/** Funcion Separadora de Miles.  */
	function formatMiles(num) {
	  num = num.toString().replace(/\$|\,/g,'');
	  if(isNaN(num))
	    num = "0";
	  sign = (num == (num = Math.abs(num)));
	  num = Math.floor(num*100+0.50000000001);
	  cents = num%100;
	  num = Math.floor(num/100).toString();
	  if(cents<10)
	    cents = "0" + cents;
	  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));
	  return (((sign)?'':'-') + num );
	}

	function pageWidth() 
    {
    //Devuelve ancho del documento. CrossBrowser    
        return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;
    }
	function pageHeight() 
	{
	//Devuelve alto del document. CrossBrowser        
	    return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;
	}
	
	function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "-";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   alert("fecha-> " + field.value)
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Fecha Incorrecta");
      DateField.select();
	  DateField.focus();
   }
}
/** Funcion Valida Cualquier Rut.  */	
function GetFieldRut_n(an_rut,ac_dv)
			{
				var ln_ret
				var ln_key
				var ls_cadena

				ln_key = GetKeyCode()
				if(ln_key == 0)
				{
  				  ac_dv.value = GetDgvRut_n(an_rut.value)
				}

				if((ln_key > 47 && ln_key < 58)  || (ln_key > 95 && ln_key < 106))
				{
					if(ln_key > 95 && ln_key < 106)
					{
						ln_key = ln_key - 48
					}
					ln_ret = ln_key
				}
				else
				{
					ln_ret = 0
				}

				if(an_rut.value.length >= 12 && ln_ret > 0)
				{
					ln_ret = 0
					ln_key = 0
				}

				if(ln_key == 46 || ln_key == 8)
				{
					ln_ret=ln_key
					ln_key=0
					
					if (an_rut.value == "" || an_rut.length == 1)
					{
						ac_dv.value = ""
					}
					else
					{
					ls_cadena = an_rut.value
					//alert(ls_cadena+"--"+ls_cadena.length+"--"+ls_cadena.substr(0, ls_cadena.length -1))
					ac_dv.value = GetDgvRut_n(ls_cadena.substr(0, ls_cadena.length -1))
					}
				}

				if(ln_key == 13 || ln_key == 9)
				{
						ln_key=0
						if (an_rut.value == "")
						{
							alert("Debe ingresar un Rut de Cliente")
							ac_dv.value = ""
							ln_ret = 0
							an_rut.focus()
						}
						else
						{
							ac_dv.value = GetDgvRut_n(an_rut.value)
							//ac_dv.value = GetDgvRut_n(ls_cadena)
							ln_ret =-1
						}
				}

				//alert(ln_key + "--" +ln_ret + "--"+(an_rut.value + String.fromCharCode(ln_ret)) )
                if(ln_key > 0 && ln_ret > 0 && (an_rut.value + String.fromCharCode(ln_ret)) != "")
				{
					ac_dv.value = GetDgvRut_n(an_rut.value+ String.fromCharCode(ln_ret))
				}
			
			if(ln_ret == 0)
				{
					return false
				}
				else
				{
					return true
				}
				//return ln_ret
			} 



function GetDgvRut_n(crut)
{
  var dvr = '0';

  suma = 0;
  mul  = 2;
  if(crut.length==0)
  {
	dvr="";
	return dvr;
  }		

  if(crut=='0')
  {
	dvr="";
	return dvr;
  }		

  for (i= crut.length-1 ; i >= 0; i--)
  {
    suma = suma + crut.charAt(i) * mul;
    if (mul == 7)
      mul = 2;
    else
      mul++;
  }


  res = suma % 11;
  if (res==1)
    dvr = 'k';
  else if (res==0)
    dvr = '0';
  else
{
    dvi = 11-res;
    dvr = dvi + "";
  }

   return dvr;
}
function ValidaIngAlfa(objeto)
{
	/*
	alert("Valor-> " + objeto.value)
	var string = objeto.value
	
	alert("Ultimo-> " + string.substring(string.length,string.length-1))
	var i
	var p=0
	var c=0
	var a=0
	for(i=0; i<string.length; i++) 
	{
		alert(" Valor -> " + i + " = " + string.substring(i, i+1));
		if (string.substring(i, i+1)==".")
		{
			p=p+1;
		}
		if (string.substring(i, i+1)==",")
		{
			c=c+1;
		}
		if (string.substring(i, i+1)=="'")
		{
			a=a+1
		}
	}
	alert("p-> " + p)
	if ((window.event.keyCode > 64 && window.event.keyCode < 91) || (window.event.keyCode > 96 && window.event.keyCode < 123) || (window.event.keyCode == 46) || (window.event.keyCode == 44) || (window.event.keyCode == 39) && (p==0))
	*/
	
	if ((window.event.keyCode > 64 && window.event.keyCode < 91) || (window.event.keyCode > 96 && window.event.keyCode < 123) || (window.event.keyCode == 46) || (window.event.keyCode == 44) || (window.event.keyCode == 39))
	{
		return window.event.keyCode;	
	}
	window.event.keyCode=0;
}
function ClearNumber(num)
{
    num=num.toString();
    //alert(num)
    var rexp=/[1234567890]/g;
    var ar=num.match(rexp);
    if(!ar||ar.lenght<1)return 0;
    return parseFloat(ar.join(''))
}
function jformatCurrency(num)
    {
        var lb_isneg=false;
        if(parseFloat(num)<0)lb_isneg=true;
        num = num.toString();
        num=num.replace('.','');
        num=num.replace(',','.');
        if(isNaN(num)){
            num = "0";
            return num;
            }
        var rexp=/[1234567890]/g;
       // var rexp=/\d+/g;
        var ar=num.match(rexp)
        
        if(!ar||ar.length<1)return 0;
        ret='';
        ar=ar.reverse(); 
        for(i=0;i<ar.length;i++)
        {
               if((i+1)%3==0&&i!=ar.length-1)ar[i]='.'+ar[i];
               ret=ar[i]+ret;
        }
        if(lb_isneg)ret='-'+ret;
        return ret;
    } 
 function jformatDecimal(num)
	{
        var lb_isneg=false;
        if(parseFloat(num)<0)lb_isneg=true;
        num = num.toString();
        num=num.replace(',','.');
        ln_ptopos=num.lastIndexOf('.');
        var dec=''
        if(ln_ptopos>0)
        {
            dec=num.substring(ln_ptopos+1,num.length)
            num=num.slice(0,ln_ptopos)
        }
        num = ClearNumber(num)
        num = num.toString();
		if(isNaN(num)){
            num = "0";
            return num;
            }	
        
		 var rexp=/[1234567890]/g;
        var ar=num.match(rexp)
        if(!ar||ar.length<1)return 0;
        ret='';
        ar=ar.reverse(); 
        for(i=0;i<ar.length;i++)
        {
               if((i+1)%3==0&&i!=ar.length-1)ar[i]='.'+ar[i];
               ret=ar[i]+ret;
        }
        
    //    if(dec!='')ret=ret+','+dec.slice(0,ln_ptopos);
        if(dec!='')ret=ret;
        if(lb_isneg)ret='-'+ret;
        return ret;
	}
	function wf_FechaHoraServer()
	{
		// Consulta HTTP a Servicio de Fecha y Hora 
		// Crea Objeto XML http
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.open("POST","xml-srv-chaw_Apl_ReponseFechaHora.asp",false);
		xmlhttp.send();

		//alert("ResponseText-> " + xmlhttp.ResponseText)

		if( xmlhttp.status != 200 || ! xmlhttp.ResponseXML.firstChild ) { //'200=OK
		  alert( xmlhttp.statusText + '\n' + xmlhttp.ResponseText  );
		  return null;
		}
		//*** Asigna valor del Servicio ASP
		var lxml_response = xmlhttp.ResponseXML;
		
		//*** Head XML Fecha y Hora ***
		var oxmlNodes = lxml_response.selectNodes('/root/FECHAHORA');
		
		// *** Asigna y retorna XML nodo *****
		var oNod = oxmlNodes.item(0);
		return oNod;
	}
	function RecargaModuloMenuIzq(Formulario)
	{
		Formulario.target="BodyEjecutivos1"
		Formulario.action="MenuIzquierdo.asp"
		Formulario.submit()
		return true
	} 
	
