function confirm_del(id, id_campo, msg)
 {
  var cnf=confirm(msg);
  if (cnf==true)
   {
	this.document.getElementById(id_campo).value=id;
	document.form1.submit();
   }
 }
 
 function validar(valor, tipo) {
 switch (tipo) {
  case 'numero':
   var check = /(^\d*$)/;
      return (check.test(valor));
  case 'real':
      var isreal=IsNum(valor);
      return isreal;
  case 'numero-letra':
   var check = /(^[a-zA-Zá-ú\s\d]*$)/;
      return (check.test(valor));
  case 'letra' :
   var check = /(^[a-zA-Zá-ú\s]*$)/;
      return (check.test(valor));
  case 'CI':
   //que tenga 11 números solamente
   var check = /(^\d{11}$)/;
   r1 = (check.test(valor));
   // que sea una entrada de fecha válida
   var check = /(^\d{2}[0-1][0-9][0-3][0-9]$)/; temp = valor.substring(0,6);
      r2 = (check.test(temp));
   //correspondencias entre los días y los meses
   fecha = 
temp.substring(4,6)+'/'+temp.substring(2,4)+'/19'+temp.substring(0,2);
   r3 = EsFecha(fecha);
   return (r1 && r2 && r3);
  case 'fecha':
   var check = /(^[0-3]?[0-9]\-|\/[0-1]?[1-2]\-|\/\d{4}$)/; //solo válida la composición de la fecha
      return (check.test(valor));
  case 'moneda':
   var check = /(^[0-9]*\.?[0-9]{0,2}$)/;
      return (check.test(valor));
  case 'telefono':
   var check = /(^[0-9()\-]*$)/;
      return (check.test(valor));
  case 'email':
   var check = /(^[\w\-\.]*@[\w\-\.]*\.[a-z]{2,3}$)/;
      return (check.test(valor));
  case 'url':
   var check = /(^[\w\-\.]*\.[a-z]{2,3}$)/;
      return (check.test(valor));
  case 'anno':
   var check = /(^[1-2]\d{3}$)/;
      return (check.test(valor));
  case 'cp':
   var check = /(^\d{5}$)/;
      return (check.test(valor));
  default:
   return true;
 }
}

function EsFecha(fecha){
	var dd   = fecha.substring(0,2); var mm   = fecha.substring(3,5); var yyyy = fecha.substring(6,10);
	
	if ((dd=='00')||(mm=='00')||(yyyy=='0000')||(dd=='')||(mm=='')||(yyyy=='')) return false;
	
	switch (mm){
		case '01': case '03': case '05': case '07': case '08': case '10': case '12':
			if (dd>31) return false; break;
		case '04': case '06': case '09': case '11':
			if (dd>30) return false; break;
		case '02': 
			if (yyyy % 4 == 0){
				if (dd>29) return false; //año bisiesto
			}else{
				if (dd>28) return false;
			}//if
			break;
		default: return false;
	}//switch
	return true;
}//EsFecha

function IsNum( numstr ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	var isValid = true;
	var decCount = 0;		// number of decimal points in the string

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for negative numbers (first char == '-')
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;

    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
				(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
			  (numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
   	return isValid;
}  // end IsNum

function send_vacios()
 {
  if (send_vacios.arguments.length>0)
   {
	for (i=0; i<send_vacios.arguments.length; i++)
	 {
	  if (this.document.getElementById(send_vacios.arguments[i]).value=='')
	   {
		alert('No debe dejar campos vacios');
		a=false;
		break;
	   }
	  else a=true; 
	 }
   }
  return a; 
 }