$(document).ready(function() {
	$("#enviar_cv_form").validationEngine({
		success :  false,
		failure : function() {}
	})
	
	$("#modificar_cv_form").validationEngine({
		success :  false,
		failure : function() {}
	})

    $("#contact_form").validationEngine({
		success :  false,
		failure : function() {}
	})
	
	$("#search_form").validationEngine({
		success :  false,
		failure : function() {}
	})
	
	$('#idioma_loader').hide();   
	$('#experiencia_loader').hide();  
	
});


function addIdioma()
{
  $(document).ready(function() {  
 $("#idioma_loader").ajaxStart(function(){
      $(this).show();
    });
 $("#idioma_loader").ajaxStop(function(){
   $(this).hide();
 });
 
  var idiomas = document.getElementById('idiomas');
  var hablar = document.getElementById('hablar');
  var escribir = document.getElementById('escribir');
  var comprender = document.getElementById('comprender');
  var mas_datos_idioma = document.getElementById('mas_datos_idioma');

   $('#idioma_added').empty();	   
     $.ajax({
		type: "POST",
		url: 'edit.php?addIdioma',
		async: true,
		data: "id_idioma="+idiomas.value+"&hablar="+hablar.value+"&escribir="+escribir.value+"&comprender="+comprender.value+"&mas_datos_idioma="+mas_datos_idioma.value+"",		
		success: function(msg){	          		
		   $("#idioma_added").append(msg);
		}
	})	

});
}

function addExperiencia()
{
  $(document).ready(function() {
  
 $("#experiencia_loader").ajaxStart(function(){
      $(this).show();
    });
 $("#experiencia_loader").ajaxStop(function(){
   $(this).hide();
 });
  var mes_ano = document.getElementById('mes_ano');
  var empresa = document.getElementById('empresa');
  var descripcion_trabajo = document.getElementById('descripcion_trabajo');
  
 $('#experiencia_added').empty();	 
 
     $.ajax({
		type: "POST",
		url: 'edit.php?addExperiencia',
		async: true,
		data: "mes_ano="+mes_ano.value+"&empresa="+empresa.value+"&descripcion_trabajo="+descripcion_trabajo.value+"",		
		success: function(msg){	          		
		   $("#experiencia_added").append(msg);
		}
	})	

});
}

function removeIdioma(id)
{
  $(document).ready(function() {
  
  $('#idioma_added').empty();	
 $("#idioma_loader").ajaxStart(function(){
      $(this).show();
    });
 $("#idioma_loader").ajaxStop(function(){
   $(this).hide();
 });
 
     $.ajax({
		type: "GET",
		url: 'edit.php?removeIdioma',
		async: true,
		data: "id="+id,		
		success: function(msg){	          		
		   $("#idioma_added").append(msg);
		}
	})	

});
}

function removeExperiencia(id)
{
  $(document).ready(function() {
  
 $('#experiencia_added').empty();	
 $("#experiencia_loader").ajaxStart(function(){
      $(this).show();
    });
 $("#experiencia_loader").ajaxStop(function(){
   $(this).hide();
 });
 
     $.ajax({
		type: "GET",
		url: 'edit.php?removeExperiencia',
		async: true,
		data: "id="+id,		
		success: function(msg){	          		
		   $("#experiencia_added").append(msg);
		}
	})	

});
}

function enviarCV()
 {
   var theform ;
			   
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.enviar_cv_form;
		}
		else {
			theform = document.forms["enviar_cv_form"];
		}
		theform.submit();
 }
 
function buscar()
 {
   var theform ;
			   
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.search_form_results;
		}
		else {
			theform = document.forms["search_form_results"];
		}
		theform.submit();
 }
 
function showFormIdioma()
{
  var form_idioma = document.getElementById('form_idioma');
  
   if(form_idioma.style.display == 'none')
     form_idioma.style.display = 'block';
	else 
	form_idioma.style.display = 'none';
}

function showFormExperiencia()
{
  var form_experienciaa = document.getElementById('form_experienciaa');
  
   if(form_experienciaa.style.display == 'none')
     form_experienciaa.style.display = 'block';
	else 
	form_experienciaa.style.display = 'none';
}

function enter()
	{
	   var theform ;
			   
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.modificar_cv_form;
		}
		else {
			theform = document.forms["modificar_cv_form"];
		}
		theform.submit();
}

function confirmDel(param,urlpage,msg){
    var answer = confirm(msg)
     if (answer){
        window.location=urlpage+'='+param;
     }      	 
} 

function changeColor(box){
  var box = document.getElementById(box);
  
  if(box.className=='hotel_activity_over')
  {
    box.className='';  
    box.className='hotel_activity';
  }else{
    box.className='';  
    box.className='hotel_activity_over';
  }
}


function doWriteBlog()
	{
	   var title = document.getElementById("title");
			   
		if(title.value == '')
		{
		  alert('Please type the blog title');
		  title.focus();
		  return false;
		}else if(tinyMCE.get('text').getContent() == '')
		{
		  alert('Please type blog post');
		  return false;
		}else{ 			
		 return true		
		}	

}

function doPostTestimonial()
	{
	   var title = document.getElementById("title");
	   var text = document.getElementById("testimonial");
			   
		if(title.value == '')
		{
		  alert('Please type the title');
		  title.focus();
		  return false;
		}else if(text.value == '')
		{
		  alert('Please type the testimonial');
		  return false;
		}else{ 			
		 return true		
		}	

}

function changeCurrency(eventArgument)
	{
	   var theform ;
			   
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.Form1;
		}
		else {
			theform = document.forms["Form1"];
		}

		theform.currency_value.value = eventArgument;
		theform.submit();

}

function changeNumberPeople(eventArgument)
	{
	   var theform ;
			   
		if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
			theform = document.FPeople;
		}
		else {
			theform = document.forms["FPeople"];
		}

		theform.number_people.value = eventArgument;
		theform.submit();

}



