/*
  STORCHENGRUSS
  Copyright (C) 2011 by Systemantics, Bureau for Informatics

  Systemantics GmbH
  Am Lavenstein 3
  52064 Aachen
  GERMANY

  Web:    www.systemantics.net
  Email:  hello@systemantics.net

  Permission granted to use the files associated with this
  website only on your webserver.

  Changes to these files are PROHIBITED due to license restrictions.
*/



$(function() {
	$(window).resize(function () {
		$("#overlay")
			.width(Math.max($(this).width(), $(document).width()))
			.height(Math.max($(this).height(), $(document).height()));
	}).resize();

	$("#images img:not(:first)").hide();
	$("#images-control span").click(function () {
		$("#images img")
			.hide()
			.eq(parseInt($(this).attr("id").substr(15))).show();
		$(this).addClass("selected").siblings().removeClass("selected");
	}).eq(0).addClass("selected");

	$(".input_date").each(function () {
		// Initialize
		var field = $(this).find("input[type='hidden']");
		var selects = $(this).find("select");
		var values = field.val().split("-");
		if (values.length==3) {
			for (var i=2; i>=0; i--) {
				selects.eq(2-i).val(values[i]);
			}
		}

		// Make functional
		selects.change(function () {
			if ($(this).val()==0) {
				selects.val(0);
			}
			if (selects.eq(2).val()==0 || selects.eq(1).val()==0 || selects.eq(0).val()==0) {
				// Set all to zero
				field.val("");
			} else {
				field.val(selects.eq(2).val()+"-"+selects.eq(1).val()+"-"+selects.eq(0).val());
			}
		}).eq(0).change();
	});

	$("a[href^='http://']").click(function (e) {
		this.blur();
		window.open(this.href);
		e.preventDefault();
	});
});

