$(document).ready(function()
{
    $('#contentlinks a').each(function() 
    {
    	url = 'http://' + window.location.hostname + window.location.pathname;
    	if($(this).attr('href') == url) 
        {
            $(this).parent().parent().addClass('submenuactive'); 
        }
    });
    
    $('#menu li').hover(
	    function()
	    {
	         $(this).children().css('color', '#000'); 
	         Cufon.replace('#menu a');
	    },
	    function()
	    {
	         $(this).children().css('color', '#fff'); 
	         Cufon.replace('#menu a');
	    }
	);
    
    $('#menu a').each(function() 
    {
    	var tekst = $(this).html();
    	
    	tekst = tekst.replace('home', 'Home');
    	tekst = tekst.replace('zorgvakanties', 'Zorgvakanties');
    	tekst = tekst.replace('cursus_-_vergadering', 'Cursus/Vergadering');
    	tekst = tekst.replace('route', 'Route');
    	tekst = tekst.replace('contact', 'Contact');
    	$(this).html(tekst);

    	var url = 'http://' + window.location.hostname + window.location.pathname;
    	var href = $(this).attr('href');

    	var myMatch = url.search(href);
    	if(myMatch != -1)
    	{
    		$(this).css('color', '#000'); 
            Cufon.replace('#menu a');
        }
    });

    $("#menu li:last-child").remove() 
    
    var imgsrc = $('#contentrechts img').attr('src');

    if(imgsrc == undefined)
    {
    	$('#contentrechts').remove();
    	$('#contentmidden').css('width', '759px');
    	$('#content').css('width', '95%');
    }
    
});

function slideSwitch() 
{
    var $active = $('#bg img.active');

    if ($active.length == 0) 
    {
    	$active = $('#bg img:last');
    }

    var $next =  $active.next().length ? $active.next() : $('#bg img:first');
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 3000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() 
{
    setInterval( "slideSwitch()", 8000 );
});

