var flag = 0;
var timer = 500;
var timerOut = 500;

$(document).ready(function(){
	$("#interestedIn").hover(function(){
	  flag = 1;
	  $(this).removeClass('droptabhover').addClass('droptabhout');
	  $("#Layer1").fadeIn(timer);
	},function(){
		 flag = 0;
		 window.setTimeout('hideMe()', timerOut);
	});

	$("#Layer1").hover(function(){
		flag = 1;
		$("#interestedIn").removeClass('droptabhover').addClass('droptabhout');
	},function(){
	    flag = 0;
		window.setTimeout('hideMe()', timerOut);
	});

	//set auto show panel after 5 sec
	panelId = window.setInterval('callPanel()', 10000);

	$('#slide2,#slide3,#slide4').css('display', 'none');

	$('#l1,#l2,#l3,#l4').click(function(){
		var txt = $(this).attr('id');
		txt = txt.replace('l', '');
		showPanel(txt);
		//stop now
		window.clearInterval(panelId);
	});
});

//declare function to call after a time
function hideMe()
{
	if(flag == 0)
	{
		$("#interestedIn").removeClass('droptabhout').addClass('droptabhover');
		$("#Layer1").fadeOut(timer-400);

	}
}



//store default id on load
var prevId = '1';

//declare function to auto call panel
function callPanel()
{
	var newId = (prevId < 4) ? (parseInt(prevId) +1) : 1;
	showPanel(newId);
}

//declare function to show panel
function showPanel(id)
{
	//change class
	$('#l'+prevId).removeClass('selected').addClass('off');
	$('#l'+id).removeClass('off').addClass('selected');
	
	//show/hide div
	$('#slide'+prevId).hide();
	$('#slide'+id).fadeIn("slow");
	//store default id
	prevId = id;
}

//top menus
ddlevelsmenu.setup("ddtopmenubar", "topbar");

