$(document).ready(function() {
	/*
	*   Examples - images
	*/
	$('.tip').tipsy({gravity: 's'});
	
	// if (!$.browser.msie) {		
	// 	$("#wrapper").css('display', 'none');
	// 	$("#wrapper").fadeIn(2000);
	// }
	// 
	$(".photos > a[rel=gallery]").fancybox({
		'transitionIn': 'none',
		'transitionOut': 'none',
		'titlePosition': 'over'	
		});

	$(".virtual").fancybox({
		'width': '75%',
		'height': 500,
		'transitionIn': 'none',
		'transitionOut': 'none',
		'titleShow': false
	});

	$('#slideshow').cycle({
		fx: 'fade',
		speed: "4000"
		// choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	 
	$('a.prices').click(function(e) {
		e.preventDefault();
		$.scrollTo('#prices', 1000);
	});


	$('a.back').click(function(e) {
		e.preventDefault();
		$.scrollTo('#header', 1000);
	});
	
	$('a.up').click(function(e) {
		e.preventDefault();
		$.scrollTo('#header', 1000);
	});
	


	$('a.sencillos').click(function(e) {
		e.preventDefault();
		$.scrollTo('#sencillos', 1000);
	});
	
	$('a.tradicionales').click(function(e) {
		e.preventDefault();
		$.scrollTo('#tradicionales', 1000);
	});
	
	$('a.asturiana').click(function(e) {
		e.preventDefault();
		$.scrollTo('#asturiana', 1000);
	});
	
	$('a.romanticas').click(function(e) {
		e.preventDefault();
		$.scrollTo('#romanticas', 1000);
	});


	$('a.escapada.romantic').click(function(e) {
		e.preventDefault();

		$.scrollTo( '#escapadas', 2000, { 
			queue:true,
			onAfter:function(){
				$("#yourway").animate({backgroundColor: 'white'}, 'fast');
				$("#food").animate({backgroundColor: 'white'}, 'fast');
				$("#romantic").animate({backgroundColor: '#ffffcc'}, 'slow');
			}
		});

	});

	$('a.escapada.food').click(function(e) {
		e.preventDefault();

		$.scrollTo( '#escapadas', 2000, { 
			queue:true,
			onAfter:function(){
				$("#yourway").animate({backgroundColor: 'white'}, 'fast');
				$("#romantic").animate({backgroundColor: 'white'}, 'fast');
				$("#food").animate({backgroundColor: '#ffffcc'}, 'slow');
			}
		});
	});

	$('a.escapada.yourway').click(function(e) {
		e.preventDefault();

		$.scrollTo( '#escapadas', 2000, { 
			queue:true,
			onAfter:function(){
				$("#food").animate({backgroundColor: 'white'}, 'fast');
				$("#romantic").animate({backgroundColor: 'white'}, 'fast');
				$("#yourway").animate({backgroundColor: '#ffffcc'}, 'slow');
			}
		});
	});


	$('a.signup').click(function(e) {
		e.preventDefault();
		$.scrollTo('#signup', 1000);
	});

	$('a.contact').click(function(e) {
		e.preventDefault();
		$.scrollTo('#more', 1000);
	});


	$("#contact_form").validate({
		submitHandler: function(form) {
			$.post('contact/create', $(form).serializeArray(), null, 'script');
		}
	});

	$("#opinions_form").validate({
		submitHandler: function(form) {
			$.post('opinions/create', $(form).serializeArray(), null, 'script');
		}
	});


	$("#signup_form").validate({
		submitHandler: function(form) {

			$.post('signup/create', $(form).serializeArray(), null, 'script');
		}
	});

	$('ol').each(function () {

		$(this).find("li").each(function (i) {
			i = i+1;				
			$(this).prepend('<div class="number">'+i+'</div>');
		});
	});

if ($('#inputDate').length > 0) {
	$('#inputDate').DatePicker({
		format:'d/m/Y',
		date: $('#inputDate').val(),
		current: $('#inputDate').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#inputDate').DatePickerSetDate($('#inputDate').val(), true);
		},
		onChange: function(formated, dates){
			$('#inputDate').val(formated);

			$('#inputDate').DatePickerHide();

		}
	});
	}
 if ($('#inputDateB').length > 0) {
	$('#inputDateB').DatePicker({
		format:'d/m/Y',
		date: $('#inputDateB').val(),
		current: $('#inputDateB').val(),
		starts: 1,
		position: 'r',
		onBeforeShow: function(){
			$('#inputDateB').DatePickerSetDate($('#inputDateB').val(), true);
		},
		onChange: function(formated, dates){
			$('#inputDateB').val(formated);

			$('#inputDateB').DatePickerHide();

		}
	});
}
});

