/* Copyright 2011 Dave Thomas */
//Popup sub menus
$(function () {
	//Menu Functions
	var timer;
	
	if ($('#pageContainer').length > 0) {
		$('#pageContainer').insertAfter($('#mainmenu'));
		$('#pageContainer').hide().fadeIn('slow');
	}
	
	$('#footer').hide().fadeIn('slow');
     $('#content').hide().fadeIn('slow');
	
	$('#mainmenu').removeClass('noJquery');
	
	$('#mainmenu > ul > li').mouseover(function () {
		$('ul', $(this)).fadeIn('fast');
		$(this).siblings('li').children('ul').hide();
		$(this).siblings('li').children('ul').stop(true, true);
		if (timer != undefined) {
			clearTimeout(timer);
		}
	});		
	
	
	$('#mainmenu a').bind('click', function () {   
		var href = $(this).attr('href');    
		$('#mainmenu ul ul').fadeOut('slow');
		$('#footer').fadeOut('slow');
		$('#pageContainer').fadeOut('slow');
        $('#content').fadeOut('slow', function () {
            window.location = href;
        });
        return false
    });
	
	$('#mainmenu').mouseleave(function () {
		timer = setTimeout("fadeOut('#mainmenu li > ul')", 750);
	});
	
	/*//Bottom Right Canadian Flag Business Card
	$('#header_right').css({ 'bottom' : '60px', 'right' : '-180px'});
	$('#header_right .hdrclk').toggle(function () {
			$('#header_right').animate({ 'bottom' : '120px', 'right' : '0px'}); 
		}, function () {
			$('#header_right').animate({ 'bottom' : '60px', 'right' : '-180px'});
	})*/;


	
	
	
});

function fadeOut(selector) {
	$(selector).fadeOut('slow');
}

