﻿/// <reference path="jquery-1.4.1-vsdoc.js" />
/// <reference path="jquery-ui-1.8.4.custom.min.js" />

var g_menuWait = 300;

var g_showNavTimeOut = null;
var g_hideNavTimeOut = null;
var g_showContoryTimeOut = null;
var g_hideContoryTimeOut = null;

function GlobalPageLoad() {
	$('div.navbarItem').not('div.navbarDrop').hover(
		function () {
			$(this).addClass('navbarItemHover');
			$('#' + this.id + ' a').css('color', '#1B1B1B');
		},
		function () {
			$(this).removeClass('navbarItemHover');
			$('#' + this.id + ' a').css('color', '');
		}
	).end().click(function () {
		document.location = $(this).children('a:first').attr('href');
	});

	$('div.navbarDrop').hover( // _nav_item & _panel_item
		function () { ShowNavPanel('_panel' + this.id.substr(4), this.id); },
		function () { HideNavPanel(); }
	);

	$('div.navpanel').hover(
		function () { clearTimeout(g_hideNavTimeOut); },
		function () { HideNavPanel(); }
	);

	$('#_global_search_btn').click(function () {
		$('#_global_search').submit();
	});

	$('#topCountryBtn, #topCountryBtnImg').hover(
		function () { ShowContory(); }
	);

	$('#topCountryDrop').hover(
		function () { ShowContory(); },
		function () { HideContory(); }
	);
}

function ShowNavPanel(id, navId)
{
	g_showNavTimeOut = setTimeout("ForceShowNavPanel('" + id + "','" + navId + "');", g_menuWait);
}

function ForceShowNavPanel(id, navId)
{
	ForceHideNavPanel();
	$('div#' + id).css('display', 'block');
	$('div#' + navId).addClass('navbarItemHover navbarDropHover');
	$('div#' + navId + ' a').css('color', '#1B1B1B');
}

function HideNavPanel()
{
	clearTimeout(g_showNavTimeOut);
	g_hideNavTimeOut = setTimeout("ForceHideNavPanel()", g_menuWait);
}

function ForceHideNavPanel()
{
	$('div.navbarDrop').removeClass('navbarItemHover navbarDropHover');
	$('div.navbarDrop a').css('color', '');
	$('div.navpanel').css('display', 'none');
}

function ShowContory()
{
	g_showContoryTimeOut = setTimeout("ForceShowContoryPanel();", g_menuWait);
}

function ForceShowContoryPanel()
{
	$('#topCountryDrop').css('display', 'block');
}

function HideContory()
{
	clearTimeout(g_showContoryTimeOut);
	g_hideContoryTimeOut = setTimeout("ForceHideContoryPanel()", g_menuWait);
}

function ForceHideContoryPanel()
{
	$('#topCountryDrop').css('display', 'none');
}


