﻿var duration = 500;
var maxDocumentHeight = 670;

function showConfirmationMessage(elementId) {
	$("#" + elementId).fadeTo(0, 0).css({"display": "block"}).fadeTo(500, 1, function() {
		setTimeout(function() {
			$("#" + elementId).fadeTo(500, 0);
		}, 3000);
	});
}

$(document).ready(function() {
	var ventjes = "/style/images/ventjes.gif";
	var ventjes_highlight = "/style/images/ventjes_highlight.gif";
	jQuery.preLoadImages(ventjes, ventjes_highlight);
	$("div#center div#ventjes a").mouseover(function(e) {
		$(this).css("background-image", "url(" + ventjes_highlight + ")");
	}).mouseout(function() {
		$(this).css("background-image", "url(" + ventjes + ")");
	});
	var paddingBottom = $(document).height() - maxDocumentHeight;
	if (paddingBottom > 0) {
		$("body").css({"paddingBottom": paddingBottom});
		$("div#center div#footer").css({"bottom": paddingBottom});
	}
});

(function($) {
	var cache = [];
	$.preLoadImages = function() {
		var args_len = arguments.length;
		for (var i = args_len; i--;) {
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
	}
})(jQuery)

function getContent(url, buttonId, hiddenFieldId) {
	var btn_getContent = $("#" + buttonId);
	var s = btn_getContent.attr("href");
	$("#" + hiddenFieldId).val(url);
	s = s.substr("javascript:".length, s.length);
	$("div#center div#content").fadeTo(0, 0, function() {
		eval(s);
		var height = - 326;
		if ($(document).height() > maxDocumentHeight) {
			height += maxDocumentHeight;
		} else {
			height += $(document).height();
		}
		$(this).css({"display": "block", "height": height}).fadeTo(duration, 1);
	});
}

function collapseLogo () {
	$("div#center div#header img").animate({"height": 66, "width": 300, "paddingLeft": 500}, duration, function() {
		$("div#center div#header img").attr("src", "/style/images/logo_small.gif").bind("click", expandLogo);
	});
	$("div#center div#header").animate({"height": 66}, duration);
	$("body").animate({"paddingTop": 66}, duration);
	var ventjes = $("div#center div#ventjes");
	var bottom = $(document).height() - ventjes.position().top - ventjes.height();
	var newBottom = 20;
	if ($(document).height() > maxDocumentHeight) {
		newBottom += $(document).height() - maxDocumentHeight;
	}
	ventjes.css({"position": "absolute", "bottom": bottom}).animate({"bottom": newBottom}, duration);
}

function expandLogo() {
	$("div#center div#header img").animate({"height": 175, "width": 800, "paddingLeft": 0}, duration, function() {
		$("div#center div#header img").attr("src", "/style/images/logo.gif");
	});
	$("div#center div#header").animate({"height": 175}, duration);
	$("body").animate({"paddingTop": 175}, duration);
	var ventjes = $("div#center div#ventjes");
	var bottom = $(document).height() - 175 - ventjes.height();
	ventjes.animate({"bottom": bottom}, duration);
	$("div#center div#content").fadeTo(duration, 0);
}
