$(document).ready(function(){
		
		//Inicializar los campos 
		/* inicio campo url */ 
			var valorUrl = $("#url").val();
			
			$("#url").click(function(){
				if( $(this).val() == valorUrl){
					$(this).val("");
				}
			});
				
			$("#url").blur(function(){
				if( $(this).val() == ""){
					$(this).val(valorUrl);
				}
			});
		/* fin campo url */ 
		
		/* inicio campo intereses */ 
			var valorIntereses = $("#intereses").val();
			
			$("#intereses").click(function(){
				if( $(this).val() == valorIntereses){
					$(this).val("");
				}
			});
				
			$("#intereses").blur(function(){
				if( $(this).val() == ""){
					$(this).val(valorIntereses);
				}
			});
		/* fin campo url */ 
		
		/* inicio control de selects de pais / provincia */
		$("#pais").change(function(){
			var valor_now = $(this).val();
			if(valor_now != pais_defecto){
				//Ocultar el combo de provincias
				$("#provincia").val("nada");
				$("#provincia").attr("disabled","disabled");
			}
			else{
				$("#provincia").removeAttr("disabled");
				$("#provincia").val(provincia_defecto);
			}
		});
		/* fin control de selects de pais / provincia */
		
		
		
		
		// show a simple loading indicator
		/*var loader = jQuery('<div><img src="/styles/imgs/loading.gif" boder="0" alt="" /></div>')
			.css({position: "relative", top: "0", left: "0", margin: "0 0 20px 0"})
			.appendTo("#resultado-formulario")
			.hide();
		*/	
		$("#solicitar-presupuesto").submit(function(){
			jQuery().ajaxStart(function() {
				$("#loader-presupuesto").show();
			}).ajaxStop(function() {
				$("#loader-presupuesto").hide();
			}).ajaxError(function(a, b, e) {
				throw e;
			});
		});
		
		var v = jQuery("#solicitar-presupuesto").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#resultado-formulario"
				});
			},
			
			rules: {
				nombre: {required:true},
				email: {required:true, email:true},
				apellidos: {required:true},
				telefono: {required:true},
				empresa: {required:true},
				localidad: {required:true}			
			},

			messages: {},
			
			errorPlacement: function(error, element) {}
		});
		
		/*jQuery("#reset").click(function() {
			v.resetForm();
		});*/
	
});