// Stingray -- Remote Subnavigation

var hosting_submenu = null;
var why_submenu = null;
var support_submenu = null;
var company_submenu = null;

timer = null;

$(document).ready(function() {

$("#navigation .hosting").hover(function() {


	if (why_submenu) {
		shutDown();
		showHosting();
	}
	else if (support_submenu) {
		shutDown();
		showHosting();
	}
	else if (company_submenu) {
		shutDown();
		showHosting();
	}
	else if (hosting_submenu) {
		clearTimeout(timer);	}
	else {
		showHosting();
	};

$(this).addClass("opened");

},function() {

	// On Mouseout of .hosting

	setTimer();

});

$("#navigation .why").hover(function() {

// If another submenu is open, shut it down NOW.

	if(hosting_submenu) {
		shutDown();
		showWhy();
	}
	else if(support_submenu) {
		shutDown();
		showWhy();
	}
	else if (company_submenu) {
		shutDown();
		showWhy();
	}
	else if(why_submenu) {
		clearTimeout(timer);
	}
	else {
		showWhy();
	};

$(this).addClass("opened");

},function() {

	setTimer();

});

$("#navigation .support").hover(function() {

// If another submenu is open, shut it down NOW.

	if(hosting_submenu) {
		shutDown();
		showSupport();
	}
	else if(why_submenu) {
		shutDown();
		showSupport();
	}
	else if (company_submenu) {
		shutDown();
		showSupport();
	}
	else if(support_submenu) {
		clearTimeout(timer);
	}
	else {
		showSupport();
	};

$(this).addClass("opened");

},function() {

	setTimer();

});

$("#navigation .company").hover(function() {

// If another submenu is open, shut it down NOW.

	if(hosting_submenu) {
		shutDown();
		showCompany();
	}
	else if(why_submenu) {
		shutDown();
		showCompany();
	}
	else if (support_submenu) {
		shutDown();
		showCompany();
	}
	else if(company_submenu) {
		clearTimeout(timer);
	}
	else {
		showCompany();
	};

$(this).addClass("opened");

},function() {

	setTimer();

});

$("#header .submenu").hover(function () {

	clearTimeout(timer);
	
},function() {

	setTimer();
	
}); // Submenu Hover sticking
}); // Ready Function

function shutDown() {

$("#navigation .opened").removeClass("opened");

if (hosting_submenu) {
	hosting_submenu.fadeOut("normal");
	hosting_submenu = null;
	} // if the hosting submenu is open

if (why_submenu) {
	why_submenu.fadeOut("normal");
	why_submenu = null;

	} // if the why submenu is open

if (support_submenu) {
	support_submenu.fadeOut("normal");
	support_submenu = null;

	} // if the support submenu is open

if (company_submenu) {
	company_submenu.fadeOut("normal");
	company_submenu = null;

	} // if the company submenu is open

} // shutdown

function showHosting() {
	clearTimeout(timer);
	$("#hosting_submenu").slideDown("normal");
	hosting_submenu = $("#hosting_submenu");	
} // show hosting 

function showWhy() {
	clearTimeout(timer);
	$("#why_submenu").slideDown("normal");
	why_submenu = $("#why_submenu");
} // show why us menu

function showSupport() {
	clearTimeout(timer);
	$("#support_submenu").slideDown("normal");
	support_submenu = $("#support_submenu");
} // show why us menu

function showCompany() {
	clearTimeout(timer);
	$("#company_submenu").slideDown("normal");
	company_submenu = $("#company_submenu");
} // show company menu

function setTimer() {
	timer = setTimeout(
	"shutDown()",400);
} // set timer
