$(document).ready
(
	function()
	{
		setInterval("slideSwitch()",3000);
		intervalForms=setInterval("forms()",50);
		setInterval("cico()",20);
	}
);

function cico()
{
	$('#search_dates input, #availability_and_price input').each
		(
			function()
			{
				if($(this).val())	{	$(this).closest('fieldset').find('legend').hide();	}
				else	{	$(this).closest('fieldset').find('legend').show();	}
			}
		);
}

function forms()
{
	if($('form textarea').length==0 || $('form .boxfield').length==0)	{	return true;	}
	
	$('form textarea').each(	
														function()	
														{
															if(!$(this).closest('p.input_element').hasClass('textarea'))	{	$(this).closest('p.input_element').addClass('textarea');	}
														}
													);
	$('form .boxfield').each(	
														function()	
														{
															if(!$(this).closest('p.input_element').hasClass('multiplec'))	{	$(this).closest('p.input_element').addClass('multiplec');	}
														}
													);
													
	clearInterval(intervalForms);
}


function slideSwitch()
{
	var $active=$('#slideshow li.active');
	
	if($active.length==0)
	{	$active = $('#slideshow li:last');	}
	var $next=$active.next().length?$active.next():$('#slideshow li:first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 600, function() {$active.removeClass('active last-active');});
}
