/* this prevents dom flickering, needs to be outside of dom.ready event: */
document.documentElement.className += 'js_active';

jQuery.noConflict();


jQuery(document).ready(function(){
	k_form(); //controls the contact form
	k_formContacto();
	k_formEmpresa();
});

function cargavalidacion(){
	var bandera = true;
	var url1 = jQuery("meta[name=temp_url]").attr('content');
	var datos1 	= jQuery("#empresa").serialize();
	var ocupado7 = 0;
	var pausa7 = null;
//	alert(datos);
	
	var b = jQuery(".ajax_form #empresa").val();
	jQuery(".ajax_form #igualar").val(b);
				
	jQuery.ajax({
		type: "POST",
		url: url1+"/registro1.php",
		data: datos1,
		success:function(msg){ 
			if(msg != 0){
				jQuery(".ajax_form #revision").val(b);
				bandera = false; /// ya existe empresa no insertar 
				if (ocupado7 == 0){
					ocupado7 = 1;
					jQuery('.ajax_form .mensaje').append(msg).css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
					ocupado7 = 0;});
					jQuery(".ajax_form #empresa").val("");
					jQuery('#empresa').css({border:'1px solid #66CCFF'});
					jQuery(".ajax_form .mensaje").append("Se encontraron los siguientes errores: La empresa <span style='color:#ff0000'>"+jQuery('.ajax_form #igualar').attr("value")+"</span> ya esta resgistrada");
				}
			}else{
				bandera = true; 
				jQuery('#empresa').css({border:'1px solid #70A41B'});
				jQuery(".ajax_form #revision").val("");
					if(b == ""){jQuery('#empresa').css({border:'1px solid #FF9000'});}
			}/// no existe empresa si insertar}
		}
	});
	return bandera;
}

function k_form(){
	var my_error;
	var url2 = jQuery("meta[name=temp_url]").attr('content');
		
	jQuery(".ajax_form #send").bind("click", function(){
    
	my_error = false;
	
		jQuery(".ajax_form #empresa, .ajax_form #telefono, .ajax_form #fax, .ajax_form #pais, .ajax_form #curriculum, .ajax_form #descripcion, .ajax_form #productos, .ajax_form #servicios, .ajax_form #patentes, .ajax_form #certificaciones, .ajax_form #core_business, .ajax_form #contact_nombre, .ajax_form #contact_telefono, .ajax_form #contact_fax, .ajax_form #contact_correo, .ajax_form #contact_direccion").each(function(i){
			//var a = jQuery(".ajax_form #empresa").val(); 
			//jQuery(".ajax_form #igualar").val(a);
			
			var value = jQuery(this).attr("value");
			var check_for = jQuery(this).attr("id");
			var surrounding_element = jQuery(this).parent();
			
			/*if(check_for == "revision"){
				if(value != ""){
					my_error = true;
				}
			}
			*/

	
				if(check_for == "empresa" || check_for == "telefono" || check_for == "pais" || check_for == "core_business"){
				
				var ocupado6 = 0;
				var pausa6 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado6 == 0){ocupado6 = 1;
							jQuery('.ajax_form .tooltip6').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado6 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #empresa").attr("value")!="" && jQuery(".ajax_form #telefono").attr("value")!="" && jQuery(".ajax_form #pais").attr("value")!="" && jQuery(".ajax_form #core_business").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa6 = setTimeout(function(){
												pausa6 = null;
												if (ocupado6 == 0){
													ocupado6 = 1;
													jQuery('.ajax_form .tooltip6').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip6').css({display: 'none',top: 0});
														ocupado6 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip6').css({display: 'none'}); ocupado6 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de NOMBRE DE CONTACTO 	
			
	
			if(check_for == "empresa"){
				
				var ocupado1 = 0;
				var pausa1 = null;
			
					if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado1 == 0){ocupado1 = 1;
							jQuery('.ajax_form .tooltip').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado1 = 0;});
						}
					});
					my_error = true;	
						
					}else{
						surrounding_element.attr("class","").addClass("valid");
						if(jQuery(".ajax_form #empresa").attr("value")!=""){																  												jQuery(".ajax_form").each(function(){ 
								pausa1 = setTimeout(function(){
													pausa1 = null;
													if (ocupado1 == 0){
														ocupado1 = 1;
														jQuery('.ajax_form .tooltip').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
															jQuery('.ajax_form .tooltip').css({display: 'none',top: 0});
															ocupado1 = 0;
														});
													}else{
														jQuery('.ajax_form .tooltip').css({display: 'none'});ocupado1 = 0;
													}
								}, 500)
							});
						}
					}//// fin de else
			
			}//// fin de EMPRESA
				
			
			if(check_for == "telefono"){
				
				var ocupado = 0;
				var pausa = null;
			if(value!=""){
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado == 0){ocupado = 1;
							jQuery('.ajax_form .tooltip1').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #telefono").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 
							pausa = setTimeout(function(){
												pausa = null;
												if (ocupado == 0){
													ocupado = 1;
													jQuery('.ajax_form .tooltip1').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip1').css({display: 'none',top: 0});
														ocupado = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip1').css({display: 'none'}); ocupado = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}
			else{
				jQuery(".ajax_form").each(function(){ 
							pausa = setTimeout(function(){
												pausa = null;
												if (ocupado == 0){
													ocupado = 1;
													jQuery('.ajax_form .tooltip1').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip1').css({display: 'none',top: 0});
														ocupado = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip1').css({display: 'none'});ocupado = 0;
												}
							}, 500)
					});
				
				}
			}//// fin de TELEFONO Y FAX
			
			
			if(check_for == "fax"){
				
				var ocupado9 = 0;
				var pausa9 = null;
			if(value!=""){
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado9 == 0){ocupado9 = 1;
							jQuery('.ajax_form .tooltip9').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado9 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #fax").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 
							pausa9 = setTimeout(function(){
												pausa9 = null;
												if (ocupado9 == 0){
													ocupado9 = 1;
													jQuery('.ajax_form .tooltip9').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip9').css({display: 'none',top: 0});
														ocupado9 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip9').css({display: 'none'}); ocupado9 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}
			else{
				jQuery(".ajax_form").each(function(){ 
							pausa9 = setTimeout(function(){
												pausa9 = null;
												if (ocupado9 == 0){
													ocupado9 = 1;
													jQuery('.ajax_form .tooltip9').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip9').css({display: 'none',top: 0});
														ocupado9 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip9').css({display: 'none'}); ocupado9 = 0;
												}
							}, 500)
					});
				
				}//// fin de else
			}//// fin de  FAX
			
			
		
			

			
	
			if(check_for == "descripcion" || check_for == "curriculum"){
			var ocupado2 = 0;
			var pausa2 = null;	
			
			if(value == ""){
						surrounding_element.attr("class","").addClass("error");
						jQuery(".ajax_form").each(function (){
								if (ocupado2 == 0){
									ocupado2 = 1;
									jQuery('.ajax_form .tooltip2').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',		
									function(){
										ocupado2 = 0;});
								}
							});
						my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #descripcion").attr("value")!="" && jQuery(".ajax_form #curriculum").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa2 = setTimeout(function(){
												pausa2 = null;
												if (ocupado2 == 0){
													ocupado2 = 1;
													jQuery('.ajax_form .tooltip2').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip2').css({display: 'none',top: 0});
														ocupado2 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip2').css({display: 'none'});ocupado2 = 0;
												}
							}, 500)
						});
					}
					
				}
				
			}//// fin de CURRICULUM Y DESCRIPCION
			
			if(check_for == "productos" || check_for == "servicios" || check_for == "patentes" || check_for == "certificaciones"){
				
				var ocupado5 = 0;
				var pausa5 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado5 == 0){ocupado5 = 1;
							jQuery('.ajax_form .tooltip5').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado5 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #productos").attr("value")!="" && jQuery(".ajax_form #servicios").attr("value")!="" && jQuery(".ajax_form #patentes").attr("value")!="" && jQuery(".ajax_form #certificaciones").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa5 = setTimeout(function(){
												pausa5 = null;
												if (ocupado5 == 0){
													ocupado5 = 1;
													jQuery('.ajax_form .tooltip5').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip5').css({display: 'none',top: 0});
														ocupado5 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip5').css({display: 'none'});ocupado5 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de PRODUCTOS, SERVICVIOS, CERTIFICACIONES, PATENTES
					
			

			if(check_for == "contact_nombre" || check_for == "contact_telefono"  || check_for == "contact_correo" || check_for == "contact_direccion"){
				
				var ocupado3 = 0;
				var pausa3 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado3 == 0){
							ocupado3 = 1;
							jQuery('.ajax_form .tooltip3').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',
							function(){
								ocupado3 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_nombre").attr("value")!="" && jQuery(".ajax_form #contact_telefono").attr("value")!="" && jQuery(".ajax_form #contact_correo").attr("value")!="" && jQuery(".ajax_form #contact_direccion").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa3 = setTimeout(function(){
												pausa3 = null;
												if (ocupado3 == 0){
													ocupado3 = 1;
													jQuery('.ajax_form .tooltip3').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip3').css({display: 'none',top: 0});
														ocupado3 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip3').css({display: 'none'}); ocupado3 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de NOMBRE DE CONTACTO 			
			

			if( check_for == "contact_telefono"){
				
				var ocupado8 = 0;
				var pausa8 = null;
			if(value!=""){	
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado8 == 0){ocupado8 = 1;
							jQuery('.ajax_form .tooltip8').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado8 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_telefono").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 	
							pausa8 = setTimeout(function(){
												pausa8 = null;
												if (ocupado8 == 0){
													ocupado8 = 1;
													jQuery('.ajax_form .tooltip8').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip8').css({display: 'none',top: 0});
														ocupado8 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip8').css({display: 'none'});ocupado8 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
				
			}
			else {
					
				jQuery(".ajax_form").each(function(){ 
						pausa8 = setTimeout(function(){
											pausa8 = null;
											if (ocupado8 == 0){
												ocupado8 = 1;
												jQuery('.ajax_form .tooltip8').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
													jQuery('.ajax_form .tooltip8').css({display: 'none',top: 0});
													ocupado8 = 0;
												});
											}else{
												jQuery('.ajax_form .tooltip8').css({display: 'none'});ocupado8 = 0;
											}
						}, 500)
					});
					
				}//// fin de else
			}//// fin de TELEFONO Y FAX	DE CONTACTO
			
			
			if( check_for == "contact_fax"){
				
				var ocupado4 = 0;
				var pausa4 = null;
			if(value!=""){	
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado4 == 0){ocupado4 = 1;
							jQuery('.ajax_form .tooltip4').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado4 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_fax").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 	
							pausa4 = setTimeout(function(){
												pausa4 = null;
												if (ocupado4 == 0){
													ocupado4 = 1;
													jQuery('.ajax_form .tooltip4').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip4').css({display: 'none',top: 0});
														ocupado4 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip4').css({display: 'none'}) ; ocupado4 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
				
			}
			else {
					
				jQuery(".ajax_form").each(function(){ 
						pausa4 = setTimeout(function(){
											pausa4 = null;
											if (ocupado4 == 0){
												ocupado4 = 1;
												jQuery('.ajax_form .tooltip4').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
													jQuery('.ajax_form .tooltip4').css({display: 'none',top: 0});
													ocupado4 = 0;
												});
											}else{
												jQuery('.ajax_form .tooltip4').css({display: 'none'}); ocupado4 = 0;
											}
						}, 500)
					});
					
				}//// fin de else
			}//// fin de FAX DE CONTACTO
			
			
				if(check_for == "contact_correo"){
				var ocupado7 = 0;
				var pausa7 = null;
				if(value != ""){ 
					if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado7 == 0){ocupado7 = 1;
							jQuery('.ajax_form .tooltip7').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado7 = 0;});
						}
					});
											
					my_error = true;
					} else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_correo").attr("value").match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){																
						jQuery(".ajax_form").each(function(){
							pausa7 = setTimeout(function(){
												pausa7 = null;
												if (ocupado7 == 0){
													ocupado7 = 1;
													jQuery('.ajax_form .tooltip7').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip7').css({display: 'none',top: 0});
														ocupado7 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip7').css({display: 'none'}); ocupado7 = 0;
												}
							}, 500)
						});
					}
									
						}//// fin de else
					}
				 else{
					 jQuery(".ajax_form").each(function(){
							pausa7 = setTimeout(function(){
												pausa7 = null;
												if (ocupado7 == 0){
													ocupado7 = 1;
													jQuery('.ajax_form .tooltip7').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip7').css({display: 'none',top: 0});
														ocupado7 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip7').css({display: 'none'}); ocupado7 = 0;
												}
							}, 500)
						});
					 
					 }
				}//// fin de CORREO	

	
				if(jQuery(".ajax_form #empresa, .ajax_form #telefono, .ajax_form #fax, .ajax_form #pais, .ajax_form #curriculum, .ajax_form #descripcion, .ajax_form #productos, .ajax_form #servicios, .ajax_form #patentes, .ajax_form #certificaciones, .ajax_form #core_business, .ajax_form #contact_nombre, .ajax_form #contact_telefono, .ajax_form #contact_fax, .ajax_form #contact_correo, .ajax_form #contact_direccion").length == (i+1) ){
					
					if(my_error == false ){					
				
						var $datastring = "ajax=true";
						jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
						{
							var $name = jQuery(this).attr('name');	
							var $value = encodeURIComponent(jQuery(this).attr('value'));
							$datastring = $datastring + "&" + $name + "=" + $value;
						});
						
						//alert(url2+"/registro.php"+$datastring);
						jQuery(".ajax_form").fadeOut(500);
						jQuery('#cuadro_imagen').fadeOut(300);
						//jQuery(".ajax_form #send").fadeOut(100);
						
						jQuery('#helperFormContacto').fadeIn(function(){ 	
							jQuery.ajax({   
								type: "POST",
								url: url2+"/registro.php",
								data: $datastring,
								success: function(response){ 
								jQuery('#helperFormContacto').fadeOut(200);
								jQuery(".ajax_form").before("<div class='ajaxresponse'></div>");
								jQuery(".ajaxresponse").html(response).slideDown(500);
								jQuery(".ajax_form #send").fadeIn(500);								
								jQuery(".ajax_form #empresa, .ajax_form #telefono, .ajax_form #fax, .ajax_form #pais, .ajax_form #curriculum, .ajax_form #descripcion, .ajax_form #productos, .ajax_form #servicios, .ajax_form #patentes, .ajax_form #certificaciones, .ajax_form #core_business, .ajax_form #contact_nombre, .ajax_form #contact_telefono, .ajax_form #contact_fax, .ajax_form #contact_correo, .ajax_form #contact_direccion").val("");
								
								}
							});
						
						});
					}
					
				}
			
		}); 
	
	return false;
	
	});
	
}



function k_formContacto(){
	var my_error;
	var url2 = jQuery("meta[name=temp_url]").attr('content');
		
	jQuery(".ajax_form #sendContacto").bind("click", function(){
    
	my_error = false;
	
		jQuery(".ajax_form #contact_nombre, .ajax_form #contact_telefono, .ajax_form #contact_fax, .ajax_form #contact_correo, .ajax_form #contact_direccion").each(function(i){
			//var a = jQuery(".ajax_form #empresa").val();
			//jQuery(".ajax_form #igualar").val(a);
			
			var value = jQuery(this).attr("value");
			var check_for = jQuery(this).attr("id");
			var surrounding_element = jQuery(this).parent();
			
					if(check_for == "contact_nombre" || check_for == "contact_telefono"  || check_for == "contact_correo" || check_for == "contact_direccion"){
				
				var ocupado3 = 0;
				var pausa3 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado3 == 0){
							ocupado3 = 1;
							jQuery('.ajax_form .tooltip3').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',
							function(){
								ocupado3 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_nombre").attr("value")!="" && jQuery(".ajax_form #contact_telefono").attr("value")!="" && jQuery(".ajax_form #contact_correo").attr("value")!="" && jQuery(".ajax_form #contact_direccion").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa3 = setTimeout(function(){
												pausa3 = null;
												if (ocupado3 == 0){
													ocupado3 = 1;
													jQuery('.ajax_form .tooltip3').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip3').css({display: 'none',top: 0});
														ocupado3 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip3').css({display: 'none'});ocupado3 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de NOMBRE DE CONTACTO 			
			
			if( check_for == "contact_telefono"){
				
				var ocupado8 = 0;
				var pausa8 = null;
			if(value!=""){	
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado8 == 0){ocupado8 = 1;
							jQuery('.ajax_form .tooltip8').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado8 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_telefono").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 	
							pausa8 = setTimeout(function(){
												pausa8 = null;
												if (ocupado8 == 0){
													ocupado8 = 1;
													jQuery('.ajax_form .tooltip8').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip8').css({display: 'none',top: 0});
														ocupado8 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip8').css({display: 'none'});ocupado8 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
				
			}
			else {
					
				jQuery(".ajax_form").each(function(){ 
						pausa8 = setTimeout(function(){
											pausa8 = null;
											if (ocupado8 == 0){
												ocupado8 = 1;
												jQuery('.ajax_form .tooltip8').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
													jQuery('.ajax_form .tooltip8').css({display: 'none',top: 0});
													ocupado8 = 0;
												});
											}else{
												jQuery('.ajax_form .tooltip8').css({display: 'none'});ocupado8 = 0;
											}
						}, 500)
					});
					
				}//// fin de else
			}//// fin de TELEFONO Y FAX	DE CONTACTO
			
			
			if( check_for == "contact_fax"){
				
				var ocupado4 = 0;
				var pausa4 = null;
			if(value!=""){	
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado4 == 0){ocupado4 = 1;
							jQuery('.ajax_form .tooltip4').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado4 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_fax").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 	
							pausa4 = setTimeout(function(){
												pausa4 = null;
												if (ocupado4 == 0){
													ocupado4 = 1;
													jQuery('.ajax_form .tooltip4').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip4').css({display: 'none',top: 0});
														ocupado4 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip4').css({display: 'none'});ocupado4 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
				
			}
			else {
					
				jQuery(".ajax_form").each(function(){ 
						pausa4 = setTimeout(function(){
											pausa4 = null;
											if (ocupado4 == 0){
												ocupado4 = 1;
												jQuery('.ajax_form .tooltip4').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
													jQuery('.ajax_form .tooltip4').css({display: 'none',top: 0});
													ocupado4 = 0;
												});
											}else{
												jQuery('.ajax_form .tooltip4').css({display: 'none'});ocupado4 = 0;
											}
						}, 500)
					});
					
				}//// fin de else
			}//// fin de FAX DE CONTACTO
			
			
				if(check_for == "contact_correo"){
				var ocupado7 = 0;
				var pausa7 = null;
				if(value != ""){ 
					if(!value.match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado7 == 0){ocupado7 = 1;
							jQuery('.ajax_form .tooltip7').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado7 = 0;});
						}
					});
											
					my_error = true;
					}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #contact_correo").attr("value").match(/^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/)){																
						jQuery(".ajax_form").each(function(){
							pausa7 = setTimeout(function(){
												pausa7 = null;
												if (ocupado7 == 0){
													ocupado7 = 1;
													jQuery('.ajax_form .tooltip7').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip7').css({display: 'none',top: 0});
														ocupado7 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip7').css({display: 'none'});ocupado7 = 0;
												}
							}, 500)
						});
					}
					
				
						
						}//// fin de else
					}
				 else{
					 jQuery(".ajax_form").each(function(){
							pausa7 = setTimeout(function(){
												pausa7 = null;
												if (ocupado7 == 0){
													ocupado7 = 1;
													jQuery('.ajax_form .tooltip7').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip7').css({display: 'none',top: 0});
														ocupado7 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip7').css({display: 'none'});ocupado7 = 0;
												}
							}, 500)
						});
					 
					 }
				}//// fin de CORREO		
		
		
				if(jQuery(".ajax_form #contact_nombre, .ajax_form #contact_telefono, .ajax_form #contact_fax, .ajax_form #contact_correo, .ajax_form #contact_direccion").length == i+1){
					
					if(my_error == false ){					
				
						var $datastring = "ajax=true";
						jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
						{
							var $name = jQuery(this).attr('name');	
							var $value = encodeURIComponent(jQuery(this).attr('value'));
							$datastring = $datastring + "&" + $name + "=" + $value;
						});
						
						//alert(url2+"/registro.php"+$datastring);
						jQuery(".ajax_form").slideUp(500);
						jQuery('#cuadro_imagen').slideUp(300);
						//jQuery(".ajax_form #send").fadeOut(100);
						jQuery('#helperFormContacto').fadeIn(function(){ 	
							jQuery.ajax({   
								type: "POST",
								url: url2+"/update_contacto.php",
								data: $datastring,
								success: function(response){ 
								jQuery('#helperFormContacto').fadeOut(200);		
								jQuery(".message").html(response);
								jQuery(".ajax_form").slideDown('slow');
								jQuery(".ajax_form #sendContacto").slideDown('slow');
								jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").attr('disabled','true');
								jQuery('.view-button').css('display','none');
								
								
								}
							});
						
						});
					}
					
				}
			
		}); 
	
	return false;
	
	});
	
}



function k_formEmpresa(){
	var my_error;
	var url2 = jQuery("meta[name=temp_url]").attr('content');
		
	jQuery(".ajax_form #sendEmpresa").bind("click", function(){
    
	my_error = false;
	
		jQuery(".ajax_form #empresa, .ajax_form #telefono, .ajax_form #fax, .ajax_form #pais, .ajax_form #curriculum, .ajax_form #descripcion, .ajax_form #productos, .ajax_form #servicios, .ajax_form #patentes, .ajax_form #certificaciones, .ajax_form #core_business").each(function(i){
			//var a = jQuery(".ajax_form #empresa").val();
			//jQuery(".ajax_form #igualar").val(a);
			
			var value = jQuery(this).attr("value");
			var check_for = jQuery(this).attr("id");
			var surrounding_element = jQuery(this).parent();
			
			/*if(check_for == "revision"){
				if(value != ""){
					my_error = true;
				}
			}
			*/
	
			if(check_for == "empresa"){
				
				var ocupado1 = 0;
				var pausa1 = null;
			
					if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado1 == 0){ocupado1 = 1;
							jQuery('.ajax_form .tooltip').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado1 = 0;});
						}
					});
					my_error = true;	
						
					}else{
						surrounding_element.attr("class","").addClass("valid");
						if(jQuery(".ajax_form #empresa").attr("value")!=""){																  												jQuery(".ajax_form").each(function(){ 
								pausa1 = setTimeout(function(){
													pausa1 = null;
													if (ocupado1 == 0){
														ocupado1 = 1;
														jQuery('.ajax_form .tooltip').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
															jQuery('.ajax_form .tooltip').css({display: 'none',top: 0});
															ocupado1 = 0;
														});
													}else{
														jQuery('.ajax_form .tooltip').css({display: 'none'});ocupado1 = 0;
													}
								}, 500)
							});
						}
					}//// fin de else
			
			}//// fin de EMPRESA
				
			
			if(check_for == "telefono"){
				
				var ocupado = 0;
				var pausa = null;
			if(value!=""){
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado == 0){ocupado = 1;
							jQuery('.ajax_form .tooltip1').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #telefono").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 
							pausa = setTimeout(function(){
												pausa = null;
												if (ocupado == 0){
													ocupado = 1;
													jQuery('.ajax_form .tooltip1').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip1').css({display: 'none',top: 0});
														ocupado = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip1').css({display: 'none'});ocupado = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}
			else{
				jQuery(".ajax_form").each(function(){ 
							pausa = setTimeout(function(){
												pausa = null;
												if (ocupado == 0){
													ocupado = 1;
													jQuery('.ajax_form .tooltip1').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip1').css({display: 'none',top: 0});
														ocupado = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip1').css({display: 'none'});ocupado = 0;
												}
							}, 500)
					});
				
				}
			}//// fin de TELEFONO 
			
			
			if(check_for == "fax"){
				
				var ocupado9 = 0;
				var pausa9 = null;
			if(value!=""){
				if(!value.match(/^([0-9\+\s\+\-])+$/)){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado9 == 0){ocupado9 = 1;
							jQuery('.ajax_form .tooltip9').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado9 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #fax").attr("value").match(/^([0-9\+\s\+\-])+$/)){																  
						jQuery(".ajax_form").each(function(){ 
							pausa9 = setTimeout(function(){
												pausa9 = null;
												if (ocupado9 == 0){
													ocupado9 = 1;
													jQuery('.ajax_form .tooltip9').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip9').css({display: 'none',top: 0});
														ocupado9 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip9').css({display: 'none'}); ocupado9 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}
			else{
				jQuery(".ajax_form").each(function(){ 
							pausa9 = setTimeout(function(){
												pausa9 = null;
												if (ocupado9 == 0){
													ocupado9 = 1;
													jQuery('.ajax_form .tooltip9').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip9').css({display: 'none',top: 0});
														ocupado9 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip9').css({display: 'none'}); ocupado9 = 0;
												}
							}, 500)
					});
				
				}//// fin de else
			}//// fin de  FAX
			
			
		
			
			if(check_for == "empresa" || check_for == "telefono" || check_for == "pais" || check_for == "core_business"){
				
				var ocupado6 = 0;
				var pausa6 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado6 == 0){ocupado6 = 1;
							jQuery('.ajax_form .tooltip6').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado6 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #empresa").attr("value")!="" && jQuery(".ajax_form #telefono").attr("value")!="" && jQuery(".ajax_form #pais").attr("value")!="" && jQuery(".ajax_form #core_business").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa6 = setTimeout(function(){
												pausa6 = null;
												if (ocupado6 == 0){
													ocupado6 = 1;
													jQuery('.ajax_form .tooltip6').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip6').css({display: 'none',top: 0});
														ocupado6 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip6').css({display: 'none'});ocupado6 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de NOMBRE DE CONTACTO 	
			
			
			
			if(check_for == "descripcion" || check_for == "curriculum"){
			var ocupado2 = 0;
			var pausa2 = null;	
			
			if(value == ""){
						surrounding_element.attr("class","").addClass("error");
						jQuery(".ajax_form").each(function (){
								if (ocupado2 == 0){
									ocupado2 = 1;
									jQuery('.ajax_form .tooltip2').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',		
									function(){
										ocupado2 = 0;});
								}
							});
						my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #descripcion").attr("value")!="" && jQuery(".ajax_form #curriculum").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa2 = setTimeout(function(){
												pausa2 = null;
												if (ocupado2 == 0){
													ocupado2 = 1;
													jQuery('.ajax_form .tooltip2').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip2').css({display: 'none',top: 0});
														ocupado2 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip2').css({display: 'none'});ocupado2 = 0;
												}
							}, 500)
						});
					}
					
				}
				
			}//// fin de CURRICULUM Y DESCRIPCION*/
			
			
			
			if(check_for == "productos" || check_for == "servicios" || check_for == "patentes" || check_for == "certificaciones"){
				
				var ocupado5 = 0;
				var pausa5 = null;
				
			if(value == ""){
					surrounding_element.attr("class","").addClass("error").each(function (){
						if (ocupado5 == 0){ocupado5 = 1;
							jQuery('.ajax_form .tooltip5').css({top: 0,display: 'block',opacity: 0,}).animate({top: '-=20px',opacity: 1,}, 'normal',function(){
								ocupado5 = 0;});
						}
					});
				my_error = true;
				}else{
					surrounding_element.attr("class","").addClass("valid");
					if(jQuery(".ajax_form #productos").attr("value")!="" && jQuery(".ajax_form #servicios").attr("value")!="" && jQuery(".ajax_form #patentes").attr("value")!="" && jQuery(".ajax_form #certificaciones").attr("value")!=""){																  
						jQuery(".ajax_form").each(function(){ 
							pausa5 = setTimeout(function(){
												pausa5 = null;
												if (ocupado5 == 0){
													ocupado5 = 1;
													jQuery('.ajax_form .tooltip5').css({opacity: 1}).animate({top: '-=' + '50px',opacity: 0},'slow',function(){
														jQuery('.ajax_form .tooltip5').css({display: 'none',top: 0});
														ocupado5 = 0;
													});
												}else{
													jQuery('.ajax_form .tooltip5').css({display: 'none'});ocupado5 = 0;
												}
							}, 500)
						});
					}
					
				}//// fin de else
			}//// fin de PRODUCTOS, SERVICVIOS, CERTIFICACIONES, PATENTES


		
				if(jQuery(".ajax_form #empresa, .ajax_form #telefono, .ajax_form #fax, .ajax_form #pais, .ajax_form #curriculum, .ajax_form #descripcion, .ajax_form #productos, .ajax_form #servicios, .ajax_form #patentes, .ajax_form #certificaciones, .ajax_form #core_business").length == i+1){
					
					if(my_error == false ){					
				
						var $datastring = "ajax=true";
						jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").each(function(i)
						{
							var $name = jQuery(this).attr('name');	
							var $value = encodeURIComponent(jQuery(this).attr('value'));
							$datastring = $datastring + "&" + $name + "=" + $value;
						});
						
						//alert(url2+"/registro.php"+$datastring);
						jQuery(".ajax_form").slideUp(500);
						jQuery('#cuadro_imagen').slideUp(300);
						//jQuery(".ajax_form #send").fadeOut(100);
						jQuery('#helperFormContacto').fadeIn(function(){ 	
							jQuery.ajax({   
								type: "POST",
								url: url2+"/update_empresa.php",
								data: $datastring,
								success: function(response){ 
								jQuery('#helperFormContacto').fadeOut(200);		
								jQuery(".message").html(response);
								jQuery(".ajax_form").slideDown('slow');
								jQuery(".ajax_form #sendEmpresa").slideDown('slow');
								jQuery(".ajax_form input, .ajax_form textarea, .ajax_form radio, .ajax_form select").attr('disabled','true');
								jQuery('.view-button').css('display','none');
								
								
								}
							});
						
						});
					}
					
				}
			
		}); 
	
	return false;
	
	});
	
}
