/*
* Author:	Mazzi Nabavi	
* Created:	15/10/2010
* Copyright Flight Centre Ltd. All rights reserved.
* 
*/

;MEGAMENU = 
{

    init: function()
    {         
        $(document).ready(function() 
        {
            try
            {
				MEGAMENU.setMegaMenu();
				MEGAMENU.setSelectedMenu();
            }
            catch(e){}
        });
    },
    
    setMegaMenu: function(){
		// There used to be a time out here. That is why we have the hoverSelf and ...
		$('ul#nav_main li').mouseenter(function(e) {
			var hoverSelf = this;			
			$(hoverSelf).find('.topMenuExpand').show();
		});
		$('ul#nav_main li').mouseleave(function(e) {
			var unHoverSelf = this;
			$(unHoverSelf).find('.topMenuExpand').hide();
		});
	},
	setSelectedMenu: function()
	{
		var pathname = window.location;
		if (/gapyear\.com\/$/.test(pathname)) $('#topMenu ul>li:eq(0)').attr('id','currentMenu');
		if (/gapyear\.com\/plan\//.test(pathname)) $('#topMenu ul li:eq(1)').attr('id','currentMenu');
		if (/gapyear\.com\/countries\//.test(pathname)) $('#topMenu ul>li:eq(2)').attr('id','currentMenu');
		if (/gapyear\.com\/volunteering\//.test(pathname)) $('#topMenu ul>li:eq(3)').attr('id','currentMenu');	
		if (/gapyear\.com\/jobs\//.test(pathname)) $('#topMenu ul>li:eq(4)').attr('id','currentMenu');
		if (/gapyear\.com\/short-gaps\//.test(pathname)) $('#topMenu ul>li:eq(5)').attr('id','currentMenu');
		if (/gapyear\.com\/advice\//.test(pathname)) $('#topMenu ul>li:eq(6)').attr('id','currentMenu');
		if (/gapyear\.com\/offers\//.test(pathname)) $('#topMenu ul>li:eq(7)').attr('id','currentMenu');
		if (/gapyear\.com\/articles\//.test(pathname)) $('#topMenu ul>li:eq(8)').attr('id','currentMenu');
		if (/gapyear\.com\/community\//.test(pathname)) $('#topMenu ul>li:eq(9)').attr('id','currentMenu');
	}
};
MEGAMENU.init();
