
function clicMostrarCampos(campo) {
	visible = document.getElementById(campo).style.display;
	if (visible == "none") {
		document.getElementById(campo).style.display = ""; //mostrar valor
	} else {
		document.getElementById(campo).style.display = "none"; //ocultar valor
	}
}
function crearXMLHttpRequest()
{
	var xmlHttp=null;
	if (window.ActiveXObject)
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	else
	if (window.XMLHttpRequest)
		xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}
function FAjaxLoadSimple(url,capa,valores,metodo){
	var ajax=crearXMLHttpRequest();
	var capaContenedora = document.getElementById(capa);
	
	/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
	if(metodo.toUpperCase()=='POST'){
		ajax.open ('POST', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="../img/progress_bar01.gif" />';
			 }else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(valores);
		return;
	}
	/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
	if (metodo.toUpperCase()=='GET'){
		url = url + '?' + valores;
		ajax.open ('GET', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="../img/progress_bar01.gif" />';
			}else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(null);
		return
	}
}
function FAjaxLoadSimpleFront(url,capa,valores,metodo){
	var ajax=crearXMLHttpRequest();
	var capaContenedora = document.getElementById(capa);
	
	/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
	if(metodo.toUpperCase()=='POST'){
		ajax.open ('POST', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="img/progress_bar01.gif" style="margin-top:6px;" />';
			 }else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(valores);
		return;
	}
	/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
	if (metodo.toUpperCase()=='GET'){
		url = url + '?' + valores;
		ajax.open ('GET', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="img/progress_bar01.gif" style="margin-top:6px;" />';
			}else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(null);
		return
	}
}
function FAjaxLoadSimpleBack(url,capa,valores,metodo){
	var ajax=crearXMLHttpRequest();
	var capaContenedora = document.getElementById(capa);
	
	/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
	if(metodo.toUpperCase()=='POST'){
		ajax.open ('POST', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="../img/progress_bar01.gif" style="margin-top:6px;" />';
			 }else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(valores);
		return;
	}
	/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
	if (metodo.toUpperCase()=='GET'){
		url = url + '?' + valores;
		ajax.open ('GET', url, true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML='<img src="../img/progress_bar01.gif" style="margin-top:6px;" />';
			}else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(capa).innerHTML=ajax.responseText;
				}else if(ajax.status==404){
					capaContenedora.innerHTML = "<font class='textoFormulario'>La direccion no existe</font>";
				}else{
					capaContenedora.innerHTML = "<font class='textoFormulario'>Error: " + ajax.status + "</font>";
				}
			}
		}
		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		ajax.send(null);
		return
	}
}




//-------------------------------------------------------------------------------------
// Descripcion: habilita los que estan deshabilitados, deshabilita los que estan      '
//              habilitados y pone que tipo de puntaje                                '
//       Autor: Ramiro Llanos                                                         '
//       Fecha: 25/04/2008                                                            '
//-------------------------------------------------------------------------------------

function busquedaAvanzada() {
	fila = document.getElementById('busqueda_avanzada');
	if (fila.style.display != "none") {
		fila.style.display = "none"; //ocultar fila 
	} else {
		fila.style.display = ""; //mostrar fila 
	}
	fila = document.getElementById('boton_buscar');
	if (fila.style.display != "none") {
		fila.style.display = "none"; //ocultar fila 
	} else {
		fila.style.display = ""; //mostrar fila 
	}
}

function habilitaDeshabilitaPuntaje(campo1, campo2, campo3, tipo)
{
	document.getElementById('tipo_puntaje_hidden').value = tipo;
	if(tipo == 'articulo') {
		document.getElementById(campo1).disabled = false;
		document.getElementById(campo2).disabled = false;
		document.getElementById(campo3).disabled = true;
	}else{
		document.getElementById(campo1).disabled = true;
		document.getElementById(campo2).disabled = true;
		document.getElementById(campo3).disabled = false;
	}
}




//-------------------------------------------------------------------------------------
// Descripcion: funcion que checkean que la estructura del mail sea correcta          '
// Parametros: email                                                                  '
//     Autor: Anibal Kolker (y la ER tambien, demonios!!)                             '
//     Fecha: 23/01/2005                                                              '
// Devuelve: boolean                                                                  '
//-------------------------------------------------------------------------------------

function validaMail(email)
{	
	//anterior -->(/^[a-zA-Z]((\.|-|_)?[a-zA-Z0-9])*@[a-zA-Z]([a-zA-Z0-9]|((-|_)[a-zA-Z0-9]))+(\.[a-zA-Z]{2,4})+$/);
	var re = new RegExp(/^[a-zA-Z]((\.|-|_)?[a-zA-Z0-9])*@[a-zA-Z]((-|_)?[a-zA-Z0-9])*(\.[a-zA-Z]{2,4})+$/);
	if(email.match(re))
		return true;
	return false;
}




//-------------------------------------------------------------------------------------
// Descripcion: funcion que que vacia los options de un combo                         '
// Parametros: el objeto combo que se desea vaciar                                    '
//     Autor: -                                                                       '
//     Fecha: 23/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function vaciarOptions(obj){
  while (obj.length > 0){
	obj.options.length--;
  }	
}



//-------------------------------------------------------------------------------------
// Descripcion: funciones que arman los depsplegables de anio mes y dia               '
// Parametros: explicitadas las llamadas sobre cada funcion                           '
//     Autor: Anibal Kolker                                                           '
//     Fecha: 23/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

//en body tag: onLoad="crearAnioMesDia(document.ff.anio, anioBase, document.ff.mes, document.ff.dia);
function crearAnioMesDia(objAnio, anioBase, objMes, objDia){

  crearAnio(objAnio, anioBase);
  crearMes(objMes);
  crearDia(objDia, 1, anioBase);
}


//en combo anio: onChange="crearDia(document.ff.dia, document.ff.mes.value, document.ff.anio.value);
function crearAnio(obj,anioBase){

  var now   = new Date();
  var year  = now.getYear();
  vaciarOptions(obj);
  obj.options[0] = new Option(anioBase, anioBase);
  obj.options[0].selected = true;
  for (var i = anioBase+1; i <= year; i++)
    obj.options[i-anioBase] = new Option(i, i); //se deja i - 1979 para que el valor sea 1
}

function esBisiesto (anio){
  if (((anio % 4)==0) && ((anio % 100)!=0) || ((anio % 400)==0))
    return (true);
  else
    return (false);
}

//en combo mes: onChange="crearDia(document.ff.dia, document.ff.mes.value, document.ff.anio.value);
function crearMes(obj){
  var meses = new Array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre');
  vaciarOptions(obj);
  for(var i = 0; i < meses.length; i++)
    obj.options[i] = new Option(meses[i], i+1);
  obj.options[0].selected = true;
}


function crearDia(obj, mes, anio){

  vaciarOptions(obj);
  if(esBisiesto(anio))
    var diasMes = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  else
    var diasMes = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  var dias = diasMes[mes-1];
  obj.options[0] = new Option(1,1);
  obj.options[0].selected = true;
  for(var i = 1; i < dias; i++)
    obj.options[i] = new Option(i+1,i+1);	
}



//-------------------------------------------------------------------------------------
// Descripcion: mueve un elemento de un listbox en la direccion especificada          '
// Parametros: formulario, direccion (true arriba, false abajo, listbox               '
//     Autor: -                                                                       '
//     Fecha: 10/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------
function moveUpDown(f,bDir,sName) {
  var el = f.elements[sName]
  var idx = el.selectedIndex
  if (idx==-1) 
    alert("Selecciona un elemento a reordenar.")
  else {
    var nxidx = idx+( bDir? -1 : 1)
    if (nxidx<0) nxidx=el.length-1
    if (nxidx>=el.length) nxidx=0
    var oldVal = el[idx].value
    var oldText = el[idx].text
    el[idx].value = el[nxidx].value
    el[idx].text = el[nxidx].text
    el[nxidx].value = oldVal
    el[nxidx].text = oldText
    el.selectedIndex = nxidx
  }
}



//-------------------------------------------------------------------------------------
// Descripcion: mueve un elemento de un listbox a otro                                '
// Parametros: listbox origen, listbox destino                                        '
//     Autor: Phil Webb                                                               '
//     Fecha: 10/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

// PickList II script (aka Menu Swapper)- By Phil Webb (http://www.philwebb.com)
// Visit JavaScript Kit (http://www.javascriptkit.com) for this JavaScript and 100s more
// Please keep this notice intact

function move(fbox, tbox) {
     var arrFbox = new Array();
     var arrTbox = new Array();
     var arrLookup = new Array();
     var i;
     for(i=0; i<tbox.options.length; i++) {
          arrLookup[tbox.options[i].text] = tbox.options[i].value;
          arrTbox[i] = tbox.options[i].text;
     }
     var fLength = 0;
     var tLength = arrTbox.length
     for(i=0; i<fbox.options.length; i++) {
          arrLookup[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               arrTbox[tLength] = fbox.options[i].text;
               tLength++;
          } else {
               arrFbox[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     //arrFbox.sort();
     //arrTbox.sort();
     fbox.length = 0;
     tbox.length = 0;
     var c;
     for(c=0; c<arrFbox.length; c++) {
          var no = new Option();
          no.value = arrLookup[arrFbox[c]];
          no.text = arrFbox[c];
          fbox[c] = no;
     }
     for(c=0; c<arrTbox.length; c++) {
     	var no = new Option();
     	no.value = arrLookup[arrTbox[c]];
     	no.text = arrTbox[c];
     	tbox[c] = no;
     }
}



//-------------------------------------------------------------------------------------
// Descripcion: selecciona todos los elementos de un listbox                          '
// Parametros: listbox 																  '
//     Autor: Phil Webb                                                               '
//     Fecha: 10/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function selectAll(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = true;
     }
}



//-------------------------------------------------------------------------------------
// Descripcion: guarda los datos de un select en un imput de text                     '
// Parametros: listbox, input type text												  '
//     Autor: Ramiro Llanos                                                           '
//     Fecha: 15/02/2008                                                              '
//  Devuelve: -                                                                       '
//-------------------------------------------------------------------------------------

function cargar_enviar(box, nombretext) {
	document.getElementById(nombretext).value = '';
	for(var i=0; i<box.length; i++) {
		if(document.getElementById(nombretext).value == ''){
			document.getElementById(nombretext).value = box[i].value;
		}else{
			document.getElementById(nombretext).value = document.getElementById(nombretext).value + "|" + box[i].value;
		}
	}
}


//-------------------------------------------------------------------------------------
// Descripcion: deselecciona todos los elementos de un listbox                        '
// Parametros: listbox                                                                '
//     Autor: Anibal Kolker                                                           '
//     Fecha: 10/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function deselectAll(box) {
     for(var i=0; i<box.length; i++) {
     box[i].selected = false;
     }
}




//-------------------------------------------------------------------------------------
// Descripcion: selecciona todos los checkbox de un form                              '
// Parametros: nombre del form, nombre de los checkbox, valor a setear 				  '
//     Autor: http://www.someacon.com/blog/page17.php                                 '
//     Fecha: 08/02/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function SetAllCheckBoxes(FormName, FieldName, CheckValue)
{
	if (!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if (!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if (!countCheckBoxes)
		objCheckBoxes.checked = CheckValue;
	else
		//set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = CheckValue;
}


//-------------------------------------------------------------------------------------
// Descripcion: crea un combo							      '
// Parametros: combo a crear, string con los options, valor seleccionado (opcional)   '
// Formato del string: ID:valorAmostrar                                               '
//     Autor: Anibal Kolker                                                           '
//     Fecha: 05/04/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function crearCombo(combo, strOpciones, seleccionado)
{

  var opciones = new Array();
  var j = 0;

  opciones = strOpciones.split(',');
  for(var i = 0; i < opciones.length; i++)
  {
    combo.options[j] = new Option((opciones[i].split(':'))[1], (opciones[i].split(':'))[0])
    if(seleccionado != undefined){
      if(combo.options[j].value == seleccionado)
        combo.options[j].selected = true;
    }
    j++;
  }
  combo.options.length--;
}




//-------------------------------------------------------------------------------------
// Descripcion: vincula los options de un combo a otro                                '
// Parametros: combo src, combo dest, string con los options 	                      '
// Formato del string: Value option src:value option dest:nombre option dest          '
// ejemplo: (ciudad depende de estado) --> IDEstado:IDciudad:nombreCiudad             '
//     Autor: Anibal Kolker                                                           '
//     Fecha: 02/03/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------

function enlazaCombos(srcCombo, destCombo, strOpciones)
{

  var opciones = new Array();
  var j = 0;

  opciones = strOpciones.split(',');
  vaciarOptions(obj2);
  for(var i = 0; i < opciones.length; i++)
  {
    if((opciones[i].split(':'))[0] == srcCombo.value)
    {
      destCombo.options[j] = new Option((opciones[i].split(':'))[2], (opciones[i].split(':'))[1])
      j++;
    }
  }
}




//-------------------------------------------------------------------------------------
// Descripcion: funcioncitas que muestran, ocultan objetos y alternan imagenes        '
// Parametros: el objeto                                                              '
//     Autor: Anibal Kolker                                                           '
//     Fecha: 01/01/2005                                                              '
// Devuelve: -                                                                        '
//-------------------------------------------------------------------------------------


function muestra(obj){
	obj.style.visibility = 'visible';
}


function oculta(obj){
	obj.style.visibility = 'hidden';
}


function cambiaImagen(imagen, src){
	imagen.src = src;
}



//-----------------------------------------------------------------------------------------
// Descripcion: funcioncitas que activan y desactivan una serie de items del form          '
// Parametros: el formulario y la lista de inputs a activar/desactivar separados por comas '
//     Autor: Anibal Kolker                                                                '
//     Fecha: 20/03/2005                                                                   '
// Devuelve: -                                                                             '
//-----------------------------------------------------------------------------------------



function activa(frm, strObjs){

  var objs = strObjs.split(",");
  for(var i = 0; i < objs.length; i++)
    frm.elements[objs[i]].disabled = false;
}

function desactiva(frm, strObjs){

  var objs = strObjs.split(",");
  for(var i = 0; i < objs.length; i++)
    frm.elements[objs[i]].disabled = true;
}







/*
  -------------------------------------------------------------------------
	                    JavaScript Form Validator 
                                Version 2.0.2
	Copyright 2003 JavaScript-coder.com. All rights reserved.
	You use this script in your Web pages, provided these opening credit
    lines are kept intact.
	The Form validation script is distributed free from JavaScript-Coder.com

	You may please add a link to JavaScript-Coder.com, 
	making it easy for others to find this script.
	Checkout the Give a link and Get a link page:
	http://www.javascript-coder.com/links/how-to-link.php

    You may not reprint or redistribute this code without permission from 
    JavaScript-Coder.com.
	
	JavaScript Coder
	It precisely codes what you imagine!
	Grab your copy here:
		http://www.javascript-coder.com/
    -------------------------------------------------------------------------  
*/
function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}

	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  
  // Patch para aceptar radio
  if ((itemobj.length != undefined) && (itemobj.type != 'select-one'))
  {
  	for (i=0; i<itemobj.length; i++)
  	{
			itemobj[i].papa = itemobj;
			if(!itemobj[i].validationset)
			{
			  itemobj[i].validationset = new ValidationSet(itemobj[i]);
			}
		  itemobj[i].validationset.add(descriptor,errstr);
  	}
  }
	else
	{	
	  if(!itemobj)
		{
		  alert("BUG: Couldnot get the input object named: "+itemname);
			return;
		}
		if(!itemobj.validationset)
		{
		  itemobj.validationset = new ValidationSet(itemobj);
		}
	  itemobj.validationset.add(descriptor,errstr);
	}
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    try
    {
    	this.itemobj.focus();
    }
    catch (exception) {}
    	
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
  this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]= 
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
function V2validateData(strValidateStr,objValue,strError) 
{ 
    var epos = strValidateStr.search("="); 
    var  command  = ""; 
    var  cmdvalue = ""; 
    if(epos >= 0) 
    { 
     command  = strValidateStr.substring(0,epos); 
     cmdvalue = strValidateStr.substr(epos+1); 
    } 
    else 
    { 
     command = strValidateStr; 
    } 
		
    switch(command) 
    { 
        case "checked":
         { 
           if (objValue.papa)
           {
	           var resultado = false;
	           for (i=0; i<objValue.papa.length; i++)
	           {
	           		if (objValue.papa[i].checked)
	           			resultado = true;
	           }
	
	           if (!resultado)
	           { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name + " : Dato obligatorio"; 
	              }//if 
	              alert(strError); 
	              return false; 
	           }//if 
					 }
					 else
					 {
	           if (!objValue.checked)
	           { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name + " : Dato obligatorio"; 
	              }//if 
	              alert(strError); 
	              return false; 
	           }//if 
					 }
           break;             
         }//case checked
        case "req": 
        case "required": 
         { 
           if(eval(objValue.value.length) == 0) 
           { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : Dato obligatorio"; 
              }//if 
              alert(strError); 
              return false; 
           }//if 
           break;             
         }//case required 
        case "maxlength": 
        case "maxlen": 
          { 
             if(eval(objValue.value.length) >  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : máximo "+cmdvalue+" caracteres "; 
               }//if 
               alert(strError + "\n[Longitud actual = " + objValue.value.length + " ]"); 
               return false; 
             }//if 
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : mínimo " + cmdvalue + " caracteres "; 
               }//if               
               alert(strError + "\n[Longitud actual = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Sólo se permiten caracteres alfanuméricos "; 
                }//if 
                alert(strError + "\n [Error en el caracter número " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Sólo se permiten dígitos "; 
                }//if               
                alert(strError + "\n [Error en el caracter número " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha": 
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Solo se admiten caracteres alfabéticos "; 
                }//if                             
                alert(strError + "\n [Error en el caracter número " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": los caracteres admitidos son A-Z,a-z,0-9,- y _"; 
                }//if                             
                alert(strError + "\n [Error en el caracter número " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email": 
          { 
               if(!validaMail(objValue.value)) 
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Ingrese una dirección de E-mail válida "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email 
        case "lt": 
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Debe ser numérico "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : valor debe ser menor que "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Debe ser numérico "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : valor debe ser mayor que "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Se encontraron caracteres invalidos "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "dontselect": 
         { 
            if(objValue.selectedIndex == null) 
            { 
              alert("BUG: dontselect command for non-select Item"); 
              return false; 
            } 
            if(objValue.selectedIndex == eval(cmdvalue)) 
            { 
             if(!strError || strError.length ==0) 
              { 
              strError = objValue.name+": Por favor selecciona una opción "; 
              }//if                                                               
              alert(strError); 
              return false;                                   
             } 
             break; 
         }//case dontselect 
    }//switch 
    return true; 
}




var cade = "";
function PonerPuntos(esto){
	var arg = esto.value
	var imp=Quita_Puntos2((arg).toString());
	var importe2=imp;
	var decimales="";
	var posicion=importe2.indexOf(",");
	var impConPuntos="";
	if (cade != arg) {
	cade = arg;
	if(posicion!=-1){
	importe2=imp.substring(0,posicion);
	decimales=imp.substring(posicion);
	var impConPuntos=impConPuntos.concat(decimales);
	}
	else{
	importe=imp;
	}
	if (importe2.length>3){
	for(var i=importe2.length;i>0;i=i-3){
	if (i==importe2.length){
	var nuevo=".".concat(importe2.substring(i-3));
	impConPuntos=nuevo.concat(impConPuntos);
	}
	else if(i==0| i==1 |i==2|i==3 ){
	impConPuntos=importe2.substring(0,i).concat(impConPuntos);
	}
	else{
	var nuevo=".".concat(importe2.substring(i-3,i));
	impConPuntos=nuevo.concat(impConPuntos);
	}
	}
	}
	else{
	impConPuntos=imp;
	}
	esto.value = impConPuntos;
	cade = impConPuntos;
	}
}

function Quita_Puntos2(str){
	var aux = "";
	var decimal = 0;
	for (var i=0; i<str.length; i++) {
	pp = str.substring(i,(i+1));
	if (pp != ".")
	aux = aux + pp;
	}
	return(aux);
}

function valinum(esto,tipo,puntos){
	fieldName   = document.forms["form1"][esto]; 
	fieldValue  = fieldName.value; 
	fieldLength = fieldName.value.length;
	cad = "";
	for( var i = 0; i < fieldLength; i++ ) { 
		var ch = fieldValue.substring( i, i + 1 ); 
		if ( (( ch >= "0" ) && ( ch <= "9" )) || ((tipo == "decimal")&&( ch == "," )) ) { 
			cad = cad + ch;
		}
	}
	fieldName.value = cad;
	if (puntos) PonerPuntos(fieldName);
}
/*
	Copyright 2003 JavaScript-coder.com. All rights reserved.
*/
