var splashTimer = null;

$(document).ready(function() 
{
	$('ul#splashes').innerfade({ containerheight: '480px' });
	  
	$('div.splashIconHolder ul li').click(function(e)
	{
		e.preventDefault();
		var prev = $('div.splashIconHolder ul li.current:first').attr("rel");
		$('div.splashIconHolder ul li').removeClass("current");
		$(this).addClass("current");
		$('ul#splashes').gotoSlide($(this).attr("rel"), prev);
		/* reset splash timer */
		resetTimer();		
		return false;
	});
	
	/**
	 * Handles click on List Items on the News Archive & Client Project pages
	 */
	$('ul.contentBox li').click(function(e)
	{
		window.location = $(this).find("a").attr("href");
		return false;
	});
	
	
	$('form#searchForm input#phrase').focus(function() {
		if ($(this).val() == 'Search')
		{
			$(this).val("");
		}
	});
	
	$('form#searchForm input#phrase').blur(function() {
		if ($(this).val() == '')
		{
			$(this).val("Search");
		}
	});
	

	$("div#submitSearchForm").click(function() { $('form#searchForm').submit(); });
	
	$("form#inquiry a#submit").click(function(e) 
	{
		e.preventDefault();
		$('form#inquiry').submit();
		return false;
	});
	
	/* reset splash timer (start it) */
	resetTimer();		
});

/* Automated splash changes */
function resetTimer()
{
	clearTimeout(splashTimer);
	splashTimer = setTimeout("changeSplash()",7000);	
}

function changeSplash()
{
	obj = $('div.splashIconHolder ul li.current').next();
	if(!$(obj).attr("rel"))
	{
		obj = $('div.splashIconHolder ul li').first();
	}
	$(obj).trigger('click');
	resetTimer();	
}

function mdec(s,name)
{
	m = ""; sz = s.length;

	for (i=0; i<s.length; i++) 
	{
			c = String.fromCharCode(s.charCodeAt(sz - i - 1)); 
			
			if (c == "#")
				c = "@";
			else if(c == "&")
				c = ".";
			
			m += c;
	}
	if (name == "") name = m; 
	
	document.write('<a href="mailto:'+ m +'">' + name + '</a>');
}

