/*
*	Standard Javascript functions for the site
*/
$(document).ready(function()
{
	$.blockUI.defaults.overlayCSS.backgroundColor = '#003366';
	$.blockUI.defaults.css.backgroundColor = '#FFF78C';
	$.blockUI.defaults.css.cursor = 'default';
	
	if ( document.all && !window.opera && !window.XMLHttpRequest && $.browser.msie )
	{
		var isIE6 = true;
	}
	else
	{
		var isIE6 = false;
	};
	$.browser.msie6 = isIE6;
	
	$(".menu_heading_main").each(function()
	{
		var menu_heading_id = $(this).attr('id');
		var menu_heading_id_num = menu_heading_id.substring(16);
		
		if ($('#menu_heading_sub_' + menu_heading_id_num).length)
		{
			$('#' + menu_heading_id).click(function()
			{
				$('#menu_heading_sub_' + menu_heading_id_num).toggle();
			});
			$('#' + menu_heading_id).mouseover(function()
			{
				$('#menu_heading_sub_' + menu_heading_id_num).show();
			});
			$('#' + menu_heading_id).mouseout(function()
			{
				$('#menu_heading_sub_' + menu_heading_id_num).hide();
			});
		}
	});
	
	$(".menu_heading li").children("a").each(function()
	{
		if ($(this).attr('class') != 'login_link')
		{
			var href = $(this).attr("href");
			$(this).parent('li').click(function()
			{
				location = href;
			});		
		}
	});

	$('.tooltip').tooltip({
		track: true,
		fade: 250,
		delay: 200,
		showURL: false
	});

	$('#display_login_link, .login_link').click(function()
	{
		$('.button').css("border-style", "outset");
		
		$.blockUI(
		{
			message: $('#login_box'),
			centerY: false,
			css: {
				top: '250px',
				width: '500px',
				left: '30%'
			}
		});
		$('.blockOverlay').click(function()
		{
			$.unblockUI();		
		});
		$('#login_email').focus();
	});
	
	$('.login_link').click(function()
	{
		return false;
	});
	
	$('.cancel_login').click(function(){
		$.unblockUI();
	});
	
	$('.button').mousedown(function(){
		$(this).css("border-style", "inset");
	});
	
	$('.button').mouseout(function(){
		$(this).css("border-style", "outset");
	});

});

function grow_notify(heading, message)
{
	$.blockUI.defaults.growlCSS.backgroundColor = '#FFF78C';
	$.blockUI.defaults.growlCSS.opacity = '0.9';
	$.blockUI.defaults.growlCSS.color = '#fff';
	
	$.growlUI(heading, message);
}

function grow_notify_error(heading, message)
{
	$.blockUI.defaults.growlCSS.backgroundColor = '#FFD6D6';
	$.blockUI.defaults.growlCSS.opacity = '0.9';
	$.blockUI.defaults.growlCSS.color = '#E8E8E8';
	
	$.growlUI(heading, message);
}

function ajax_blockui(image)
{
	$().ajaxStop($.unblockUI);
	$().ajaxStart(function()
	{
		$.blockUI(
		{
			message: '<img src="' + image + '" /><p>Please wait...</p>',
			css: {backgroundColor: '#FFF'}	
		});
	});
}

function remove_location(element_id)
{
	$('#' + element_id).fadeOut('slow', function(){
		$(this).remove();
	});
}