/*
  ethecon
  Copyright (C) 2009 by Systemantics, Bureau for Informatics

  Lutz Issler
  Mauerstr. 10-12
  52064 Aachen
  GERMANY

  Web:    www.systemantics.net
  Email:  mail@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() {
	$("#search input[type=text]").focus(function() {
		if ($(this).hasClass("default")) {
			$(this)
				.removeClass("default")
				.data("defaultValue", $(this).val())
				.val("");
		}
	});
	$("#search input[type=text]").blur(function() {
		var defaultValue = $(this).data("defaultValue");
		if ($(this).val()=="" && defaultValue) {
			$(this)
				.addClass("default")
				.val(defaultValue);
		}
	});
	$("img[title]")
		.each(function() {
			var title = $(this).attr("title");
			var offset = $(this).offset();
			var w = $(this).width();
			var h = $(this).height();
			$(this)
				.attr("title", "")
				.hover(
					function() {
						$('<div id="lupe">'+title+'</div>')
							.css("left", offset.left-200+w)
							.css("top", offset.top+h+5)
							.appendTo("body");
					},
					function() {
						$("#lupe").remove();
					}
				);
		});
	$("#imagelist div:even").css("clear", "left");
	$(".youtube").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
				'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	$("#support").tabs({
		selected: $("#support div").index($(".show"))
	});
	$("a").click(function() {
		this.blur();
	});
	$("#tellafriend form").validate({showErrors: function(errorMap, errorList) {
		$("#tellafriend label").removeClass("missing");
		for (var i=0; i<errorList.length; i++) {
			$('label[for="'+errorList[i].element.id+'"]').addClass("missing");
		}
	}});
	$("a[href=#tellafriend]").fancybox();
	$("a[href=#]").click(function() {
		$("body").animate({scrollTop:0}, "slow");
		return false;
	});
});
