function slideSwitch() {
	
	$('#beeld img').css('visibility', 'visible');
    var $active = $('#beeld img.active');

    if ( $active.length == 0 ) $active = $('#beeld img:last');

    var $next =  $active.next().length ? $active.next() : $('#beeld img:first');

    $active.addClass('last-active');

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


$(function() {
	var userAgent = navigator.userAgent.toLowerCase();

	if (userAgent.search('ipad') > 1) {
		if (!localStorage.ipadTipMRKNT) { 
			localStorage.setItem('ipadTipMRKNT', 'on');
		}
		
		if (localStorage.ipadTipMRKNT == 'on') {
			$('body').addClass('ipad-tip');
			$('body').prepend('<div id="ipad"><div id="ipad-tip"><span>&gt;</span><em>Zet in beginscherm</em><a href="#" class="close">x</a></div></div>');
		}
			
		document.title = 'Markant Emmen';
	}

	$('#ipad a').click(function() {
		$('#ipad').remove();
		$('body').removeClass('ipad-tip');
		
		localStorage.setItem('ipadTipMRKNT', 'off');
		
		return false;
	});
	
	ddsmoothmenu.init({
		mainmenuid: "menuWrapper",
		orientation: 'v',
		classname: 'ddsmoothmenu-v',
		contentsource: "markup"
	});
	
	Cufon.replace('h1');
	Cufon.replace('h2');
	Cufon.replace('h3');
	Cufon.now();
	
	if($('#beeld img').length > 1)
	{
		setInterval( "slideSwitch()", 5000 );
	}
	
	/*
	$('#twitterFeed').liveTwitter('PlotsTheater', {limit: 3, refresh: false, mode: 'user_timeline', showAuthor: true}, function(container, newCount){
		$('#twitterFeed a').each(function(){
			$(this).attr('target', '_blank');
		});
	});
	*/
	
	$('.homeBlock').each(function(object) {  
		var url = $('.url', this).attr('href');
		
		$.each($(this).children('.linked'), function(index, child){
			$(child).click(function() { 
				location.href=url; 
			});
			
		});
	});
	
	$('.extraLink.video').fancybox({
		type: 'iframe'
	});
	
	$('.extraLink.image').fancybox();
	
	$('.extraLink.tekst').fancybox({
		type: 'inline'
	});
});

