jQuery.fn.DefaultValue = function() {
	/* inspired by bit.ly/MHDtB */
	var elements = this;
	var args = arguments;
	var c = 0;
	return(
		elements.each(function() {				
			var el = jQuery(this);
			var def = args[c++];
			el.val(def).focus(function() {
				if(el.val() == def) {
					el.val("");
				}
				el.blur(function() {
					if(el.val() == "") {
						el.val(def);
					}
				});
			});
		})
	);
};

jQuery(document).ready(function(){
	jQuery('#contactform').submit(function(){
		action = jQuery(this).attr('action');
		
		jQuery('#submit').attr('disabled','disabled');

		jQuery("input,textarea").removeClass("error");

		jQuery.get(action,jQuery("#contactform").serialize(),function(data){
			if(data=='Ok') {
				jQuery('#contactform').slideUp(600,function(){
					jQuery(".success").fadeIn(600)
				});
			} else if(data=='Error_1') {
				jQuery('input#name').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200, function() {alert('Bitte überprüfe die Eingabe des Names! (Pflichtfeld)')});
			} else if(data=='Error_2') {
				jQuery('input#email').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200, function() {alert('Bitte überprüfe die Eingabe der E-Mail Adresse! (Pflichtfeld) Sie wird als Antwort Adresse verwendet und sollte gültig sein!')});
			} else if(data=='Error_3') {
				jQuery('textarea#text').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200, function() {alert('Bitte überprüfe die Eingabe der Nachricht; mindestens 10 Zeichen! (Pflichtfeld)')});
			}
			jQuery('#contactform #submit').attr('disabled','');
		});

	return false;
	});
	
	jQuery('#contactform #submit').attr('disabled','');
	jQuery("#name").DefaultValue("Name");
	jQuery("#email").DefaultValue("E-Mail Adresse");
	jQuery("#text").DefaultValue("Nachricht");

	var move = -15;
	var zoom = 1.2;
	jQuery('.item').hover(function() {
		width = jQuery('.item').width() * zoom;
		height = jQuery('.item').height() * zoom;
		jQuery(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		jQuery(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		jQuery(this).find('img').stop(false,true).animate({'width':jQuery('.item').width(), 'height':jQuery('.item').height(), 'top':'0', 'left':'0'}, {duration:100});	
		jQuery(this).find('div.caption').stop(false,true).fadeOut(200);
	});
	
	jQuery('.show').click().toggle(function() {
		jQuery('#rollout,.network, .partner ').animate({'height': '300px'}, 500);
	}, function() {
		jQuery('#rollout,.network, .partner ').animate({'height': '0px'}, 500);
	});


});