$(document).ready(function()
{
	$('.navmenucontents').hide();
	
	$('.navmenu').each(function()
	{
		var id = $(this).attr('id');

		$('#'+id).click(function(e)
		{
			var container = $('#'+$(this).attr('id')+'_contents');
			var position = $(this).offset();
			container.show();
		  	container.css('left', parseInt(position.left)+"px");
			container.css('top', parseInt(position.top + $(this).height() + 15)+"px");
			e.stopPropagation();
			return false;
		});
	});
	
	$(document).click( function()
	{
		$('.navmenucontents').each( function(){ $(this).hide(); });
	});
	
	$('#search_keywords').focus(function()
	{
		if( $('#search_keywords').val() == 'Search...' )
		{
			$('#search_keywords').val('');
		}
	});
	
	$('input.linkcode').focus(function()
	{
		$(this).select();
	});
	
	if( $('#report-file') )
	{
		$('#report-file').colorbox( { inline: true, href: '#report-box' } );
	}

	$('ul.ui_drop_small').each(ui_drop);
	$('ul.ui_drop_large').each(ui_drop);
});

function ui_drop()
{
	$(this).click(function()
	{
		$(this).toggleClass('selected');
		
		if($(this).hasClass('selected'))
		{
			var obj = this;
			setTimeout(function()
			{
				$(document).click(function()
				{
					$(obj).removeClass('selected');
					$(this).unbind('click');
				});
			}, 0);
		}
	});
}
