﻿$(document).ready(function() {
	//ifixpng
	$('img[src$=".png"]').ifixpng();

	//jdmenu
	if (typeof jQuery.fn.jdMenu == 'function') {
		$('ul.sitemenu').jdMenu({
			disableLinks: false,
			showDelay: 0,
			hideDelay: 500
		});

		$('ul.sitemenu a').hover(
			function () {
				$(this).data('title', $(this).attr("title") );
				$(this).removeAttr("title");
			},
			function () {
				$(this).attr("title", $(this).data('title') );
				$(this).removeData("title");
			}
		);
	}

	//button click
	$(".button_middle").click(function()
	{
		if( $(this).has("a").length )
		{
			location.href = $("a", this).attr("href");
		}
		else if( $(this).parents("form").length )
		{
			$(this).parents("form").submit();
		}
		else
		{
			//nothing
		}
	});

	//toggleval
	$("input.toggleInput").toggleVal({
		populateFrom:	"label",
		removeLabels:	true,
		focusClass:		"hasFocus",
		changedClass:	"isChanged"
	});

	//quick search
	$("form#searchContent").submit(function(){
		$(this).find(".toggleInput").each(function() {
			if($(this).val() == $(this).data("defText")) {
				$(this).val("");
			}
		});
	});

	//spacegallery
	if( $('#portfolioGallery').length )
	{
		$('#portfolioGallery').spacegallery({
			perspective: 37,
			before: function(){
				var title = $("#portfolioGallery img:last").prev().attr("alt");
				$("#ambiance_left_link").html( 'Bekijk: ' + title );
			}
		});

		$("div#ambiance_left_link").click(function(){
			location.href=$("#portfolioGallery img:last").attr("longdesc");
		});

		var titleStart = $("#portfolioGallery img:last").attr("alt");
		$("#ambiance_left_link").html( 'Bekijk: ' + titleStart );
	}
});