	function OpenWindow(theURL,winName,features){
		var myWindow = window.open(theURL,winName,features);
	}
	
	$(function() { 
	    
	    //Adjust image size
	    $.fn.resizenow = function() {
	        //Define starting width and height values for the original image
	        var startwidth = 1440;  
	        var startheight = 900;
	        //Define image ratio
	        var ratio = startheight/startwidth;
	        //Gather browser dimensions
	        var browserwidth = $(window).width();
	        var browserheight = $(window).height();
	        //Resize image to proper ratio
	        if ((browserheight/browserwidth) > ratio) {
	            $(this).height(browserheight);
	            $(this).width(browserheight / ratio);
	            $(this).children().height(browserheight);
	            $(this).children().width(browserheight / ratio);
	        } else {
	            $(this).width(browserwidth);
	            $(this).height(browserwidth * ratio);
	            $(this).children().width(browserwidth);
	            $(this).children().height(browserwidth * ratio);
	        }
	        //Make sure the image stays center in the window
	        $(this).children().css('left', (browserwidth - $(this).width())/2);
	        $(this).children().css('top', (browserheight - $(this).height())/2);
	    };
	    
	    
		$('#homepage-container').resizenow(); 

		$(window).bind("resize", function() {
			$('#homepage-container').resizenow(); 
		});
		
		$('#check-in-date').datepicker({ minDate: 0, dateFormat: 'yy-mm-dd' }).closest('body').find('#ui-datepicker-div').wrap('<div class="cal"></div>');
		$('#check-out-date').datepicker({
			dateFormat: 'yy-mm-dd',
			beforeShow: function newMin(input) {
				var getTheDate = $('#check-in-date').datepicker('getDate');
				return { minDate: getTheDate }
			}
		}).closest('body').find('#ui-datepicker-div').wrap('<div class="cal"></div>');
		
		$('#photo-slideshow').nivoSlider({ 
			effect: 'fade',
			slices: 1,
			pauseTime: 3000,
			directionNav: true,
			controlNavThumbs: true,
			controlNavThumbsSearch: '.jpg',
			controlNavThumbsReplace: '-thumb.jpg'
		});
		
		// Any pages with videos that have thumbnail pictures
		
		var clickedThumb;
		$('.room-thumbs li a').click(function(){  
			clickedThumb = $(this).attr('rel');
			$('#flash-video, .skip-video, video').hide();
			$('iframe').remove();
			$('.post-video, .view-video').show();
			$('.post-video img').hide();
			$('.post-video img#'+clickedThumb).show();
		});
		
		// Creates tabs for a variety of places throughout the site

		$('#treatments, #sports').tabs({ fx: { opacity: 'toggle' } });
		
		// Neat enlarger for Press Images
		
		$('.press-page img').animate({ opacity: ".75" });
		$('.press-page img').hover(function(){  
			$(this).addClass('hover');
			$(this).animate({ opacity: "1" }, 500);
		},function(){  
			$(this).removeClass('hover');
			$(this).animate({ opacity: ".75" }, 500);
		});
		
		// Takes care of the left side image switching on the spa -> treatments page
		
		var tsh;
		function spaValign() {
			tsh = $('#text-side').height();
			marginSize = (tsh-$('#treatment-imagery img').height())/2;
			$('#treatment-imagery').css('height',tsh);
			$('#treatment-imagery img').css('margin-top',marginSize);
		}
		
		var treatmentID;	
		$('#treatment-tabs li a').click(function(){
			treatmentID = $(this).attr('id');
			$('#treatment-imagery img').fadeOut().queue(function(){  
				$('.'+treatmentID+'-large').fadeIn();
				spaValign();
				$(this).dequeue();
			});
		});
		
		// Adjusts the Play images, similar to code above
		
		var playID;	
		$('#sports-nav li a').click(function(){
			playID = $(this).attr('rel');
			$('#play-imagery img').hide().queue(function(){  
				$('.'+playID+'-image').fadeIn();
				$(this).dequeue();
			});
		});
		
		// Navigate through floorplans
		
		var floorPlan;
		$('#floorplans li a').click(function(){  
			floorPlan = $(this).attr('rel');
			$('#media-side img').hide();
			$('#'+floorPlan).fadeIn();
		});
		
		// Navigate through data tables on the charts page
		
		var tableName;
		$('#table-nav li a').click(function(){  
			tableName = $(this).attr('href');
			$('#table-nav li a').removeClass('active');
			$(this).addClass('active');
			$('.chart-table').hide();
			$(tableName).show();
		});
		
		// Request Forms (Meeting/Party)
		
		$('.requests:first').show();
		
		var requestClick;
		$('#request li a').click(function(){  
			requestClick = $(this).attr('href');
			$('.requests').hide();
			$(requestClick).show();
			$('.success').hide();
		});
		
		// Video Related Scripts
		
		$('.skip-video').show();
		
		$('.skip-video').click(function(){ 
			$(this).hide();
			$('#flash-video, video').hide();
			$('iframe').remove();
			$('.post-video img').hide();
			$('.post-video, .post-video img:first').fadeIn();
		});
		
		$('.view-video').click(function(){
			location.reload();
			//$(this).hide();
			//$('.post-video, .post-video img:first').hide();
			//$('#flash-video, .skip-video, video').show();
		});
		
		// AJAX-ify Forms
		
		$('#contact-us').ajaxForm({
			beforeSubmit: validate,
			clearForm: true,
			success: successMessage
		});
		
		$('#meeting-request').ajaxForm({
			beforeSubmit: reqValidate,
			clearForm: true,
			success: successMessage
		});
		
		$('#party-request').ajaxForm({
			beforeSubmit: partyValidate,
			clearForm: true,
			success: successMessage
		});
		
		function validate() { 
			var nameValue = $('input[name=Name]').fieldValue(); 
    		var emailValue = $('input[name=Email]').fieldValue();
    		var commentValue = $('textarea[name=Comment or Question]').fieldValue(); 
    		if (!nameValue[0] || !emailValue[0] || !commentValue[0]) { 
		        alert('Please fill in all fields before submitting'); 
		        return false; 
		    } 
		}
		
		function partyValidate() { 
			var nameValue = $('#party-request input[name=Name]').fieldValue(); 
    		var dateValue = $('#party-request input[name=Preferred Date]').fieldValue();
    		var guestsValue = $('#party-request input[name=Number of guests]').fieldValue();
    		var brunchValue = $('#party-request select[name=Brunch]').fieldValue();
    		var lunchValue = $('#party-request select[name=Lunch]').fieldValue();
    		var dinnerValue = $('#party-request select[name=Dinner]').fieldValue();
    		var guestroomsValue = $('#party-request input[name=Number of guestrooms]').fieldValue();
    		var telephoneValue = $('#party-request input[name=Telephone]').fieldValue();
    		var emailValue = $('#party-request input[name=Email]').fieldValue();
    		if (!nameValue[0] || !dateValue[0] || !guestsValue[0] || !brunchValue[0] || !lunchValue[0] || !dinnerValue[0] || !guestroomsValue[0] || !telephoneValue[0] || !emailValue[0]) { 
		        alert('Please fill in all fields before submitting'); 
		        return false; 
		    } 
		}
		
		function reqValidate() {
			var nameValue = $('#meeting-request input[name=Your Name]').fieldValue();
			var companyValue = $('#meeting-request input[name=Company]').fieldValue();
			var addressValue = $('#meeting-request input[name=Address]').fieldValue();
			var cityValue = $('#meeting-request input[name=City]').fieldValue();
			var stateValue = $('#meeting-request input[name=State]').fieldValue();
			var zipValue = $('#meeting-request input[name=Zip Code]').fieldValue();
			var telephoneValue = $('#meeting-request input[name=Telephone]').fieldValue(); 
			var emailValue = $('#meeting-request input[name=Email]').fieldValue(); 
			var whenValue = $('#meeting-request input[name=When are you traveling to Palm Springs]').fieldValue(); 
			var howmanyValue = $('#meeting-request input[name=How many nights]').fieldValue();
			if (!nameValue[0] || !companyValue[0] || !addressValue[0] || !cityValue[0] || !stateValue[0] || !zipValue[0] || !telephoneValue[0] || !emailValue[0] || !whenValue[0] || !howmanyValue[0]) { 
		        alert('Please fill in all fields before submitting');
		        return false;
		    }
		}
		
		function successMessage() { $('.success').fadeIn().delay(3000).fadeOut(); }
	
	});
