jQuery(document).ready(function(){
	//Menu Superior
	jQuery(".select_sub ul li").hide();
	
	jQuery("#opt3").hover(function(){
	
		jQuery("#opt3 .select_sub ul li").show();
		
	}, function(){
	
		jQuery("#opt3 .select_sub ul li").hide();
		
	});
	
	jQuery("#opt2").hover(function(){
	
		jQuery("#opt2 .select_sub ul li").show();
		
	}, function(){
	
		jQuery("#opt2 .select_sub ul li").hide();
		
	});
	
	jQuery('#loading_contacto').css({
		'display': 'none'
	});
	
	jQuery('#response_contacto').css({
		'display': 'none'
	});
	
	/*jQuery('div.AMIPCI img.hover').hide();
	jQuery('div.AMIPCI img').hover(function(){
		jQuery('div.AMIPCI img').hide();
		jQuery('div.AMIPCI img.hover').show();
	}, function(){
		jQuery('div.AMIPCI img').show();
		jQuery('div.AMIPCI img.hover').hide();
	});*/
	jQuery("#formulario_contacto").validate({
		rules: {
			nombre: {
				required: true,
				minlength: 3,
				maxlength: 50
			},
			email: {
				required: true,
				email: true,
				minlength: 3,
				maxlength: 50
			},
			mensaje: {
				required: true,
				minlength: 10,
				maxlength: 1000
			}
		},
		messages: {
			nombre: "Introduce tu nombre por favor",
			email: "Introduce un email válido por favor",
			mensaje: "Introduce un mensaje por favor ( 10 - 1000 caractéres)"
		},
		submitHandler: function(){
			jQuery("#formulario_contacto").ajaxSubmit({
				beforeSubmit: showRequest, // pre-submit callback 
				success: showResponse // post-submit callback
			});
		},
		highlight: function(element, errorClass){
			//jQuery(element).addClass('error');
		},
		unhighlight: function(element, errorClass){
			//jQuery(element).removeClass('error');
		}
	});
	
	function showRequest(formData, jqForm, options){
		jQuery("#loading_contacto").show("slow");
	}
	
	function showResponse(responseText, statusText){
		jQuery("#loading_contacto").hide("slow");
		jQuery("#response_contacto").show("slow").append(responseText).fadeTo(3000, 1).fadeOut(2000);
		jQuery('form')[1].reset();
	}
	
	jQuery(".politicas").fancybox({
		'frameWidth': 500,
		'frameHeight': 500
	});
	jQuery(".accesoClientes a").fancybox({
		'frameWidth': 410,
		'frameHeight': 210,
		'overlayOpacity': .80,
		'hideOnContentClick': false
	});
	jQuery(".fancybox").fancybox({
		'frameWidth': 950,
		'frameHeight': 500,
		'hideOnContentClick': false
	});
	
/*	window.addEvent('accesoCliente', function(){
		$$(".sexyform input", ".sexyform select", ".sexyform textarea").each(function(el){
			el.DoSexy();
		});
	});
*/
	
	
	
	/*formulario del cotizador*/
	
	jQuery('#loading_cotizador').hide();
	
	jQuery("#formularioCotiza").validate({
		rules: {
			vFacturas: {
				required: true,
				number: true
			},
			enganche: {
				required: true,
				number: true
			
			}
		},
		messages: {
			vFacturas: "Ingresa Valor factura",
			enganche: "Ingresa tu Enganche"
		},
		submitHandler: function(){
			jQuery("#formularioCotiza").ajaxSubmit({
				beforeSubmit: showRequestCotizador, // pre-submit callback 
				success: showResponseCotizador // post-submit callback
			});
		},
		highlight: function(element, errorClass){
			//jQuery(element).addClass('error');
		},
		unhighlight: function(element, errorClass){
			//jQuery(element).removeClass('error');
		}
	});
	
	function showResponseCotizador(responseText, statusText){
		jQuery('#cotizaIva').css('display', 'block');
		jQuery('#cotizaIva').empty();
		jQuery('#cotizaIva').append(responseText);
		jQuery('#tabs').tabs();
		jQuery('#silder').easySlider();
		jQuery('#loading_cotizador').hide('slow');
		jQuery('#footer').css("position","static");
		
		
	}
	
	function showRequestCotizador(formData, jqForm, options){
		jQuery('#loading_cotizador').show('slow');
	}
});



