// Thickbox
$.fn.thickbox = function() {
	return this.each(function() {

		$("p.gallery a").attr("class","thickbox").attr("rel","gal");

	});
};

// Newsletter
$.fn.newsletter = function() {
	return this.each(function() {

		var emailLabel = $("input#email").prev("label");
		var emailInput = document.getElementById("email");
		var emailValue = emailLabel.text();
		$("body#startseite form").addClass("script");
		emailLabel.remove();
		if (emailInput) {
			emailInput.value = emailValue;
			emailInput.onfocus = function() {
				if (this.value == emailValue) this.value = '';
			};
			emailInput.onblur = function() {
				if (this.value == "") this.value = emailValue;
			};
			emailInput.form.onsubmit = function() {
				emailInput.onfocus();
			};
		};

	});
};

// Form
$.fn.form = function() {
	return this.each(function() {

		// li:focus
		$("input").focus(
			function() { $(this).parent("li").addClass("focus"); }
		);
		$("input").blur(
			function() { $(this).parent("li").removeClass("focus"); }
		);
		$("textarea").focus(
			function() { $(this).parent("li").addClass("focus"); }
		);
		$("textarea").blur(
			function() { $(this).parent("li").removeClass("focus"); }
		);

	});
};

$(document).ready(function() {
	$("p.gallery").thickbox();
	$("body#startseite form").newsletter();
	$("form").form();

	if($.browser.msie && $.browser.version <= 6) {
		$("body#startseite #content .wrapper p.image + p.image").css('margin-top', '0');
	}
});