$(document).ready(function() {

// ========== 
// ! SLIDER   
// ========== 

	jQuery(function( $ ){
		$.localScroll.hash({
			target: '#wrapper',
			queue:true,
			duration:1500
		});
		
		$.localScroll({
			target: '#wrapper',
			axis: 'xy',
			queue:true,
			duration:1500,
			hash:true
		});
	});


// ==================================== 
// ! CONTACTFORM REMOVE STANDARD TEXT   
// ==================================== 

		$('input[type="text"]').addClass("idleField");
   		$('input[type="text"]').focus(function() {
   			$(this).removeClass("idleField").addClass("focusField");
		    if (this.value == this.defaultValue){ 
		    	this.value = '';
			}
			if(this.value != this.defaultValue){
    			this.select();
    		}
		});
		$('input[type="text"]').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		    if ($.trim(this.value) == ''){
		    	this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});


		$('textarea').addClass("idleField");
   		$('textarea').focus(function() {
   			$(this).removeClass("idleField").addClass("focusField");
		    if (this.value == this.defaultValue){ 
		    	this.value = '';
			}
			if(this.value != this.defaultValue){
    			this.select();
    		}
		});
		$('textarea').blur(function() {
			$(this).removeClass("focusField").addClass("idleField");
		    if ($.trim(this.value) == ''){
		    	this.value = (this.defaultValue ? this.defaultValue : '');
			}
		});


// ================================ 
// ! CONTACT FORM VALIDATE & SEND  
// ================================ 

		$(".contactform").validate({
			//set the rules for the fild names
			rules: {
				contactmessage: {
					required: true,
					minlength: 10
				},
				contactname: {
					required: true,
					minlength: 5
				},
				contactemail: {
					required: true,
					email: true
				},
			},
			//set messages to appear inline
			messages: {
				contactmessage: "",
				contactname: "",
				contactemail: ""
			},
			submitHandler: function() {
				$.post('contact-form.php', { 
					contactmessage: $('#contactmessage').val(), 
					contactname: $('#contactname').val(), 
					contactemail: $('#contactemail').val(), 
				},
				function(data) {
					if (data == 'true') {
						$('#hidden-thankyou').click();
							$('#contactmessage').val("Nachricht"); 
							$('#contactname').val("Name"); 
							$('#contactemail').val("Email");
					}
				});
			}
		});
	
	
// ============ 
// ! FANCYBOX   
// ============ 
		
		$("a.single_image").fancybox({
			'overlayColor'		:	'#e1e1e1',
			'overlayOpacity'		:	0.96,
			'showCloseButton'		:	false,
			'nameShow'			:	true,
			'titlePosition'		: 	'inside',
			'hideOnContentClick'	:	true,
			'showCloseButton'		:	true,
			'showNavArrows'		:	true
		});
					
});
