$(document).ready(function()
{
	setInterval(forms,50);
	
	var intervalCalendarHideYear=setInterval(calendarHideYear,50);
	var intervalChange=setInterval(change,20);
	propertyPageTitles();


function forms()
{
	$('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');}});
}

function calendarHideYear()
{
	$('div.calendar tr.headrow td:first, div.calendar tr.headrow td:last').hide();
	$('div.calendar tr.headrow td:eq(2)').attr('colspan','6');
	clearInterval(intervalCalendarHideYear);
}

function change()
{
	$('#search_guests fieldset.e-1 legend span, .template-property div.guests fieldset.e-1 legend span').text('(older than 2 years)');
	clearInterval(intervalChange);
}

function propertyPageTitles()
{
	if($('.template-property').length==0)	{	return false;	}
	if($('#titles').length<=0)	{	$('<ul id="titles"></ul>').prependTo('#content');	}
	$('.template-property #content > .block:not(:first) h2').each(function()	{	$('<li><a href="#'+$(this).parent().parent().attr('id')+'">'+$(this).text()+'</a></li>').appendTo('#titles');	});
	if($('#titles').length<=1)	{	$('<li><a href="#availability_calendar">Availability Calendar</a></li>').appendTo('#titles');	}
}

});
