
function elimina_puntos(valor)
 {
 if (valor.value != '')
  {
  for (i=valor.value.length-1; i >= 0;i--)
     {
     valor.value = valor.value.replace('.','');
     }
  return true;
  }
 }
 //para formateo numerico
function elimina_puntos_ccomas(valor)
 {
 if (valor.value != '')
  {
  for (i=valor.value.length-1; i >= 0;i--)
     {
     valor.value = valor.value.replace('.','');
     }
  valor.value = valor.value.replace(',','.');   
  return true;
  }
 }


function elimina_comas(valor)
 {
 if (valor.value != '')
  {
  for (i=valor.value.length-1; i >= 0;i--)
     {
     valor.value = valor.value.replace(',','');
     }
  return true;
  }
 }


function borrar()
 {
   document.form1.cons_clave.value=""
   document.form1.cons_user.value=""
 }


function Rut()
 {
 if (document.form1.rut.value != '') {
    return checkRutField(document.form1.rut.value);
 }
   return true;
}


///// INICIO CHEQUEO DE RESOLUCION DE PANTALLA ///////////

function Variables()
{
  if (window.screen) //En versiones antiguas de los navegadores no existe este objeto
  {
    if (screen.width=="640" && screen.height=="480")
    {
       tamano=1
    }
    if (screen.width=="800" && screen.height=="600")
    {
       tamano=2
    }
    if (screen.width=="1024" && screen.height=="768")
    {
       tamano=3
    }
    if (screen.width=="1152" && screen.height=="864")
    {
       tamano=4
    }
  }
}

///// FIN CHEQUEO DE RESOLUCION DE PANTALLA ///////////


///// INICIO FUNCIONES DREAMWEAVER ///////////

 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) { //v3.0
   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); 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_openBrWindow(theURL,winName,features) { //v2.0
   window.open(theURL,winName,features);
 }


 function openwin(urldestino,windowsname,windowsparam)
 {
   window.open(urldestino,windowsname,windowsparam);
}

///// FIN FUNCIONES DREAMWEAVER ///////////


function FormatoNumero(valor)
{
    var digito
    //alert(valor.value);
    digito = '';
    numero = '';
    if (valor.value != '')
    {
        valor.value = valor.value.replace('.','');
        j=1;
        for (i=valor.value.length-1; i >= 0;i--)
        {
            digito = valor.value.charAt(i)
            if (j == 3)
            {
                digito = '.' + digito;
                j = 1;
            }
            else
            {
                j = j + 1;
            }
            numero = digito + numero;
        }

        valor.value = numero;
        return true;
    }
}


function Grabar()
{
 if ( document.form1.prop_direccion.value == '') {
        alert('Debe ingresar Dirección de la Propiedad');
        document.form1.prop_direccion.focus();
        return false;
 }
 else if ( document.form1.id_ejecutivo.value == '0') {
        alert('Debe ingresar un Ejecutivo del Consignante');
        document.form1.eje_nom.focus();
        return false;
 }
 else if ( document.form1.id_persona.value == '0') {
        alert('Debe ingresar un Ejecutivo Macal');
        document.form1.pers_nom.focus();
        return false;
 }
 /*else if (isNaN(parseInt(form1.prod_precio.value, 10))) {
        alert('Debe ingresar digitar un número en el campo Precio Venta');
        document.form1.prod_precio.focus();
        return false;
 }
 // valida rut
 else if (document.form1.prop_rutdeudor.value != '') {
        return checkRutField(document.form1.prop_rutdeudor.value);
 }

 if ( !document.form1.es_destacado.checked ) {
        document.form1.prod_orden_destacado.value='0';
 }*/
 return true;
}


function browser(){//Constructor de un objeto "browser"
        this.ver=navigator.appVersion;
        this.browser=navigator.appName;
        this.agent=navigator.userAgent;
        this.dom=document.getElementById?1:0;
        this.IE5=(this.ver.indexOf("MSIE 5")>-1)||(IE5=this.ver.indexOf("MSIE 6")>-1);
        this.NS5=(this.dom && parseInt(this.ver)>=5)?1:0;
        this.Mac=this.agent.indexOf("Mac")>-1;
        this.NS4=(document.layers && !this.dom)?1:0;

}
BR=new browser();//Objeto de tipo "browser".
function findObj(obj){ //Esta función busca el objeto por el id según el browser del usuario.
   element=BR.IE5?window.document.all[obj]:BR.NS5?window.document.getElementById(obj):(BR.IE5&&BR.Mac)?window.document.all[obj]:(BR.NS5&&BR.Mac)?window.document.getElementById(obj):0;
   if(element==0) alert("Este sitio web está diseñado para browsers Internet Explorer o Netscape Navigator versiones 5.0 o superiores.");
   return (element);
}
ancho = screen.width;
largo = screen.height;
//function window_onload() {
//        parent.window.moveTo (-100,-100);
//        parent.window.resizeTo(1,1);
//        }
//if (BR.IE5 && !BR.Mac) window_onload();

// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****
// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****// *****
// ***** SI HACES REFERENCIA EN EL TAG BODY A ESTA FUNCION (GETWIN_POPUP), SE ABRE EL BROWSER A PANTALLA COMPLETA MEDIANTE LA PROPIEDAD FULLSCREEN='YES', TOMANDO PREVIAMENTE LOS VALORES DEL ANCHO Y ALTO DE LA PANTALLA (screen.width y screen.height)*****


function getwin_popup(wr_win, wname){
    var w_config = "fullscreen=yes, status=no,scrollbars=no,resizable='0',width=" + ancho + ",height=" + largo;
    var w_var = window.open(wr_win, wname, w_config);
    if (w_var.history.length >= 1) {
       var del = -w_var.history.length;
       w_var.history.go(del);
    }
    w_var.moveTo (0,0);
    if(BR.Mac) window.close();
}


function open_window_center(win_win,win_name,win_atrib,win_ancho,win_alto){
    var w_config = win_atrib;
    if (win_atrib != '') { w_config = w_config + ',' }
    w_config = w_config + "width=" + win_ancho + ",height=" + win_alto + ",left=" + (ancho-win_ancho) / 2 +",top="+(largo-win_alto)/2
//    alert("config="+w_config);
    var w_var = window.open(win_win, win_name, w_config);
    w_var.focus();
}


function open_window_top(win_win,win_name,win_atrib,win_ancho,win_alto){
    var w_config = win_atrib;
    if (win_atrib != '') { w_config = w_config + ',' }
    w_config = w_config + "width=" + win_ancho + ",height=" + win_alto + ",left=0,top=0";
    var w_var = window.open(win_win, win_name, w_config); 
    w_var.focus();
}


function valida_teclas(valor) 
 {
   alert('El Codigo de la tecla es :'+event.keyCode)
 }


// coloca los miles a los numeros
function formatear_monto(campo)
{
  //campo.value=campo.value.toUpperCase();
  //campo.value.replace('.','');
  if (campo.value != "")
  {
    valor=campo.value.replace('.','');
    valor=valor.replace('.','');
    valor=valor.replace('.','');    
    campo.value=valor;
    if (valor.length > 1)
    {
      campo.value= insertapuntos(valor.substring(0,valor.length));
      //alert('(insertapuntos = '+campo.value);
    }
  }
  else
  {
  campo.value="";
  } 
}


function insertapuntos(strval)
{
  var A = new Array();
  var strtemp = strval;

  if(strtemp.length > 0){
    strtemp = new Number(strtemp);
    strtemp = new String(strtemp);
    if (strtemp.length > 3){
      for(var i = 0; strtemp.length > 3; i++)
      {
        A[i] = Right(strtemp,3);
        strtemp /= 1000;
        strtemp=new String(strtemp);
        if (strtemp.indexOf('.') != -1)
        {
          strtemp = strtemp.substr(0,strtemp.indexOf('.'));
        }
      }
      for(i-- ;i >= 0 ;i--){
        strtemp = strtemp + "." + A[i];
      }
    }
  }
  return(strtemp);
}

function Right(strvar,intcant)
{
  strtemp = "";
  intlargo = strvar.length -1;
  for(i = 1;i <= intcant; i++)
  {
    strtemp = strtemp + strvar.charAt(intlargo);
    intlargo--;
  }

  strtmp2=""
  for(intlargo = strtemp.length -1; intlargo >=0; intlargo--)
  {
    strtmp2 = strtmp2 + strtemp.charAt(intlargo);
  }
  return(strtmp2);
}


  function mOvr(src,clrOver) {
    if (!src.contains(event.fromElement))
      {
        src.style.cursor = 'hand';
        src.bgColor = clrOver;
      }
    }

  function mOut(src,clrIn) {
    if (!src.contains(event.toElement))
      {
        src.style.cursor = 'default';
        src.bgColor = clrIn;
      }
    }

function submitea_pagina() 
 {
   if (event.keyCode==13)
     {
      document.form1.submit();
      //alert(document.form1.numeropag.value);
      if (document.form1.numeropag.value > 1)
      { 
        document.form1.navega.value = ''
      }
     }
 }
 
  function submitea_pagina_inicio() 
   {
     if (event.keyCode==13)
       {
        document.form1.submit();
       }
 }
 
 
 function formatNumber(campo)
 {
     var obj = campo;
     var num = new NumberFormat();
     num.setInputDecimal('.');
     num.setNumber(obj.value); 
     num.setPlaces('2', false);
     num.setCurrencyValue('');
     num.setCurrency(false);
     num.setCurrencyPosition(num.LEFT_OUTSIDE);
     num.setNegativeFormat(num.LEFT_DASH);
     num.setNegativeRed(false);
     num.setSeparators(true, '.', ',');
     obj.value = num.toFormatted(); //llama a otra función que esta en P:\include\NumberFormat154.js
     
}
