$(function()
{
	
	$('.datepick').datePicker();
	
	$('#enddate').addClass('.dpchoosedate dpdisabled');
	
	
	$('#startdate').bind(
		'dpClosed',
		function(e, selectedDates)
		{
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#enddate').dpSetStartDate(d.addDays(1).asString());
				$('#enddate').val ( d.addDays(7).asString() );
				$('#enddate').attr("class", "datepick dpapplied .dpchoosedate");
			}
		}
	);
	$('#enddate').bind(
		'dpClosed',
		function(e, selectedDates)
		{
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#startdate').dpSetEndDate(d.addDays(-1).asString());
			}
		}
	);
});

$( document ).ready( function(){
	
	//alert ("casa");							  

	var vacationRentalsPhotoThumbs = $('#photothumbs');
    var vacationRentalsThumbs = vacationRentalsPhotoThumbs.find( '> a' );       

	if (vacationRentalsThumbs.size() > 7){
		var i= 8;

		for (i; i<vacationRentalsThumbs.size();i++){		
			vacationRentalsThumbs.eq(i).css({display: 'none', visibility: 'hidden'});
		}
	}
	
	var thums= $('#photothumbs img');


	var largePhotoClass = "";
	var largePhotoTitle = "";
	var largePhotoAlt   = "";
	var largePhotoSrc   = "";
	var smallPhotoClass = "";
	var smallPhotoTitle = "";
	var smallPhotoAlt   = "";
	var smallPhotoSrc   = "";
	
	
	thums.mouseover(
		
		function () { 
			thums.index( $( this ) ); 
			
			//Large photo properties
			largePhotoClass = $('#photolarge img').attr("class");
			largePhotoTitle = $('#photolarge img').attr("title");
			largePhotoAlt = $('#photolarge img').attr("alt");
			largePhotoSrc = $('#photolarge img').attr("src");
			
			//Thumb photo properties
			smallPhotoClass = thums.eq( thums.index($(this)) ).attr("class");
			smallPhotoTitle = thums.eq( thums.index($(this)) ).attr("title");
			smallPhotoAlt = thums.eq( thums.index($(this)) ).attr("alt");
			smallPhotoSrc = thums.eq( thums.index($(this)) ).attr("src");
			
			
			//Empty photolarge div and put the selected photo
			$('#photolarge').empty();
			$('#photolarge').append('<img class="' + largePhotoClass + '" title="' + smallPhotoTitle + '" alt="' + smallPhotoAlt + '" src="' + smallPhotoSrc.replace( "-t.jpg", "-l.jpg") + '" />' );
			
		}
		
	).mouseout(function(){
		
		/*
		//Put in the selected thumb the large photo that was changed
		thums.eq( thums.index($(this)) ).attr("class",smallPhotoClass);
		thums.eq( thums.index($(this)) ).attr("title",largePhotoTitle);
		thums.eq( thums.index($(this)) ).attr("alt",largePhotoAlt);
		thums.eq( thums.index($(this)) ).attr("src",largePhotoSrc.replace( "-l.jpg", "-t.jpg"));		
		*/
	});
	
	var textToShow= "Inquiries that appear to include a website URL or spam violate our terms of service and will not be delivered.";
	$('#message').val(textToShow).css({color: 'gray'});
	
});

function imposeMaxLength(Object, MaxLen)
{
	document.contactform.message.style.color = "#000";
  return (Object.value.length <= MaxLen);
}