function callMe() {
	var dDate;
	var iYear;
	var iMonth;
	var iDay;

	dDate = new Date();
	iDay = dDate.getDate();
	iMonth = dDate.getMonth();
	iYear = dDate.getFullYear();

	for (var i=0;i<=document.frmBook.checkInDate.length-1; i++) {
		if (document.frmBook.checkInDate[i].value == iDay) {
			document.frmBook.checkInDate[i].selected=true;
		}
	}

	for (var i=0;i<=document.frmBook.checkInMonth.length-1; i++) {
		if (document.frmBook.checkInMonth[i].value == iMonth + 1) {
			document.frmBook.checkInMonth[i].selected=true;
		}
	}

	for (var i=0;i<=document.frmBook.checkInYear.length-1; i++) {
		if (document.frmBook.checkInYear[i].value == iYear) {
			document.frmBook.checkInYear[i].selected=true;
		}
	}
}

function openWin(URL) {
	aWindow=window.open(URL, "terms", "top=20,left=20,toolbar=no,width=520,height=400,status=no,scrollbars=yes,resize=no,menubar=no");
}

function getTerms() {
	var s = checkDate(document.frmBook);
	if (s) {
		var sDate ;
		var nNights ;
		sDate = document.frmBook.ArrivalDay.options[document.frmBook.ArrivalDay.selectedIndex].value + '/'+ document.frmBook.ArrivalMonth.options[document.frmBook.ArrivalMonth.selectedIndex].value + '/' + document.frmBook.ArrivalYear.options[document.frmBook.ArrivalYear.selectedIndex].value;
		nNights = document.frmBook.Nights.options[document.frmBook.Nights.selectedIndex].value;
		openWin("terms.asp?date=" + sDate + "&nNights=" + nNights);
	}
}

function checkDate(frm) {
		var dDate;
		var iYear;
		var iMonth;
		var iDay;
		var aMonthDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];

		dDate = new Date();
		iDay = dDate.getDate();
		iMonth = dDate.getMonth();
		iYear = dDate.getFullYear();

		// now, check if the year is OK
		if ( frm.ArrivalYear.options[frm.ArrivalYear.selectedIndex].value == iYear) {
			if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value < iMonth + 1) {
				alert( "Please select the Arrival Date greater than or equal to Today.");
				return false;
			} else if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value == iMonth + 1) {
				if ( frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value < iDay) {
					alert( "Please select the Arrival Date greater than or equal to Today.");
					return false;
				}
			}
		}

		// check that the upper date limit is OK
		if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value != 2) {
			if (frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value > aMonthDays[ frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value]) {
				alert( "Please select an Valid Date of the selected Month.");
				return false;
			}
		}

		// check the date in february is correct
		if ( frm.ArrivalMonth.options[frm.ArrivalMonth.selectedIndex].value == 2) {
			if (frm.ArrivalDay.options[frm.ArrivalDay.selectedIndex].value > daysInFebruary( frm.ArrivalYear.options[frm.ArrivalYear.selectedIndex].value)) {
				alert( "Please select an Valid Date in month of February.");
				return false;
			}
		}
	return true;
}

function validate(frm) {
	var s = checkDate(frm);
	if (!s) {
		return s;
	}

	if ( parseInt(frm.Rooms.options[frm.Rooms.selectedIndex].value) > parseInt(frm.Adults.options[frm.Adults.selectedIndex].value) ) {
		alert("There should be one Adult Per Room.");
		frm.Adults.focus();
		return false;
	}
}

function daysInFebruary (year) {
	// February has 29 days in any year evenly divisible by four,
  // EXCEPT for centurial years which are not also divisible by 400.
  return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function emailStart(obj) {
	if (obj.value) obj.value='';
}
	
function messageStart(obj) {
	if (obj.value) obj.value='';
}	

$(document).ready(function() {
	/* zjisteni a nastaveni velikosti okna */
	var windowOne = $('#windowOne').height();
	var windowTwo = $('#windowTwo').height();
	var windowThree = $('#windowThree').height();
	var windowFour = $('#windowFour').height();
	var arrayNum = [windowOne, windowTwo, windowThree, windowFour];
	var maximal = Math.max.apply(null, arrayNum);

	$('#box-homepage .text').css('height', maximal+15);
	
	$("ul.sf-menu").superfish();
});

$(document).ready(function() {
	
	function mycarousel_initCallback(carousel) {
		jQuery('#featured-next-button').bind('click', function() {
			carousel.next();
			return false;
		});		
		jQuery('#featured-prev-button').bind('click', function() {
			carousel.prev();
			return false;
		});		
		jQuery('.button-nav span').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			return false;
		});
	};
	
	/* slider v hlavicce */
	$('#features').jshowoff({
		animatePause: false,	// nezobrazuje se animovany text pri pauze
		effect: 'fade',			// efekt mezi prechodem slideru
		autoPlay: true,			// automaticke spusteni pri startu
		speed: 4500,			// doba v ms kdy bude nasledovat dalsi slider
		changeSpeed: 2500,		// doba prechodu mezi slidery
		hoverPause: false		// zakaze menit obrazky pri prejeti tlacitka play/pause
	});
});
