// JavaScript Document

// -------------------------------------------
// will add target to external links (jQuery)
// -------------------------------------------
function externalLinks(){
	$('a[@rel^="external"]').attr('target', '_blank').click(function(){
		hideAmbassador();
	});
}

jQuery(document).ready(function() {	
								
	
	toggleSlideShow();
								
	// set the date format for the calendar plugin
    $.datePicker.setDateFormat('mdy', '/');
	// initalize
    $('input#arrival').datePicker();
	$('input#depart').datePicker();
	

	//Savings form
	var active_color = '#000'; // Colour of user provided text
	var inactive_color = '#999'; // Colour of default text
	$("input.default-value").css("color", inactive_color);
	  var default_values = new Array();
	  $("input.default-value").focus(function() {
		if (!default_values[this.id]) {
		  default_values[this.id] = this.value;
		}
		if (this.value == default_values[this.id]) {
		  this.value = '';
		  this.style.color = active_color;
		}
		$(this).blur(function() {
		  if (this.value == '') {
			this.style.color = inactive_color;
			this.value = default_values[this.id];
		  }
		});
	  });
	  
	 $('#emailSignup').submit(function (){
		email = $('#ESemail').val();
		zip = $('#zip').val();
		$.ajax({
		   type: "POST",
		   url: "/site/apicall/",
		   data: "email=" + email + "&zip=" + zip,
		   success: function(){
		   }
		}); //close ajax
	 }); //close onSubmit

}); //close doc.ready

var toggleSlideShow = function(resortId) {
	if (jQuery('#slideshow').children().length > 1) {
		jQuery('#slideshow').cycle({
										fx:			'fade',
										next:		'#next',
										prev:		'#previous'
		});
		jQuery('#playpause').click(function(){
			if (jQuery(this).attr('rel') == 'play') {
				jQuery('#slideshow').cycle('resume');
				jQuery(this).attr('rel', 'pause');
				jQuery(this).children().attr('src', '/media/layout/btn-pause.gif'); //image to pause button
			}
			else {
				jQuery('#slideshow').cycle('pause');
				jQuery(this).attr('rel', 'play');
				jQuery(this).children().attr('src', '/media/layout/btn-play.gif'); //image to play button
			}
			return false;
		});
	}
}