// JavaScript Document
// Copyright (c) by Felix Rupp. All rights reserved.
// No copy, reproduction or use without written permission of Felix Rupp.
// For contact see: http://www.felixrupp.com/


function resetColors() {	
	$(":input").removeClass("error");
}


$(document).ready(function(){
	
	// Accordion Effekte
	$(".standardAccordion").accordion({clearStyle: true, collapsible: true, autoHeight: false, active: false, header: 'h3'});
	$("#medientechnik").accordion({clearStyle: true, collapsible: true, autoHeight: false, active: false, header: 'h4'});
	
	
	$("a.lightbox").lightBox();
	
	
	// Textgroessen
	$("#smallFontSize").click(function(event){
		event.preventDefault();
		$(document.body).css({'font-size':0.9+'em'});
	});
	
	$("#normalFontSize").click(function(event){
		event.preventDefault();
		$(document.body).css({'font-size':1+'em'});
	});
	
	$("#bigFontSize").click(function(event){
		event.preventDefault();
		$(document.body).css({'font-size':1.1+'em'});
	});
	
	
	
	/* Kontaktformular */
		$('#kontaktFormular').submit(function(){
			action = $(this).attr('action');
			
			$('#submitKontakt').attr('disabled','disabled');
	
			$("input,textarea").removeClass("error");
	
			$.post(action,$("#kontaktFormular").serialize(),function(data){
				if(data=='Ihre Nachricht wurde erfolgreich versendet. Vielen Dank.') {
					$('#kontaktFormular').slideUp(600,function(){
						$(".success").fadeIn(600)
					});
				} else if(data=='Bitte Absender eintragen.') {
					$('input[name=absenderName]').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200).tooltip().show();
				} else if(data=='Bitte g&uuml;ltige E-Mail-Adresse eintragen.') {
					$('input[name=absenderEmail]').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200).tooltip().show();
				} else if(data=='Bitte eine mindestens 10 Zeichen lange Nachricht eingeben.') {
					$('textarea[name=absenderNachricht]').animate({opacity:"0"},200).addClass("error").animate({opacity:"1"},200).animate({opacity:"0"},200).animate({opacity:"1"},200).tooltip().show();
				} else if(data=='Fehler: Nachricht wurde nicht gesendet.') {
					$(".errorMessage").fadeIn(600)
				}
				
				$('#submitKontakt').attr('disabled','');
			});
	
		    return false;
		
		});	
		
		
		// Tooltip fürs Kontaktformular
		$("#kontaktFormular :input[type=text], :input[type=textarea], :input[type=checkbox]").tooltip({position: "center right", offset: [0, 45], effect: "slide", direction: "left", slideInSpeed: 350, slideOutSpeed: 300});	
		
	
});
