$(document).ready(function() {
													 
	$('a[rel=external]').attr('target', '_blank');

	/* Adds class="active" to current page */
	
	$("#wrapper #header .float-right ul li a").each(function() {
		if(this.href == window.location) $(this).addClass("active");
	});

	/* Fancybox Homepage Video */ 
 
	$("a.home_modal").fancybox({
		'hideOnContentClick': false,
		'overlayShow': true,
		'overlayOpacity': '0.8',
		'frameWidth': 700,
		'centerOnScroll': false,
		'frameHeight': 425
	});
	
	$("a.modal_newsletter").fancybox({
		'hideOnContentClick': false,
		'overlayShow': true,
		'overlayOpacity': '0.8',
		'frameWidth': 420,
		'centerOnScroll': false,
		'frameHeight': 475
	});

	/* Fancybox other modals */
 
	$("a.fancybox").fancybox({ 
		'zoomSpeedIn': 600,
		'zoomSpeedOut': 500,
		'overlayShow': true,
		'overlayOpacity': '0.4',
		'easingIn': 'easeOutBack',
		'easingOut': 'easeInBack'
	}); 

	/* Post images opacity */

	$("#wrapper .post-body a img").css({ "opacity":"0.8" });


	$("#wrapper .post-body a img").hover(function(){
		$(this).animate({"opacity": "1"}, 150);
	},
	function(){
		$(this).animate({"opacity": "0.8"}, 150);
	});

	/* Footer widgets paddings */

	$(".footer-widgets .box:first").css({paddingLeft: '0'});
	
	$('#refLoading').hide();
	
	$('#refnr').blur(function(){
		if($('#refnr').val() !=""){
		$('#refLoading').show();
			$.post("/bestellen/parse-referenties.php", {
				referentie: $('#refnr').val()
			}, function(response){
				$('#refResult').fadeOut();
				setTimeout("finishAjax('refResult', '"+escape(response)+"')", 2000);
			});
			return false;
		}
	});

	jQuery(window).load(function() {
		$.post("/bestellen/parse-orders.php",
			function(response){
				setTimeout("finishAjaxOrders('idResult', '"+escape(response)+"')", 1);
			});
	});

});

	function finishAjax(id, response) {
		$('#refLoading').hide();
		$('#'+id).html(unescape(response));
		$('#'+id).fadeIn();
	} //finishAjax
	
	function finishAjaxOrders(id, response) {
		$('#idLoading').hide();
		$('#'+id).html(unescape(response));
	}

	/* Tooltip */

	$(function() {
		$(".tooltip").tooltip({
			track: true,
			delay: 0,
			showURL: false,
			showBody: " - ",
			fade: 250
			});
		});