var textList = [
"Why are you keeping historic data in enterprise applications?",
"Are you really using production data to test?",
"Could your brand cope with a security breach of sensitive data?",
"Are you having problems finding niche Data Integration Professionals?",
"How much do you spend maintaining legacy applications?"
]

var defaultInterval = 5000;
var fadeRate = 1000;
var hash;

$(document).ready(function(){
	setTimeout("rollText('tagline')", 1);

	var d = new Date();
	var copyright = "&copy; " + d.getFullYear() + " Jonathan Garth Ltd.";
	$("#copyright").append(copyright);
	
	hash = window.location.hash.replace(/^#/,"");

	if (hash.length > 0)
		loadContent(hash.split('-')[0]);
	else
		loadContent("home");

	$("ul#tabs a,a#policy").click(function(){
		id = $(this).attr("id");
			loadContent(id.split('-')[0]);
		return false;
	});
	
});


function loadContent(id) 
{
		$("div#content").html(""); 	
		$("div#content").load(id+".html",function(response, status, xhr) {
			if (status == "error") loadContent("home");
		});
		$("div#content").removeClass();
		$("div#content").addClass(id);
		$("ul#tabs li.current").removeClass("current");
		$("ul#tabs li a#"+id).parent("li").addClass("current");
};

function rollText(elementId, interval)
{
	interval = interval != null ? interval : defaultInterval;

	$("#"+elementId).fadeOut(fadeRate, function(){
		rotateText(elementId);
		$("#"+elementId).fadeIn(fadeRate);
	});

	setTimeout("rollText('"+elementId+"',"+interval+")",interval);
}

function rotateText(rollingElementId)
{
	text = textList.shift();
	textList.push(text);

	if (text.length > 76)
	{
		text = "<span class='narrower'>" + text + "</span>";
	}

	$("#"+rollingElementId).html(text);

}




