var newsNum = 0;
var newslength;
var spotNum = 0;
var spotlength;
var headline_interval;
$(document).ready(function() {
	//$('#midrow > div').corner();

	newslength = $("#news_strip_box > a").length;
	headline_interval = setInterval(rotateNews,5000);
	spotlength = $("#spotlightcont > div").length;
	$('#newsnext').click(function()
	{
		clearInterval(headline_interval);
		rotateNews(1);
		if (newsNum != newslength - 1)
			newsNum++;
		else
			newsNum = 0;
		headline_interval = setInterval(rotateNews,5000);
		return false;
	});
	$('#newsprev').click(function()
	{
		clearInterval(headline_interval);
		rotateNews(1);
		if (newsNum != 0)
			newsNum--;
		else
			newsNum = newslength - 1;
		headline_interval = setInterval(rotateNews,5000);
		return false;
	});
	
	$('#spotprev').click(function()
	{
		$("#spotlightcont > div:eq(" + spotNum  +")").fadeOut("slow", showSpot);
		if (spotNum != 0)
			spotNum--;
		else
			spotNum = spotlength - 1;
		return false;
	});
	
	$('#spotnext').click(function()
	{
		$("#spotlightcont > div:eq(" + spotNum  +")").fadeOut("slow", showSpot);
		if (spotNum != spotlength - 1)
			spotNum++;
		else
			spotNum = 0;
		return false;
	});
	
	function rotateNews(fromClick)
	{
		$("#news_strip_box > a:eq(" + newsNum  +")").fadeOut("slow", showNews);
		if (!fromClick)
		{
			if (newsNum != newslength - 1)
				newsNum++;
			else
				newsNum = 0;
		}
	}
	
	function showNews()
	{
		$("#news_strip_box > a:eq(" + newsNum  +")").fadeIn("fast");
	}
	
	function showSpot()
	{
		$("#spotlightcont > div:eq(" + spotNum  +")").fadeIn("fast");
	}
	
	if ($('#leftcolumn')){
		try
		{
		$('#leftcolumn div:eq(1)').corner({tl : { radius: 6 },tr: { radius: 1 },bl: false,br: false,antiAlias: true,autoPad: true});
		$('#leftcolumn').corner({tl : { radius: 6 },tr: { radius: 1 },bl: { radius: 6 },br: { radius: 1 },antiAlias: true,autoPad: true});
		$('#rightcolumn div:eq(0)').corner({tl : { radius: 1 },tr: { radius: 6 },bl: false,br: false,antiAlias: true,autoPad: true});
		$('#rightcolumn').corner({tl : { radius: 1 },tr: { radius: 6 },bl: { radius: 1 },br: { radius: 6 },antiAlias: true,autoPad: true});
		$('#contentcolumn').corner({tl : { radius: 1 },tr: { radius: 1 },bl: { radius: 1 },br: { radius: 1 },antiAlias: true,autoPad: true});/**/
		}
		catch (ex)
		{
			alert(ex);
		}
	}
	if( document.location.toString().indexOf( 'https://' ) == -1 ) {
		clickHeatSite = 'finjan';
		clickHeatGroup = encodeURIComponent(document.title);
		clickHeatServer = 'http://199.203.243.203/finjan/clickheat/click.php';
		initClickHeat();
	}
});