$(document).ready(function() {
		
	$('#video').cycle ({
		timeout: 0,
        fx:          'fade',	
		fastOnEvent: 100,
		sync:          1,
	    fit:           1,
		pager: '#video-nav', 
		pagerEvent: 'click.cycle' 
	});
     
    var url1 = $('.videothumbsrc:eq(0)').text();
	var url1final = 'url(' + url1 + ') 0 0 no-repeat';
	var url2 = $('.videothumbsrc:eq(1)').text();
	var url2final = 'url(' + url2 + ') 0 0 no-repeat';
	var url3 = $('.videothumbsrc:eq(2)').text();
	var url3final = 'url(' + url3 + ') 0 0 no-repeat';
	
    $('#video-nav a:eq(0)').css('background', url1final);
	$('#video-nav a:eq(1)').css('background', url2final);
	$('#video-nav a:eq(2)').css('background', url3final);
	 
	$('#video-nav a').each(function() {
		$(this).empty();
		$(this).append('<img class="play" src="/wp-content/themes/default/images/icons/play.png" style="padding:15px 0 0 32px;"></img>');
	});
	
	$('#foto > img').attr('height','268');
	$('#foto > img').attr('width','319');

	if ($('body').hasClass('page-id-85')) {
		$('#main-right').append('<div id="album-nav"></div>');
		$('#album-nav').wrap('<div id="album-nav-chell">','</div>');
		$('#main-right-inner').cycle ({
		timeout: 0,
        fx:          'fade',	
		fastOnEvent: 100,
		sync:          1,
	    fit:           1,
		pager: '#album-nav', 
		pagerEvent: 'click.cycle' 
	});
	}

	/*content images*/
		
    $("#content p:has(img)").each(function () {
   	$w = $(this).find('img').width();
   	$h = $(this).find('img').height();
	$(this).css('display','block').css('height', $h).css('width', $w);
   });
   
   $('#content img.alignleft').each(function () {
   		$(this).attr('class','');
   		$(this).parent().attr('class','alignleft');
   });
   
   $('#content img.alignright').each(function () {
   		$(this).attr('class','');
   		$(this).parent().attr('class','alignright');
   });
 
   $(function(){
   if ($(".alignleft").width() <= 140) {
 	   $(".alignleft").css('float','left').css('margin','0 35px 18px 0');
 	}
 	else {
 		$(".alignleft").css('float','none');
 	}
 	});
 	
	
 	/*e.o. content images*/
	
	$('#main-right').each(function () {
		$h = $(this).height();
		$('#main').css('min-height', $h);
		$('#container').css('min-height', $h);
	});


	
	/*
	$('.ngg-widget a:first-child').each(function() { 	
		$('#album-viewer img').remove();
		$('.fotobeschrijving').remove();
		$('.imgtitle').remove();
		var src = $(this).attr('href');
		var desc = $(this).attr('title');
		var imgtitle = $(this).find('img').attr('title');
		$('#album-viewer').append('<img src='+ src +' width="560" height="373"></img>').before('<h3 class="imgtitle">'+ imgtitle +'</h3>').after('<p class="fotobeschrijving">'+ desc +'</p>');
	});*/
	
	/*
	$('.ngg-widget a').each(function() {  
		var src = $(this).attr('href'); 
		var imgtitle = $(this).find('img').attr('title');
		$(this).attr('alt', src);
		var altsrc = $(this).attr('alt');
		$(this).removeAttr('href');
		var desc = $(this).attr('title');
		
			$(this).click(function() {
			
			$('#album-viewer img').remove();
			$('.fotobeschrijving').remove();
			$('.imgtitle').remove();
			$('#album-viewer').append('<img src='+ altsrc +' width="560" height="373"></img>').before('<h3 class="imgtitle">'+ imgtitle +'</h3>').after('<p class="fotobeschrijving">'+ desc +'</p>');
	
	  });
	});
	*/
	
	//$('.ngg-gallery-thumbnail a').removeAttr('href');
	
	$('.ngg-gallery-thumbnail a').each(function() {  
		var src = $(this).attr('href'); 
		var imgtitle = $(this).find('img').attr('title');
		$(this).attr('alt', src);
		var altsrc = $(this).attr('alt');
		$(this).removeAttr('href');
		var desc = $(this).attr('title');
						
			$(this).click(function() {
			var content = $('.entry').html();
			$('.entry *').remove();
			$('.entry').append('<h1>Foto-Album</h1><h3 class="imgtitle">'+ imgtitle +'<a href="javascript:window.location.reload();" class="fotoback" style="float:right;"> Terug&raquo</a></h3><div id="album-viewer"><img src='+ altsrc +' width="560" height="373"></img></div><p class="fotobeschrijving">'+ desc +'</p>');
	   
	  });
	});	 
	
	if ($('#videocycler').length != '0' && $('#fotoalbum').length != '0') { 
	var firstdiv = $('#videocycler').height();
	var secdiv = $('#fotoalbum').height();
	var addedh = firstdiv + secdiv;
	var addedhh = addedh - 38;
	$('.entry').css('min-height', addedhh);
	}
	   
	/** adjustments **/
	
	$('ul.lcp_catlist > br').remove();
	$('ul.lcp_catlist a').wrap("<li></li>").attr('target','_blank');
	$('.video-option > br').remove();
	$('.video-nav > br, .video-nav > p').remove();
	
});
