	$(document).ready(function() {
		$.fn.betterTooltip = function(options){
			/* Setup the options for the tooltip that can be 
			   accessed from outside the plugin              */
			var defaults = {
				speed: 100,
				delay: 0
			};
			
			var options = $.extend(defaults, options);
			
			/* Create a function that builds the tooltip 
			   markup. Then, prepend the tooltip to the body */
			getTip = function() {
				var tTip = 
					"<div class='tip'>" +
						"<div class='tipMid'>"	+
						"</div>" +
						"<div class='tipBtm'></div>" +
					"</div>";
					
				return tTip;
			}
			$("body").prepend(getTip());
			
			/* Give each item with the class associated with 
			   the plugin the ability to call the tooltip    */
			$(this).each(function(){
				
				var $this = $(this);
				var tip = $('.tip');
				var tipInner = $('.tip .tipMid');
				
				var tTitle = (this.title);
				this.title = "";
				
				var offset = $(this).offset();
				var tLeft = offset.left;
				var tTop = offset.top;
				var tWidth = $this.width();
				var tHeight = $this.height();
				
				/* Mouse over and out functions*/
				$this.hover(
					function() {
						tipInner.html(tTitle);
						setTip(tTop, tLeft);
						setTimer();
					}, 
					function() {
						stopTimer();
						tip.hide();
					}
				);		   
				
				/* Delay the fade-in animation of the tooltip */
				setTimer = function() {
					$this.showTipTimer = setInterval("showTip()", defaults.delay);
				}
				
				stopTimer = function() {
					clearInterval($this.showTipTimer);
				}
				
				/* Position the tooltip relative to the class 
				   associated with the tooltip                */
				setTip = function(top, left){
					var topOffset = tip.height();
					var xTip = (left-10)+"px";
					var yTip = (top-topOffset-17)+"px";
					tip.css({'top' : yTip, 'left' : xTip});
				}
				
				/* This function stops the timer and creates the
				   fade-in animation                          */
				showTip = function(){
					stopTimer();
					tip.animate({"top": "+=20px", "opacity": "toggle"}, defaults.speed);
				}
			});
		};
		//Tooltip
		$('.tTip').betterTooltip({speed: 150, delay: 30});
		//show hide contact
		 $("#cform #header_form").click(function () { 
			if($('#cform #contactf').is(":hidden")) {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #contactf').show("slow");
			} else {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_right.jpg)'); 
				$('#cform #contactf').slideUp();
			}
		});
		
		//uitklappen als ...(contact)
		if ($('#cform #contactf .errorMessages').length) {
			if ($('#cform #contactf .errorMessages').text() != '') {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #contactf').show();
			}
		}
		if ($('#cform #contactf p').length) {
			if ($('#cform #contactf p').text() != '') {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #contactf').show();
			}
		}
		//show hide contact
		 $("#cform #header_form2").click(function () { 
			if($('#cform #nieuwsf').is(":hidden")) {
				$("#cform #header_form2").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #nieuwsf').show("slow");
			} else {
				$("#cform #header_form2").css('background-image','url(assets/templates/pekago/images/arrow_orange_right.jpg)'); 
				$('#cform #nieuwsf').slideUp();
			}
		});
		//uitklappen als ... (nieuwsbrief)
		if ($('#cform #nieuwsf .errorMessages').length) {
			if ($('#cform #nieuwsf .errorMessages').text() != '') {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #nieuwsf').show();
			}
		}
		if ($('#cform #nieuwsf p').length) {
			if ($('#cform #nieuwsf p').text() != '') {
				$("#cform #header_form").css('background-image','url(assets/templates/pekago/images/arrow_orange_down.jpg)'); 
				$('#cform #nieuwsf').show();
			}
		}
		
		//legen invoerfeld van zoeken
		$('#search_txt').focus(function(){
			if(this.value!='') {
				this.value='';
			}
		});
		//lightbox
		/*
		$(function() {
			$('a[rel*=lightbox[0]]').lightBox({fixedNavigation:true}); // Select all links that contains lightbox in the attribute rel
		});
		*/
		//carrousel
		(function showCarrouselImage() { setTimeout(function() {
				var $active = $("#images IMG.active"); 			
				var $next = $active.next();    
				if ($active.is("#images IMG:last-child") ) {
					$next = $("#images IMG:first-child");
					$next.addClass('active');
				} else {
					$next.addClass('active');
				}
				$active.removeClass('active');
				showCarrouselImage();
			}, 4000);
		})();
	
		//Hover carrousel
		$("#carrousel_menu a").hover(function() {
			elmNumber = $(this).find('img').attr('alt');
			$("#images img").hide();
			var i = 1;
			$('#images').children().each(
				function(){
					if (i == elmNumber){
						$(this).show();
					}
					i++;
				}
			)	
		});
		var at = / at /;
		var dot = / dot /g;
		$('a.mailme').each(function () {
			var addr = $(this).text().replace(at,"@").replace(dot,".");
			var title = jQuery(this).attr('title');
			$(this).after('<a href="mailto:'+addr+'" title="'+title+'" rel="nofollow">'+ addr +'</a>');
			$(this).remove();
		});
	});
	function print() {
		$('#content #col2').jqprint({  operaSupport: true });
	}
