/*
function update() {
	alert ("update");
}
*/
//var i = 1;
var timer = 0;
function update()
{
	switch (i)
	{
		case 1:
			$("div#ff_sub_4 img").css("border-color","");
			$("div#ff_sub_1 img").css("border-color","#" + highlightColor);
			html_image = '<a href="' + ff_url_1 + '"><img  border="0" src="/fun/images/' + ff_type_1 + '/thumbs/lg/' + ff_image_1 + '" alt="' + ff_title_1 + '" /></a>';//top image html
			html_des = '<h1>' + ff_title_1 + '</h1><p>' + ff_description_1 + '</p><a href="' + ff_url_1 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
			i++;
//			alert("case 1");
			break;
		case 2:
			$("div#ff_sub_1 img").css("border-color","");
			$("div#ff_sub_2 img").css("border-color","#" + highlightColor);
			html_image = '<a href="' + ff_url_2 + '"><img  border="0" src="/fun/images/' + ff_type_2 + '/thumbs/lg/' + ff_image_2 + '" alt="' + ff_title_2 + '" /></a>';//top image html
			html_des = '<h1>' + ff_title_2 + '</h1><p>' + ff_description_2 + '</p><a href="' + ff_url_2 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
			i++;
			break;
		case 3:
			$("div#ff_sub_2 img").css("border-color","");
			$("div#ff_sub_3 img").css("border-color","#" + highlightColor);
			html_image = '<a href="' + ff_url_3 + '"><img  border="0" src="/fun/images/' + ff_type_3 + '/thumbs/lg/' + ff_image_3 + '" alt="' + ff_title_3 + '" /></a>';//top image html
			html_des = '<h1>' + ff_title_3 + '</h1><p>' + ff_description_3 + '</p><a href="' + ff_url_3 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
			i++;
			break;
		case 4:
			$("div#ff_sub_3 img").css("border-color","");
			$("div#ff_sub_4 img").css("border-color","#" + highlightColor);
			html_image = '<a href="' + ff_url_4 + '"><img  border="0" src="/fun/images/' + ff_type_4 + '/thumbs/lg/' + ff_image_4 + '" alt="' + ff_title_4 + '" /></a>';//top image html
			html_des = '<h1>' + ff_title_4 + '</h1><p>' + ff_description_4 + '</p><a href="' + ff_url_4 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
			i = 1;
			break; 
		default:
			i = 1;
			update();
			break;
	}
	$("#" + id_mainImage).html(html_image);
	$("#" + id_description).html(html_des);		
}

function hightligtSelected()
{
	switch (i)
	{
		case 1:
			$("div#ff_sub_1 img").css("border-color","#" + highlightColor);
			i++;
			break;
		case 2:
			$("div#ff_sub_2 img").css("border-color","#" + highlightColor);
			i++;
			break;
		case 3:
			$("div#ff_sub_3 img").css("border-color","#" + highlightColor);
			i++;
			break;
		case 4:
			$("div#ff_sub_4 img").css("border-color","#" + highlightColor);
			i=1;
			break; 
		default:
			break;
	}
}
$(function() 
{
	$("div#ff_sub_1").click(function()
	{
		var html = '<a href="' + ff_url_1 + '"><img  border="0" src="/fun/images/' + ff_type_1 + '/thumbs/lg/' + ff_image_1 + '" alt="' + ff_title_1 + '" /></a>';//top image html
		$("#" + id_mainImage).html(html);
		html = '<h1>' + ff_title_1 + '</h1><p>' + ff_description_1 + '</p><a href="' + ff_url_1 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
		$("#" + id_description).html(html);		
		$("div#ff_sub_1 img").css("border-color","#" + highlightColor);
		$("div#ff_sub_2 img").css("border-color","");
		$("div#ff_sub_3 img").css("border-color","");
		$("div#ff_sub_4 img").css("border-color","");
		clearInterval(timer);
	})
	$("div#ff_sub_2").click(function()
	{
		var html = '<a href="' + ff_url_2 + '"><img  border="0" src="/fun/images/' + ff_type_2 + '/thumbs/lg/' + ff_image_2 + '" alt="' + ff_title_2 + '" /></a>';//top image html
		$("#" + id_mainImage).html(html);
		html = '<h1>' + ff_title_2 + '</h1><p>' + ff_description_2 + '</p><a href="' + ff_url_2 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
		$("#" + id_description).html(html);		
		$("div#ff_sub_1 img").css("border-color","");
		$("div#ff_sub_2 img").css("border-color","#" + highlightColor);
		$("div#ff_sub_3 img").css("border-color","");
		$("div#ff_sub_4 img").css("border-color","");
		clearInterval(timer);
	})
	$("div#ff_sub_3").click(function()
	{
		var html = '<a href="' + ff_url_3 + '"><img  border="0" src="/fun/images/' + ff_type_3 + '/thumbs/lg/' + ff_image_3 + '" alt="' + ff_title_3 + '" /></a>';//top image html
		$("#" + id_mainImage).html(html);
		html = '<h1>' + ff_title_3 + '</h1><p>' + ff_description_3 + '</p><a href="' + ff_url_3 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
		$("#" + id_description).html(html);		
		$("div#ff_sub_1 img").css("border-color","");
		$("div#ff_sub_2 img").css("border-color","");
		$("div#ff_sub_3 img").css("border-color","#" + highlightColor);
		$("div#ff_sub_4 img").css("border-color","");
		clearInterval(timer);
	})
	$("div#ff_sub_4").click(function()
	{
		var  html = '<a href="' + ff_url_4 + '"><img  border="0" src="/fun/images/' + ff_type_4 + '/thumbs/lg/' + ff_image_4 + '" alt="' + ff_title_4 + '" /></a>';//top image html
		$("#" + id_mainImage).html(html);
		html = '<h1>' + ff_title_4 + '</h1><p>' + ff_description_4 + '</p><a href="' + ff_url_4 + '"><img id="' + id_btn + '" src="' + src_btn + '" alt="Play now" border="0" width="108" height="42" /></a>'; // ffdescription content
		$("#" + id_description).html(html);		
		$("div#ff_sub_1 img").css("border-color","");
		$("div#ff_sub_2 img").css("border-color","");
		$("div#ff_sub_3 img").css("border-color","");
		$("div#ff_sub_4 img").css("border-color","#" + highlightColor);
		clearInterval(timer);
	})
	$(window).load(function()
	{
//		alert("page loaded");
		var html_image = '';
		var html_des = '';
		timer = setInterval("update()",5000);	
		hightligtSelected();
	})


})