	$(document).ready(function() {
	
		$("a.fancy_group").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500
		});
		$("a.fancy_iframe").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 600,
			'frameHeight'			: 450
		});
		$("a.fancy_pages").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 700,
			'frameHeight'			: 480
		});
		$("a.fancy_video").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 500,
			'frameHeight'			: 400,
			'callbackOnClose'		: function() { $("#fancy_content").empty();} 
		});
		$("a.fancy_testlevel").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 700,
			'frameHeight'			: 480
		});
		$("a.fancy_pie").fancybox({
			'hideOnContentClick'	: false,
			'zoomOpacity'			: true,
			'zoomSpeedIn'			: 500,
			'zoomSpeedOut'			: 500,
			'frameWidth'			: 700,
			'frameHeight'			: 480
		});
		/*
		$("#manuel").click(function () {
			$("#pepe").html("askd kasdkj ajksd jkasjkd askdj <strong>sd</strong> asd asd");
		});
		$("#manuela").click(function () {
			$("#pepe").html("asjk dkajsd kaskhd kgaskd kajsd kjaskd kasdkjasjk djasdj jasdj kkasd kjasdkj askjd kjasdkjasd asaskdj <strong>sd</strong> asd asd");
		});
		*/
		
		/* 
			esta función es un hack para I5+/IE6
			"añade" la capacidad de hover a los elementos LI, claseándolos
		*/
		if (document.all&&document.getElementById) 
		{
			// para el menú principal
			navRoot = document.getElementById("nav");
			if(navRoot != null){
				for (i=0; i<navRoot.childNodes.length; i++) 
				{
					node = navRoot.childNodes[i];
					if (node.nodeName=="LI") 
					{
						node.onmouseover=function() 
						{
							this.className+=" over";
						}
						
						node.onmouseout=function() 
						{
							this.className=this.className.substring(0,this.className.indexOf(" "));
						}
					}
				}
			}
		}
		
		
		if($("#language").val() == 'es-ES')
			$.datepicker.setDefaults($.datepicker.regional['es']);
		else
			$.datepicker.setDefaults($.datepicker.regional['']);
		
		$("#fechanacimiento").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd/mm/yy',
			beforeShow: function(input) {
				var d = new Date();
				$(this).datepicker('option', 'yearRange', (d.getFullYear()-60)+':'+(d.getFullYear()-5));
			}
		});
		
		$("#fechainicio").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd/mm/yy'
		});
		
		$("#fechafin").datepicker({
			changeMonth: true,
			changeYear: true,
			beforeShow: function(input) {
				var theDate = new Date(Date.parse($('#fechainicio').datepicker('getDate')));
				$(this).datepicker('option', 'minDate', theDate);
			},
			dateFormat: 'dd/mm/yy'
		});
		
		$("#fechallegada").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd/mm/yy',
			minDate: new Date(),
			onSelect: function(dateText, inst) {
				hoy = new Date(Date.parse($('#fechasalida').datepicker('getDate')));
				inicio = new Date(Date.parse($('#fechallegada').datepicker('getDate')));
				resta = hoy.getTime()-inicio.getTime();
				resultado = Math.floor(resta/(1000*60*60*24)); 
				$('#nochestotal').val(resultado);
			}
		});
		
		$("#fechasalida").datepicker({
			changeMonth: true,
			changeYear: true,
			beforeShow: function(input) {
				var theDate = new Date(Date.parse($('#fechallegada').datepicker('getDate')));
				$(this).datepicker('option', 'minDate', new Date(theDate.getFullYear(),theDate.getMonth(),(theDate.getDate()+1)));
			},
			dateFormat: 'dd/mm/yy',
			onSelect: function(dateText, inst) {
				hoy = new Date(Date.parse($('#fechasalida').datepicker('getDate')));
				inicio = new Date(Date.parse($('#fechallegada').datepicker('getDate')));
				resta = hoy.getTime()-inicio.getTime();
				resultado = Math.floor(resta/(1000*60*60*24)); 
				$('#nochestotal').val(resultado);
			}
		});
		
		$('.desa').attr("disabled", "disabled");
		
		$("#inscr1").validate({
			rules:{
				nombre: "required",
				apellidos: "required",
				email: {
					required: true,
					email: true
				}
			},
			messages:{
				nombre: '*',
				apellidos: '*',
				email: '*'
			}
		});
		
		$("#inscr2").validate({
			rules:{
				legal: "required"				
			},
			messages:{
				legal: 'You must accept the conditions / Debes aceptar las condiciones <br>'				
			}
		});
	});
	
	function resetRadios(){
		$('.desa').attr('disabled', 'disabled'); 
		$('.desa').attr('checked', false);
	}
	
	function activaRadios1(){
		jQuery("input[name=tipohabitacion]").each(function(i) {
	        jQuery(this).removeAttr('disabled');
		});
	}
	
	function activaRadios2(){
		jQuery("input[name=familiatipo]").each(function(i) {
	        jQuery(this).removeAttr('disabled');
		});
	}
	
	function activaRadios3(){
		jQuery("input[name=tipohabitacion3]").each(function(i) {
	        jQuery(this).removeAttr('disabled');
		});
	}
	
	function activaRadios4(){
		jQuery("input[name=tipohabitacion4]").each(function(i) {
	        jQuery(this).removeAttr('disabled');
		});
	}
	
	function activaRadios5(){
		jQuery("input[name=habitapart]").each(function(i) {
	        jQuery(this).removeAttr('disabled');
		});
	}
	
	function next(){
		f = document.forms["inscr1"];
		f.action = 'form_accomodation.php';
	}
	
	function send(){
		f = document.forms["inscr1"];
		f.action = 'form_ok.php';
	}

	
	function ViewMenu(idd) {
		$("#"+idd).slideToggle("slow");
	}
	
	function visualitza_capa(np,classtitular) {

		document.getElementById('pestanyas').className = classtitular;
		for (i=1; i<=13; i++) {
			if (i==np) {
				document.getElementById('central_'+np).style.display='block';
				document.getElementById('central_'+np).className = 'current';
			} else {
				document.getElementById('central_'+i).style.display='none';
				document.getElementById('central_'+i).className = '';
			}
		}
	}
