$(document).ready(function(){
		
		//image cycle
		var images = $('#images img');
		
		if(images.length>0){
			var c=0; var l=images.length-1;
			images.hide().eq(c).show();
			$('#images').everyTime(5000, function(){
				if(c==l) c=0; else c++; 
				images.fadeOut().eq(c).fadeIn();
			});
		}
		
		//forms today's date
		$.ajax({
			type: "post",
			url: "media/scripts/php/today.php",
			data: "formid=te",
			success: function(html){
				$('span#form_te_date').html(html);
			}			
		});
		
		$.ajax({
			type: "post",
			url: "media/scripts/php/today.php",
			data: "formid=re",
			success: function(html){
				$('span#form_re_arrive').html(html);
			}			
		});
		
		$.ajax({
			type: "post",
			url: "media/scripts/php/tomorrow.php",
			data: "formid=re",
			success: function(html){
				$('span#form_re_depart').html(html);
			}
		});

	
	$(window).bind("load", function(){
				//clear form inputs (add & uses rel attributes for comparison)
				$('.inputClear').focus(function(){
					if(!$(this).attr('rel')) {
						$(this).attr('rel',$(this).val()).val('');
					} else {
						if($(this).val()==$(this).attr('rel')) $(this).val('');
					}
				}).blur(function(){
				   if($(this).val()=="") $(this).val($(this).attr('rel'));
				});
				
				$('.form_date_day').blur(function(){
					v=$(this).val();
					if(isNaN(v) || v>31 || v<1 ){
						alert("please insert a number between 1 and 31");
						$(this).val($(this).attr('rel'));
					}
				});
	});
});
