//************************************************

//The BodyHoliday LeSport website by Halpern Cowan

//************************************************

Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('table.optionalExtras th');
Cufon.replace('p.ppc-offer span');

$(document).ready(function(){
	$('#globalNav').corner('bottom'); // rounded corners for global nav
	
	$("input.inDate").datepicker({ // datepicker calendar
		hideIfNoPrevNext: true,
		minDate: new Date()
	});
	
	$("input.prevDate").datepicker({ // datepicker calendar
		hideIfNoPrevNext: false,
		changeYear: true,
		yearRange: '1920:2015'	
	});
	
	$("input.nights").spinner({max: 15, min: 1}); // number of nights input box
	
	$('a.questions').click(function(e){ // FAQs animated scroll to
		var question = $(this).attr('href');
		$.scrollTo(question, 600);
		e.preventDefault();
	});
	
	$('a.backToTop').click(function(e){ // FAQs Back to top animated scroll to
		$.scrollTo('#contentGlobal', 600);
		e.preventDefault();
	});
	
	//$('#headerImageHome').cycle('fade'); // homepage slideshow
	if($('#slideshowHeader')){ // other pages slideshow
		$('#slideshowHeader').cycle('fade');
	}

    // Default text on form fields
    $('.defaultText').each(function(i, el){
        $(el).val(this.title)
             .focus(function(){
                 if (this.value == this.title) {
                     $(this).val('')
                            .removeClass('defaultText');
                 }
             })
             .blur(function(){
                 if (!this.value) {
                     $(this).val(this.title)
                            .addClass('defaultText');
                 }
             });

        var parent = el.parentNode
        while (parent != null) {
            if (parent.tagName == 'FORM') {
                parent.onsubmit = function() {
                    if (el.value == el.title) {
                        el.value = '';
                    }
                }
                break;
            }
            parent = parent.parentNode;
        }
    });
	
	// Footer social media logo rollovers
	$('ul.socialMedia li.facebook a').hover(
		function(){
			$(this).children().attr('src', '/images/icons/facebook-over.jpg');
		},
		function(){
			$(this).children().attr('src', '/images/icons/facebook.jpg');
		}
	);
	$('ul.socialMedia li.twitter a').hover(
		function(){
			$(this).children().attr('src', '/images/icons/twitter-over.jpg');
		},
		function(){
			$(this).children().attr('src', '/images/icons/twitter.jpg');
		}
	);
});

