jQuery(document).ready(function()
{
	initNavigation();
});

function initNavigation()
{
	jQuery('.navigation li').hover(function()
	{
		jQuery(this).addClass('hover');
	},
	function()
	{
		jQuery(this).removeClass('hover');
		setTimeout(function(){Cufon.refresh('ul.navigation > li > a')}, 10);
	});
}

function validateContactForm(id)
{
	var ok = true;
	
	jQuery('#' + id + ' .required').each(function()
	{
		if(jQuery(this).val() == '')
		{
			ok = false;
			jQuery(this).addClass('error');
		}
		else
			jQuery(this).removeClass('error');
	});
	
	if(!ok)
		jQuery('#validate-msg').html('Alle felter markeret med * skal udfyldes.').show();
	else
		jQuery('#validate-msg').hide();
	
	return ok;
}

function slideSwitch()
{
    var $active = jQuery('#slides img.active');

    if($active.length == 0)
		$active = jQuery('#slides img:last');

    var $next = $active.next().length ? $active.next() : jQuery('#slides img:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0}).addClass('active').animate({opacity: 1.0}, 1000, function()
	{
		$active.removeClass('active last-active');
	});
}
