/**
 * @author arjen
 */

jQuery.log = function(message) {
  if(window.console) {
     console.debug(message);
  } else {
     alert(message);
  }
};

/**
 * Image Replace
 * Appends some spans to selection, so with css nice IR can happen)
 * @author AK|Peppered
 */

jQuery.fn.ImageReplace = function(options) {
	var defaults = {
		hover: false
	};
	options = $.extend(defaults, options);
	if (document.styleSheets[0].disabled) return false;
	if (this.length < 1) return false;
	
	if (this.get(0).nodeName.toLowerCase() == 'body') {
		// old style replace via classnames
		$('.ir, .ir-anchors a').append('<span class="ir-aid"></span>');	// single element IR & descendant anchors of an element
		$('.ir.ir-hover span.ir-aid, .ir-anchors.ir-anchors-hover a span.ir-aid').append('<span></span>');	// append another span when it has a hover state
		$('.ir, .ir-anchors').addClass('irActive');		
	}
	else {
		this.each(function() {
			//$.log(this);
			$(this).addClass('ir');		
			$(this).append('<span class="ir-aid"></span>');	
			if (options.hover == true) {
				$(this).children('span.ir-aid').addClass('ir-aid-hover');
				$(this).children('span.ir-aid').append('<span></span>');
			}
	
			$(this).addClass('irActive');
		});		
	}
}

$(function(){
	/**
	 * afrekenen 
	 * jquery 1.2.3
	 * @author: arjen
	 * 
	 */ 
	 
	// tegoedbonnen
	$('#tegoedbonnen #tegoedbonnenTekst').hide();
	$('#tegoedbonnen legend').wrapInner('<a class="button" href="#tegoedbonnenTekst"></a>');
	$('#tegoedbonnen legend a').click(function(){
		$('#tegoedbonnen #tegoedbonnenTekst').toggle();
	});
});
