
jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})

//config for the adapt.js script.  view more at http://adapt.960.gs
// Edit to suit your needs.
var ADAPT_CONFIG = {
  // Where is your CSS?
  path: '/stylesheets/grid/',

  // false = Only run once, when page first loads.
  // true = Change on window resize and page tilt.
  dynamic: true,

  // First range entry is the minimum.
  // Last range entry is the maximum.
  // Separate ranges by "to" keyword.
  range: [
    '0px    to 760px  = mobile.min.css',
    '760px  to 1280px = 960.min.css',
    '1280px to 2540px = 1200.min.css'
  ]
};
//end adapt.js config

$(document).ready(function() {
	$('.autofocus:first').focus();
	$("#popup_request_form").submit(function() {
		$.post(this.action, $(this).serialize(), null, "script");
		$("#form_submit_button").attr("disabled", "true");
		return false;
	});
	
	$("#persistant_contact_link").click(function(){
                    $("#persistant_contact_form").animate({width:'toggle'},1000);
    });
    
    $("#cancel_persistant_contact_form").click(function() {
    	$("#persistant_contact_form").animate({width:'toggle'},1000);
    });
    
    $("#persistant_contact_form_container").show();
    
     $("#persistant_contact_form form").submit(function() {
		$.post(this.action, $(this).serialize(), null, "script");
		$("#contact_form_submit_button").attr("disabled", "true");
		return false;
	}); 
	
	$(".tip").tooltip({ offset: [-5, 75], delay: 0 }).dynamic({ bottom: { direction: 'down' } });
	     
	//this is the homepage tabs
	$(".homepage_scrollable").scrollable({ circular:true, keyboard:false, mousewheel: true }).navigator().autoscroll({ interval:5000, autopause: false });	
	$(".homepage_feature_description .description").scrollable({ circular:true, keyboard:false, vertical:true, mousewheel: true }).navigator().autoscroll({ interval:5000, autopause:false });
	//this is the scroll function for the about_us pages
	$("#about_us_scroller").scrollable({ vertical: true, circular: true, speed:800 }).autoscroll({autoplay: true, interval: 8000});
   
   //slidedown info request menu
   $("a#request_more_information_link").click(function() {
   		$("#hidden_request_more_information_form").slideDown("fast").toggle();
   		$("a#request_more_information_link") .toggleClass("menu_open");
   		return false;
   });
   $("#request_more_information a.cancel").click(function() {
   		$("#hidden_request_more_information_form").hide();
   		$("a#request_more_information_link").removeClass("menu_open");
   		return false;
   });
   
   //vacation pages popup gallery
   $("img[rel]").overlay({
   	top: '1%',
   	mask: {
   		color: '#202020',
   		loadSpeed: 200,
   		opacity: 0.9,
   	}
   });
   
   $(".scrollable").scrollable();
   $("img.launch_photo").click(function() {
 
	// see if same thumb is being clicked
	if ($(this).hasClass("active")) { return; }
 
	// calclulate large image's URL based on the thumbnail URL (flickr specific)
	if ($(this).hasClass("note_photo")) {
		var url = $(this).attr("src").replace("medium", "large");
	}
	else {
		var url = $(this).attr("src").replace("thumb", "large");
	}
	//var url = $(this).attr("src").replace("thumb", "large");
	//var url = $(this).attr("src").replace("medium", "large");
 
	// get handle to element that wraps the image and make it semi-transparent
	var wrap = $("#image_wrap").fadeTo("medium", 0.75);
 	//var wrap = $("#image_wrap");
	// the large image from www.flickr.com
	var img = new Image();
 
 
	// call this function after it's loaded
	img.onload = function() {
 
		// make wrapper fully visible
		wrap.fadeTo("fast", 1);
 
		// change the image
		wrap.find("img").attr("src", url);
 
	};
 
	// begin loading the image from www.flickr.com
	img.src = url;
 
	// activate item
	$("img.launch_photo").removeClass("active");
	$(this).addClass("active");
	});
});

