 $(document).ready(function(){
  jQuery.Xpander = {

	build : function(o) {

	// Variabelen
        var s = {
		height: 	'auto',		// valid css height declaration
		width:  	'100%',		// valid css width declaration
		fx:		false,		// false, slow, fast, etc...
		style:  	false,		// class name
		overflow: 	'hidden',	// auto, scroll, hidden, visable
		show:		'Lees verder..',		// Link Content (Image, Text, etc)
		hide:		'Verberg',		// Link Content (image, Text, etc)
		display: 	'none',		// block, none (initial state)
		element:	'div'		// Element Block Type (div/iframe)
        };
	// Update standaart settings
        if(o) $.extend(s, o);

	// Loop voor elke item
  	return this.each(function(){

		// Link nalopen of hij valid is
		if($(this).attr('href').length < 2) return false;

		// Controle elementen
		if(s.element != 'iframe') s.element = 'div';

		// Maakt content blok
		var ptr = document.createElement(s.element);
		ptr.style.height = s.height;
		ptr.style.width = s.width;
		ptr.style.display = s.display
		$(this).after(ptr);

		// Update link naam
		if(s.display=='none') 
			$(this).html(s.show) 
		else 
			$(this).html(s.hide);

		// Laad content erin	
		if(s.element == 'iframe')
			$(this).next(s.element).attr('src',$(this).attr('href'));
		else
			$(this).next(s.element).load($(this).attr('href'));

		// Geef class
		if(s.style)
			$(this).next(s.element).addClass(s.style); 

		// Verfijn toggle
		$(this).click(function() {
			if($(this).next(s.element).css('display') == 'none')
			{
				if(s.fx)
					{ $(this).next(s.element).animate({ height: 'show', opacity:'show' }, s.fx); } 
				else 
					{ $(this).next(s.element).show().overflow(s.overflow); }
				$(this).html(s.hide);
			}
			else
			{	
				if(s.fx)
					{ $(this).next(s.element).animate({ height: 'hide', opacity:'hide' }, s.fx); } 
				else 
					{ $(this).next(s.element).hide().overflow('hidden'); }
                                $(this).html(s.show);
			}	
  			this.blur();
  			
  			return false;
		});
  	});
	}
};

jQuery.fn.Xpander = jQuery.Xpander.build;

	// Snelheid uitklapper]
	$(function(){

		$('a.xpand').Xpander({
			fx: 1			});
	});

 });


