var activeCustomer = 1;


$(document).ready(function() {

    $(".navItem").hover(function() {
        $(this).addClass("navHover");
    },
    function() {
        $(this).removeClass("navHover");  
    });




	//kundenHandling
	var lastCustomer = $("#firstCustomer");
	var lastCustomerNumb = 1;
	lastCustomer.animate({
		color: 'red',
	}, 120);
	$("#k1").fadeIn(200);
	$(".kundenLink").children().click(function() {
		lastCustomer.animate({
			color: '#ccc',
		}, 120)
		$("#k"+lastCustomerNumb).fadeOut(200);
		activeCustomer = $(this).attr('href').replace('#', '');
		$("#k"+activeCustomer).delay(250).fadeIn(200);
		$(this).parent().animate({
			color: 'red'
		}, 120);
		lastCustomer = $(this).parent();
		lastCustomerNumb = activeCustomer;
		
	})
	
	
	$(".clientLink").hover(function() {
		$(this).children(".clientHref").animate({
			color: '#333'
		}, 50);
		$(this).children(".linkIcon").animate({
			opacity: 1
		}, 50);
	
	},
	function() {
		$(this).children(".clientHref").animate({
			color: '#999'
		}, 50);
		$(this).children(".linkIcon").animate({
			opacity: 0.5
		}, 50);
	});





    //CONTACT FORM THINGS
    var savedText = '';
		
    $(".inputValue")
    .focus(function() {
        if ($(this)[0].value == $(this)[0].defaultValue) {
            savedText = $(this)[0].value;
            $(this)[0].value = "";
            $(this).css({
                color: '#333',
                backgroundColor: '#fff'
            })
        }
    })
    .blur(function() {
        if ($(this)[0].value == '') {
            $(this)[0].value = $(this)[0].defaultValue;
            $(this).css({
                color: '#aaa'
            })
        }
    });
});
var formIsValid = false;

$(function() {
    $('#contact').validate({
        submitHandler: function(form) {
			formIsValid = true;
			if( $("[name=name]")[0].value == $("[name=name]")[0].defaultValue ) {
				$("[name=name]").animate({
					color: '#c10a0a'
				}, 120);
				formIsValid = false;
			} 
			if( $("[name=email]")[0].value == $("[name=email]")[0].defaultValue ) {
				$("[name=email]").animate({
					color: '#c10a0a'
				}, 120);
				formIsValid = false;
			}
			if( $("[name=phone]")[0].value == $("[name=phone]")[0].defaultValue ) {
				$("[name=phone]").animate({
					color: '#c10a0a'
				}, 120);
				formIsValid = false;
			}
			if( $("[name=message]")[0].value == $("[name=message]")[0].defaultValue ) {
				$("[name=message]").animate({
					color: '#c10a0a'
				}, 120);
				formIsValid = false;
			}
			if(formIsValid) {
	            $(form).ajaxSubmit({
	                url: 'process.php',
	                success: function() {
						$("#contactSubHead").prev().delay(100).fadeOut(200);
						$("#contactSubHead2").delay(300).fadeIn(200).delay(2500).fadeOut(200);
						$("#contactSubHead").delay(3200).fadeIn(200);
                    
						$("#contactHead").prev().delay(3000).fadeOut(200);	
						$("#contactHead").delay(3200).fadeIn(200);
				
                    
	                }
	            });
			}
        }
    });
});
