$(document).ready(function(){

	$('.form_tp').val("dm");


	$('.pictures img').css("cursor","pointer").click(function () { 
		var url=$(this).attr('src');
		
		url=url.replace(/small/, "large");

		$.ImagePopup.show(url);
	});

	$('.arrangementen .item .more').html("Lees meer..");


	$('.arrangementen .item').css("cursor","pointer");
	$('.arrangementen .item').click(function() {

		if ($("#"+$(this).attr("id")+" .more").size()>0) {
			$("#"+$(this).attr("id")+" .more").html(" ");
			$("#"+$(this).attr("id")+" .more").attr("className","less");
		}
		else {
			$("#"+$(this).attr("id")+" .less").html("Lees meer..");
			$("#"+$(this).attr("id")+" .less").attr("className","more");
		}		


		if ($(this).children(".content").html()!="") {
			$(this).children(".content").toggle("slow");
		}
		else {
			var id=$(this).attr("id");
			 $.ajax({
   				type: "POST",
   				url: "/arrangementen/convert.php?file="+id,
   				success: function(msg){	


					$("#"+id+" .content").html(msg);
					$("#"+id+" .content").toggle("slow");
		   		}
		 	});
		}

					

	});
	
}); 


  /*****************************************************************************
   *
   * IMage popup
   *  
   ****************************************************************************/
  $.ImagePopup= {
	
    show: function(img) {
	sifr_hide();

	// Hide objects that are always on top
  	$("object").css("visibility","hidden");
  	$("embed").css("visibility","hidden");
      	$("select").css("visibility","hidden");

	
	// Create background
	var background = $('<div/>');
	$(background).attr('class', 'ImagePopupBackground');
	$(background).css("opacity","0");
	$(background).animate({'opacity' : '.7'}, 300);


	var height=$(document).height();
	if (height<$(window).height()) {
		var height=$(window).height();	
	}

	$(background).css(
		{
		'width' : $(document).width(),
		'height' : height

		});

	$('body').append(background);

	// Create image 

	var newImage = $('<img/>');
	var width = $('body').width();
	$(newImage).attr('src',img);
	$(newImage).attr('class', 'ImagePopupImg').css(
		{
	
		});
	


	$('body').append(newImage);
	

	// Wait for image to load
 
	$(newImage).css('visibility','hidden');
	$(newImage).load(function () {
		
		$(newImage).css('visibility','visible');
		var top=$(newImage).vCenter();

		
		
 		$(this).css("left",$(document).width()/2-$(this).width()/2);

		$(this).css({'opacity' : '.1'});
		$(this).animate({'opacity' : '1'}, 300, function() {

			$(this).bind('click', function() {

 				sifr_show();


				$(this).fadeOut(400, function() {
					$(this).remove();
					$("object").css("visibility","visible");
		  			$("embed").css("visibility","visible");
		      			$("select").css("visibility","visible");

				});
				$('.ImagePopupBackground').fadeOut(400, function() {
					$(this).remove();
				});
			});
		});
	});
    }

  }



    




  
