/*$(function(){
	$('.nav>li').hover(
		function(){
		$('.submenu',this).stop(true,true).fadeIn('fast');//('fast');
		$(this).css({background: '#eee'});
		},
		function(){
		$('.submenu',this).fadeOut('fast');//animate({width: 'toggle'});//.slideUp('fast');
		$(this).css({background: 'none'});
		}
	);
});*/
$(function(){
	$('.nav>li').hover(
		function(){
			$(this).find('ul').stop(true,true).fadeIn('fast');
			$(this).children('a').addClass('selec');
//		$('.submenu',this).stop(true,true).fadeIn('fast');//('fast');
		},
		function(){
			$(this).find('ul').hide();
			$(this).children('a').removeClass('selec');
//		$('.submenu',this).fadeOut('fast');//animate({width: 'toggle'});//.slideUp('fast');
		}
	);
});


/* cotacto-ex */
/*************************************************************************************/
$(document).ready(function(){
	$('#contactoExEnviar').click(function(){
		dataString = '';
		$("#contactoExForm input, #contactoExForm textarea").each(function(i){	
			if (i == 0) dataString = this.name + '=' + escape(this.value);
			else dataString = dataString + '&' + this.name + '=' + escape(this.value);
		});
		if (validar_contacto_ex()) {
			$('#contactoEx #resultado').html('enviando ...');
			$('#contactoEx #resultado').show();
			$.ajax({
				type: 'post',
				url: 'include/contacto-ex.php',
				data: dataString,
				success: function(data){
					$('#contactoEx #resultado').html(data);
					if (data == 'Mensaje enviado') {
						$('#contactoEx #nombre').val('');
						$('#contactoEx #email').val('');
						$('#contactoEx #telefono').val('');
						$('#contactoEx #mensaje').val('');
						$('#contactoEx #captcha').val('');
						$('#contactoEx #captcha1').attr('src', 'http://www.diw.es/captcha/captcha.php?'+Math.random());
					}
				}
			});
		}
		return false;
	});
});


/*************************************************************************************/
function validar_contacto_ex () {
	var error = false;
	form = document.getElementById('contactoExForm');
	if (form) {
		if (form.nombre.value == '') {
			alert("El nombre es obligatorio");
			form.nombre.select();
			error = true;
		}else if (form.email.value == '') {
			alert("El email es obligatorio");
			form.email.select();
			error = true;
		}else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(form.email.value)) {
			alert("El campo email no es correcto");
			form.email.select();
			error=true;
		}else if (!/^\d*$/.test(form.telefono.value)) {
			alert("El telefono solo puede contener numeros");
			form.telefono.select();
			error = true;
		}
	}
	else return false;
	if (error)	return false;
	else		return true;
}
