var def = 1;
var def_top = 1;
var topcycle = setInterval(cycleTop, 10000);
var featurecycle = setInterval(cycleFeature, 3000);

function setFeature(id)
{
	if (id != def)
	{
		$("#feature_title").animate({marginTop: -18*(id-1)}, 500);
		$("#feature_image").animate({marginLeft: -450*(id-1)}, 500);
		
		$("#feature_description_" + def).slideUp(); 
		$("#feature_description_" + id).delay(500).slideDown(); 
	
		document.getElementById("feature_link_" + def).className = "feature_item_1";
		document.getElementById("feature_link_" + def).style.backgroundColor = "#004e9e";
		
		document.getElementById("feature_link_" + id).className = "feature_item_2";
		document.getElementById("feature_link_" + id).style.backgroundColor = "#008aff";
		
		def = id;	
	}
}

function cycleFeature()
{
	var id = def;
	
	if (def == 6)
		id = 1;
	else
		id++;
	
	setFeature(id);
}

function featureOver(id)
{
	if (id != def)
	{
		document.getElementById("feature_link_" + id).style.backgroundColor = '#d60000';
	}
}

function featureOut(id)
{
	if (id != def)
	{
		document.getElementById("feature_link_" + id).style.backgroundColor = '#004e9e';
	}
}

function cycleTop()
{
	if (def_top == 10)
		def_top = 1;
	else
		def_top++;
	
	$("#frontpage_top").animate({marginTop: -95*(def_top-1)}, 500);
}

function topOver()
{
	clearInterval(topcycle);
}

function topOut()
{
	topcycle = setInterval(cycleTop, 10000);
}

function topOver2(selection)
{
	selection.style.backgroundColor = '#d60000';
	selection.style.color = '#FFFFFF';
}

function topOut2(selection)
{
	selection.style.backgroundColor = '#FFFFFF';
	selection.style.color = '#999999';
}


function topCycle(dir)
{
	if (dir == 1)
	{
		if (def_top == 1)
			def_top = 10;
		else
			def_top--;
	}
	else if (dir == 2)
	{
		if (def_top == 10)
			def_top = 1;
		else
			def_top++;
	}
	
	$("#frontpage_top").animate({marginTop: -95*(def_top-1)}, 500);
}

function featureOver2()
{
	clearInterval(featurecycle);
}

function featureOut2()
{
	featurecycle = setInterval(cycleFeature, 3000);
}
