cuenta=0;
// FX es el formulario a validar
function validar(fx){
	email_str=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;

	for (i = 0; i < fx.elements.length; i++) {
		if ((fx.elements[i].type == "text" ||
				fx.elements[i].type == "password" ||
				fx.elements[i].type == "textarea") &&
			 (fx.elements[i].type != "hidden" && fx.elements[i].type != "file") &&
			(fx.elements[i].name!= 'nb_usuario_m' && 
				fx.elements[i].name!= 'pass_m' && 
				fx.elements[i].name!= 'observacion' &&
				fx.elements[i].name!= 'telefono') && 
			(fx.elements[i].value == "" || 
				fx.elements[i].value == " " || 
				fx.elements[i].value == "null" || 
				fx.elements[i].value.indexOf("\"", 0) > -1 || 
				fx.elements[i].value.indexOf("=", 0) > -1 || 
				fx.elements[i].value.indexOf("\'", 0) > -1)){   
				alert("Debe ingresar "+fx.elements[i].title);
				fx.elements[i].style.backgroundColor = "#F3F8FC";
			if(fx.elements[i].type != "hidden")
				fx.elements[i].focus();

			return false;
			break;
		}
		if(fx.elements[i].name == "email" && fx.elements[i].value!="" && fx.elements[i].value!=" "){
			if(!email_str.test(fx.elements[i].value)) {
				alert("El formato del campo email no es valido");
				return false;
				break;
			}
		}
		if(fx.elements[i].value=="x999"){
			if(!email_str.test(fx.elements[i].value)) {
				alert("Por favor completa los campos del formulario");
				return false;
				break;
			}
		}
	}
	if (cuenta == 0){
		cuenta++;
		return true;
	}else{
		alert("Por favor espera la respuesta de tu peticion!");
		return false;
	}
}

//onKeyPress="return(formato_campo(this,event,1))"
function formato_campo(fld,e,t) { 

    var aux = aux2 = '';
	var i = j = 0;

	if(t==1)
    	var strCheck = '0123456789';
	if(t==2)
    	var strCheck = 'AaBbCcDdEeFfGgHhIiJjKkLlÑñNnMmOoPpQqRrSsTtUuVvWwXxYyZzáÁéÉíÍóÓúÚ ';
	if(t==3)
    	var strCheck = '0123456789-ext';
	if(t==4)
    	var strCheck = '0123456789,.';
	
    var whichCode = (window.Event) ? e.which : e.keyCode;
    if (whichCode == 13) return true; 						// Enter
	if (whichCode == 8) return true; 							// Enter
	//if (whichCode == 46) return true;						// Enter 
	if (whichCode == 0) return true; 							// Tab
    key = String.fromCharCode(whichCode); 				// Consigue el valor del codigo de tecla...
    if (strCheck.indexOf(key) == -1) return false; 	// no es una tecla valida
	fld.value += aux2.charAt(i);
}

//<a href="javascript:ventanaPopUp('pagina.html','ventana','600px','400px','yes');">link</a>
function ventanaPopUp (pagina,nom_ventana,ancho,alto,scroll_b){
	var opciones=("toolbar=no, "+
				  "location=no, "+
				  "directories=no, "+
				  "status=no, "+
				  "menubar=yes, "+
				  "scrollbars="+scroll_b+","+
				  "resizable=no,"+
				  "width="+ancho+","+
				  "height="+alto+"");
	var w=window.open(pagina,nom_ventana,opciones);
}

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = "" ;
}

function cambiar(img) {
	 document.images['carga'].src = "../../images/img/"+img+".jpg";
};


function cambiare(img) {
	 document.images['carga'].src = "../../images/imge/"+img+".jpg";
};

function runSWF(archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess) { // tutorial by IVI CONCEPT - www.ivi-concept.com
if(version!=""){
var version_data=version;
}else{
var version_data="6,0,0,0";
}
if(menu!=""){
menu_data=menu;
}else{
menu_data=false;
}
if(bgcolor!=""){
var bgcolor_data=bgcolor;
}else{
var bgcolor_data="#9DB3C0";
}
if(id!=""){
id_data=id;
}else{
id_data="flashMovie";
}
if(quality!=""){
quality_data=quality;
}else{
quality_data="high";
}
if(allowScriptAccess!=""){
allowScriptAccess_data=allowScriptAccess;
}else{
allowScriptAccess_data="always";
}
var quality="high"; // calidad de visualización de la peli
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= '+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
document.write('<param name="movie" value='+archivo+'>\n');
document.write('<param name= "allowScriptAccess" value= '+allowScriptAccess_data+'>\n');
document.write('<param name="quality" value='+quality_data+'>\n');
document.write('<param name="FlashVars" value='+FlashVars+'>\n');
document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
document.write('<param name="menu" value='+menu_data+' >\n');
document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+'></embed>');
document.write('</object>\n');
} 

function passw(){
		if (document.frm_insert.contrasena.value!="bivo"){
				alert("Clave de acceso invalida");
				document.frm_insert.contrasena.focus();
				document.frm_insert.contrasena.value=="";
				return false;
			} else{  frm_insert.submit();}
}


