
$('#slideshow').cycle({
	speed: 4000,
	easing: 'easeOutBounce',
	timeout: 10,
        fx: 'scrollDown,scrollUp,fade'
});
$('#portfolio-content').cycle({
	speed: 4500,
	delay:  -8000,
	easing: 'easeOutBack',
	pager:'#portfolio-text',
        fx: 'scrollHorz',
	timeout: 0,
	pagerEvent: 'mouseover',
    pagerAnchorBuilder: function(idx, slide) { 
        return '#portfolio-text a:eq(' + idx + ')'; 
    }
});
var bgrueber = function() {
		$(this).css('backgroundColor','#ff0000');
		$(this).children().css('borderColor','#fff');
	}
var bgrunter = function() {
		$(this).css('backgroundColor','#EFFDFF');
		$(this).children().css('borderColor','#00ccff');
	}
var rueber = function() {
	$(this).animate({backgroundPosition:'0 -29px'},0);
	}
var runter = function() {
	$(this).animate({backgroundPosition:'0 0'}, 0);
	}
var theoasisrueber = function() {
		$('#portfolio-slider').stop(true, true);
		$('#portfolio-slider').animate({left:'167px'},200);
	}
var adassjisroelrueber = function() {
		$('#portfolio-slider').stop(true, true);
		$('#portfolio-slider').animate({left:'3px'},200);
	}
var meltfestivalrueber = function() {
		$('#portfolio-slider').stop(true, true);
		$('#portfolio-slider').animate({left:'331px'},200);
	}
var zurgluehlamperueber = function() {
		$('#portfolio-slider').stop(true, true);
		$('#portfolio-slider').animate({left:'495px'},200);
	}
var berlinfilesrueber = function() {
		$('#portfolio-slider').stop(true, true);
		$('#portfolio-slider').animate({left:'659px'},200);
	}

function validateForm()
		{
			$("#name_error").empty().hide();
			$("#mail_error").empty().hide();
			$("#nachricht_error").empty().hide();
			var name = $("#name").val();
			var mail = $("#mail").val();
			var nachricht = $("#nachricht").val();

			var errors = 0;
			
			if (name == null || name == '')
			{
				$("#name").css("backgroundColor","#00ccff");
				$("#name_error").show().append("Bitte geben Sie ihren Namen ein!");
				errors++;
			}
			else if (name !== null || name !== '')
			{
				$("#name").css("backgroundColor","#fff");
			}
			if(isValidEmailAddress(mail)) {
				$("#mail").css("backgroundColor","#fff");
			} else {
				$("#mail").css("backgroundColor","#00ccff");
				$("#mail_error").show().append("Bitte geben Sie eine gültige E-Mailadresse ein!");
				errors++;
			}			
			if (nachricht == null || nachricht == '')
			{
				$("#nachricht").css("backgroundColor","#00ccff");
				$("#nachricht_error").show().append("Bitte geben Sie eine Nachricht ein!");
				errors++;
			}
			else if (nachricht !== null || nachricht !== '')
			{
				$("#nachricht").css("backgroundColor","#fff");
			}
			if (name !== "" & mail !== "" & nachricht !== "") {
			var dataString = 'name=' + name + '&mail=' + mail + '&nachricht=' + nachricht;
$.ajax({

		type: "POST", 
		url: "mail.php",  
		data: dataString,
		success:
		function(data) {
		$('#ausgabe').fadeIn('slow');
		}
		});
}
			function isValidEmailAddress(emailAddress) {
			var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

			return pattern.test(emailAddress);
			}
return false;
};

function navirueber() {
	$(this).animate({width:'230px'},100);
	}
function navirunter() {
	$(this).animate({width:'0px'},200);
	}
$(document).ready(function() {
		$( '#scrollnavi' ).scrollFollow( {
		speed: 1000,
		offset: 60
		}).hover(navirueber, navirunter).click(function() {
			$(this).animate({width:'0px'},200);
		});
		$('#kontaktformular p').hover(bgrueber, bgrunter);
		$('.submit').click(validateForm);
		$('#portfolio-slide a').click(function(){return false;})
		$('#navigation, .content-footer, #scrollnavi, #slideshow').localScroll();
		$('#container').fadeIn(0);
		$('a#to-slider').hover(theoasisrueber);
		$('a#aj-slider').hover(adassjisroelrueber);
		$('a#mf-slider').hover(meltfestivalrueber);
		$('a#zg-slider').hover(zurgluehlamperueber);
		$('a#bf-slider').hover(berlinfilesrueber);
		$('#navigation li a').each(function () {
		$(this).hover(rueber, runter);
		});
		$.preloadCssImages();
});
