jQuery(function($) {
	
	
	$("#slider").easySlider({controlsShow: false,auto: true,continuous: true});
	/*$('.home-news').jcarousel({
        auto:5,
		scroll:1,
		wrap: 'last'
    });*/
		

	// submenu: punten tussenvoegen
	$('#submenu li a').not('#submenu li:last a').after(' . '); 
	
	$('#gallery > ul').addClass('gallery_demo galleria'); // adds new class name to maintain degradability
	$('.gallery_demo').before("<div id='imageHolder'><img src='' alt='' /></div>");
	
	// bij pagina laden, img invullen met eerste uit de lijst
	if ($('#imageHolder img').attr('src') == "") {
		var mySrc = $('.gallery_demo li:first img').attr('src');
		var myAlt = $('.gallery_demo li:first img').attr('alt');
		
		$('#imageHolder img').attr({src : mySrc});
		$('#imageHolder img').attr({alt : myAlt});
		
	}
	
	// bij mouseover, foto wisselen
	$('.gallery_demo li img').mouseover(function() {
		var mySrc = $(this).attr("src");
		var myAlt = $(this).attr("alt");
		
		//alert(mySrc);
		$('#imageHolder img').attr({src : mySrc});
		$('#imageHolder img').attr({alt : myAlt});
	});
	
	// indien een url aanwezig, hiernaar surfen bij klikken
	$('#imageHolder img, ul.galleria img').mouseover(function() {
		var myAlt = $(this).attr('alt');
		if (myAlt.substr(0, 7) == "http://") {
			$(this).css({'cursor' : 'pointer'});
		}
	});
	$('#imageHolder img, ul.galleria img').click(function() {
		var myAlt = $(this).attr('alt');
		if (myAlt.substr(0, 7) == "http://") {
			window.open(myAlt);
		}
	});
	
	
	// shaduw toevoegen
	//$('#gallery').append("<img src='uploads/images/galleryLeft.png' width='10' height='97' id='shadeLeft' /><img src='uploads/images/galleryRight.png' width='10' height='97' id='shadeRight' />")
	$('.simply-scroll-container').append("<img src='uploads/images/galleryLeft.png' width='10' height='97' id='shadeLeft' /><img src='uploads/images/galleryRight.png' width='10' height='97' id='shadeRight' />")
	
	$('#galleryNav a').not(":last").after(" . ");
	
	// links op de homepage
	$('.homepage div').not('.homepage div.home-news, .homepage div.home-news div').hover(
		function() {
			$(this).css({'background' : 'none #003259'});
			$(this).find('p').css({'color' : '#fff'});
			$(this).find('h2').css({'color' : '#fff'});
		},
		function() {
			$(this).css({'background' : '#fff url(uploads/images/bgHomeBadkamers.jpg) 0px 0px no-repeat'});
			$(this).find('p').css({'color' : '#003259'});
			$(this).find('h2').css({'color' : '#003259'});
		}
	);

	$('.homepage div').click(function () {
		var url = $(this).find('a').attr('href');
		//alert("URL: "+url);
		window.location.assign(url);
	});
	
	// breedte van ul aanpassen...
	var nPictures = $('ul.galleria li').length;
	var nGalleriaWidth = nPictures * ($('ul.galleria li img').width() + 3) + 30;
	if (nGalleriaWidth < 510) {
		nGalleriaWidth = 510;
		$('.simply-scroll-btn').css({'display' : 'none'});
	}
	$('ul.galleria').css({'width' : nGalleriaWidth+"px"});
	
	
	// div + klasse toevoegen voor slider
	$('#gallery > ul').wrap("<div class='gallery' id='scroller'></div>");
	
	
});
