<!--
var x =0; //variable para evitar el envio multiple del form!

function cambio(f) {
	document.images['imagen_cambiar'].src = f;
}

function separar(cadena,id,nombre){
	var vector=cadena.split("|");
	id.value=vector[0];
	nombre.value=vector[1];
}

function registrarOperacion(operacion){
	if (x==0){
		document.forma.operacionRealizada.value=operacion;
		document.forma.submit();
		x=1;	
	}	
}


function registrarOperacionSucursal(operacion,sucursal){
	if (x==0){
		document.forma.operacionRealizada.value=operacion;
		document.forma.action=document.forma.action+"#"+sucursal;
		document.forma.submit();
		x=1;			
	}
}



function validarDocIde(){
	if(document.forma.tipoDocumentoIdentificacion.selectedIndex>0){
		if(document.forma.tipoDocumentoIdentificacion.selectedIndex==2){
			validar('documentoIdentificacion','','RisNum','0',' Cédula de Identidad '); 
		}else{
			var tmp = document.forma.documentoIdentificacion.value;
			if (tmp.length>0){
//				alert(tmp.substring(0,1)+'-'+ tmp.substring(1,tmp.length));
				if (!isNaN(tmp.substring(0,1))) {
					alert('IMPORTANTE\nPara continuar debes completar o modificar los campos del formulario que se señalan a continuación:\n - RIF no válido.');
				}
				if (tmp.length>1){
					if (isNaN(tmp.substring(1,tmp.length))) {
						alert('IMPORTANTE\nPara continuar debes completar o modificar los campos del formulario que se señalan a continuación:\n - RIF no válido.');
					}
				}
			}
		}
	}else{
		document.forma.tipoDocumentoIdentificacion.selectedIndex=2;
	}
}
// Ej:
//validar('campo','','Si es requerido y tipo', 'longitud minima', 'etiqueta'....
//donde SI es requerido y tipo puede valer: R = Requerido, RisEmail = Es Email y es Requerido, RisNum = Es numerico y requerido, isNum = Es numerico no requerido, isEmail = Es email y no requerido
function validar() { //v4.0
  var i,j,p,q,nm,test,num,min,max,errors='',args=validar.arguments,field,arrayLen,tmp;
  for (i=0; i<(args.length-4); i+=5) { 
  	test=args[i+2];
	val=MM_findObj(args[i]);
  	field=MM_findObj(args[i]);
	len=args[i+3];
	label=args[i+4];
    if (val) { 
		if (field.type=='select-one'){
		    if (field.selectedIndex==0){
				errors+='- '+label+'.\n';  
		    }
		}else{
    		nm=val.name; 
    		if ((val=val.value)!="") {
    			if (test.indexOf('isEmail')!=-1) {
    				p=val.indexOf('@');
    				if (p<1 || p==(val.length-1)) errors+='- '+label+' no es valido.\n';
    			} else if ((test!='R') && (test!='isChecked')) { 
    				if(parseInt(len)>0){ if (val.length <parseInt(len)){errors+='- '+label+' debe tener al menos ' +len+ ' caracteres.\n';}}
    				num = parseFloat(val);
    				if (isNaN(val)) errors+='- '+label+' debe ser numerico.\n';
    				if (test.indexOf('inRange') != -1) { 
    					p=test.indexOf(':');
    					min=test.substring(8,p); 
    					max=test.substring(p+1);
    					if (num<min || max<num) errors+='- '+label+' debe ser un numero entre  '+min+' y '+max+'.\n';
    				}
        		} else if (test.indexOf('isChecked')!= -1){  
                	arrayLen = field.length;
                	j=0;
                	tmp=0;
                	for( j=0 ; j<arrayLen; j++) {
                		if (field[j].checked == true) {
                			tmp=1;
                		}
                	}
                	if (tmp==0){ errors+='- '+label+' debe seleccionarse.\n';} 				
    			}
    		}else if (test.charAt(0) == 'R') {			
			  
				errors+='- '+label+'.\n';  
				
    		}
        }
    }
    
//Validar campo a campo haciendo focus en el campo en cuestion
//	if (errors){ 
//		alert('The following error(s) occurred:\n'+errors);
		//field.focus();
//		break;
//	}
  } 
//Un solo mensaje con todos los campos faltantes
	if (errors){ 
		alert('WARNING\nThe following fields of the form need to fill or to modify themselves:\n'+errors);
	}
  document.MM_returnValue = (errors == '');
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' it must be a valid email.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' it must be a valid number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' debe ser un numero entre '+min+' y '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' es requerido.\n'; }
  } if (errors) alert('Ha ocurrido el(los) siguiente(s) error(es):\n'+errors);
  document.MM_returnValue = (errors == '');
}

	function trim(s) {
		  while (s.substring(0,1) == ' ') {
			s = s.substring(1,s.length);
		  }
		  while (s.substring(s.length-1,s.length) == ' ') {
			s = s.substring(0,s.length-1);
		  }
		  return s;
	}
	
	function nextFocus(current,next){
		if (current.value.length>=current.maxLength){
			next.focus();
			}
	}
 
//-->
