/**
 * @author daniel
 */
$(document).ready(function(){
	
	// Lightbox
	$('a.lightbox').lightBox({
		imageBtnClose: domain + 'media/js/lightbox/images/closelabel_dk.gif',
		txtImage:'Billede',
		txtOf:'af'
	});
	
	// Search field
	$('#search-field').focus(function(){
		if($(this).val() == 'Indtast søgeord her')
		{
			$(this).val('');
		}
	});
	$('#search-field').blur(function(){
		if($(this).val() == '')
		{
			$(this).val('Indtast søgeord her');
		}
	});
	$('#search-submit').click(function(){
		$('#search-form').submit();
	});
	// Dropdown menu
	$('#topmenu .menu a').mouseover(function(e){
		if($(this).parent().children('.sub').length > 0)
		{
			var pos = $(this).position();
			var total = 0;
			var obj = $(this);
			var go = true;
			var i = 0;
			$(this).parent().prevAll('li').each(function(){
				total += 30;
			});			var child = $(this).parent().children('.sub:first');
			if (!$(this).parent().parent().hasClass('sub')) {
				child.css({
					left: pos.left
				});
			}
			else
			{
				child.css({
					left:parseInt($(this).parent().parent().width()),
					top:total
				});
			}
			child.show();
			$(child).mouseover(function(e){
				$(child).show();
			});
			$(child).mouseout(function()
			{
				$(child).hide();
			});
			$(child).children('ul').mouseover(function(){
				$(child).show();
			});
		}
	});
	$('#topmenu .menu a').mouseout(function(){
		if ($(this).parent().children('.sub').length > 0)
		{
			$(this).parent().children('.sub:first').hide();
		}
	});
});

