function initTextBox(inputId, defaultValue)
{
	inputId = '#' + inputId;

	$(inputId).focus(function()
	{
		if($(inputId).val() == defaultValue)
		{
			$(inputId).removeClass('grey');
			$(inputId).addClass('black');
			$(inputId).val("");
		}
	});
   
	$(inputId).blur(function()
	{
		if($.trim($(inputId).val()) == "")
		{
			$(inputId).removeClass('black');
			$(inputId).addClass('grey');
			$(inputId).val(defaultValue);
		}
	});
}

function initPasswordBox(inputId, defaultValue)
{
	var textInputId = '#' + inputId + 'Text';
	inputId = '#' + inputId;
	$(textInputId).focus(function()
	{	
		$(textInputId).toggleClass('hidden');
		$(inputId).toggleClass('hidden');
		$(inputId).focus();
	});
	
	$(inputId).blur(function()
	{
		if($.trim($(inputId).val()) == "")
		{
			$(textInputId).toggleClass('hidden');
			$(inputId).toggleClass('hidden');
		}
	});
}

function goTourSearch()
{
	if($('#tourSearch').hasClass('grey'))
	{
		$('#tourSearch').val('');
	}
}

function goNewsSearch()
{
	if($('#tourSearch').hasClass('grey'))
	{
		$('#tourSearch').val('');
	}
}


// Used by login.php
function login()
{
	if($('#login_username').hasClass('grey'))
	{
		$('#login_username').val('');
	}
	
	$('#login_passwordText').val('');
}

//
function submitForm(formId)
{
	try
	{
		var form = document.getElementById(formId);
		form.submit();
	}
	catch(ex)
	{
	}
}

function goToPage(url)
{
	document.location = url;
}

function process_banners()
{
	// Set delay to prevent all banners refreshing at once, we increment per banner container load
	var initial_delay = 0;
	
	$('.banner_wrapper').each(function(i)
	{
		var paging_div = '#' + this.id + ' > .banner_paging';
		var banners_div = '#' + this.id + ' > .banners';
		
		$(banners_div).cycle
		({
			fx: 'fade',
			pause: true,
			speed: 500,
			timeout: 6000,
			delay: initial_delay,
			pager: paging_div 
		});
		
		initial_delay += 800;
		
		// Shows and hides navigation based on hovering over the banners
		$(banners_div).hover
		(
			function(){$(this).next().next().css('display','block'); $('.content').css('color', '#ffffff');},
			function(){$(this).next().next().css('display','none'); $('.content').css('color', '#00aeef');}
		);
		
		$(paging_div).hover
		(
			function(){$(this).css('display','block')}
		);
	});
}
