function check_newsletter_signup()
{	
	if (!jQuery('#name')[0].value)
	{
		alert('Du skal indtaste dit navn');
		return false;
	}
	if (!/^.+?@.+?\.[a-z]{2,6}$/.test(jQuery('#email')[0].value))
	{
		alert('Du skal indtaste en korrekt e-mail adresse');
		return false;
	}
	return true;
}

function open_worker(id)
{
	jQuery('select').hide();
	var scrollTop = scrollLeft = 0;

	if(typeof (window.pageYOffset) == 'number' )
	{
	scrollTop = window.pageYOffset;
	scrollLeft = window.pageXOffset;
	}

	else if (document.documentElement)
	{
		scrollTop = document.documentElement.scrollTop;
		scrollLeft = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{
		scrollTop = document.body.scrollTop;
		scrollLeft = document.body.scrollLeft;
	}
		
	// Cover site
	if(window.innerHeight && window.scrollMaxY)
	{  
		yScroll = getBrowserDimensions().height + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{
		yScroll = document.body.scrollHeight;
	}
	else
	{
		yScroll = document.documentElement.scrollHeight;
	}
	$("worker_info").style.top	= (scrollTop) + 'px';
	$("coversite").style.height	= (150 + yScroll) + 'px';


	// Show worker box
	jQuery.post(global_url + "ajax.worker.php", { id: id }, // Ajax call script, sending the id as a param
	function(data)
	{
		window.onresize = myResize;
		$('worker_info').innerHTML 		= data;
		$("coversite").style.display	= "block";
		$("worker_info").style.left 	= ((getBrowserDimensions().width / 2) - 417) + 'px';
		$("worker_info").style.display	= "block";
	});
}

function myResize()
{
	$("worker_info").style.left 	= ((getBrowserDimensions().width / 2) - 417) + 'px';
}

function getBrowserDimensions()
{
	var browser = {};
	if(typeof(window.innerWidth) == 'number')
	{
		browser.height = window.innerHeight;
		browser.width = window.innerWidth;
	}
	else if (document.documentElement.clientHeight)
	{
		browser.height = document.documentElement.clientHeight;
		browser.width = document.documentElement.clientWidth;
	}
	else if (document.body.clientHeight)
	{
		browser.height = document.body.clientHeight;
		browser.width = document.body.clientWidth;
	}
	return browser;
}

function close_worker()
{
	jQuery('select').show();
	$("coversite").style.display	= "none";
	$('worker_info').innerHTML		= '';
}

function focus_searchfield()
{
	$('search_value').style.top = -100 + 'px';
	$('search_text').value = '';
	$('search_text').focus();
}

function focus_searchvalue(newTop)
{
	if($('search_text').value == '')
	{
		$('search_value').style.top = newTop + 'px';
	}
}

function resize_flashmenu(newH)
{
	if(newH != parseInt($('flashmenu').style.height))
	{
		$('flashmenu').style.height = newH+'px';
	}
}

function eventhandler_worker()
{
	var array = getElementsByClassName('worker');
	if(array.length > 0)
	{
		for(var i=0; i<array.length; i++)
		{
			array[i].onmouseover = function()
			{
				this.className	= 'worker worker_active';
				// Find BW-image to hover
				var arr_col	= getElementsByClassName('color_image','img',this);
				var arr_bw	= getElementsByClassName('bw_image','img',this);
				if(arr_col.length > 0 && arr_bw.length > 0)
				{
					arr_col[0].style.display = 'none';
					arr_bw[0].style.display = 'block';
				}
			}
			array[i].onmouseout = function()
			{
				this.className	= 'worker';
				// Find BW-image to hover
				var arr_col	= getElementsByClassName('color_image','img',this);
				var arr_bw	= getElementsByClassName('bw_image','img',this);
				if(arr_col.length > 0 && arr_bw.length > 0)
				{
					arr_col[0].style.display = 'block';
					arr_bw[0].style.display = 'none';
				}
			}
			
		}
	}
}

function popup(url,id,width,height,scroll) 
{
	pos_horizon = ((screen.width/2)-(width/2));
	pos_vertical = ((screen.height/2)-(height/2));
	scroll = scroll || 'no';
	var popup_win = window.open(url,id,'width='+width+',height='+height+',left='+pos_horizon+',top='+pos_vertical+',resizable=no,scrollbars='+scroll+',menubar=no,status=no');
	popup_windows.push(popup_win);
	return popup_win;
}

// Execute functions after load
addLoadEvent(eventhandler_worker);	

if(document.all)
{
	document.execCommand("BackgroundImageCache",false,true);
}

jQuery(document).ready(function(){ $('flashmenu').style.height='30px'; });