
// Fading headers
$(document).ready(function() {
	$('.HeaderWrap').delay(400).fadeIn(800);
});

// Home Item Hover Effect
$(document).ready(function() {
	$("#Items li").hover(function() { //On hover...	
		var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
		//Set a background image(thumbOver) on the &lt;a&gt; tag 
		$(this).find("a.Thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
		//Fade the image to 0 
		$(this).find("span").stop().fadeTo('fast', 0 , function() {
			$(this).hide() //Hide the image after fade
		}); 
	} , function() { //on hover out...
		//Fade the image to 1 
		$(this).find("span").stop().fadeTo('fast', 1).show();
	});
});


// Main Javascript for jQuery Realistic Hover Effect
// Created by Adrian Pelletier - http://www.adrianpelletier.com
$(document).ready(function() {
	// Append shadow image to each LI
	$("#Activities li").append('<img class="Shadow" src="/wp-content/themes/Illusiv/images/bg-shadow.jpg" width="81" height="27" alt="" />');
	// Animate buttons, shrink and fade shadow
	$("#Activities li").hover(function() {
		var e = this;
		$(e).find("a").stop().animate({ marginTop: "-14px" }, 250, function() {
			$(e).find("a").animate({ marginTop: "-10px" }, 250);
		});
		$(e).find("img.Shadow").stop().animate({ width: "81px", height: "20px", opacity: 0.25 }, 250);
	},function(){
		var e = this;
		$(e).find("a").stop().animate({ marginTop: "4px" }, 250, function() {
			$(e).find("a").animate({ marginTop: "0px" }, 250);
		});
		$(e).find("img.Shadow").stop().animate({ width: "81px", height: "27px", opacity: 1 }, 250);
	});
});

// Chart
$(document).ready(function() {
  // for each result row..
  $(".Result").each(function() {
    // get the width of the bar from the span html
    var length = $(this).find("span").html();
    // Animate the width of the 'p' with a callback function
    // You can add a delay if you want too!
    $(this).find("p").delay(2000).animate({'width':length}, 2000, function() {
	  // once the bar animation has finished, fade in the results
	  $(this).find("span").fadeIn(600);
    });
  });
});

// jQuery Toggle FAQ Module
$(document).ready(function(){
$(".ToggleBox").hide();
	$(".Toggle").click(function(){
		$(this).toggleClass("ActiveToggle").next().slideToggle("normal");
	});
});

// jQuery Contactform
$(document).ready(function(){
	// Input Fields Highlights
	$('input[type="text"], textarea').addClass("idleField");
	$('input[type="text"], textarea').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 : '');
		}
	});
	// Validating Fields
	$('#ContactForm').submit(function(){
		var action = $(this).attr('action');
		$("#Message").slideUp('normal',function() {
		$('#Message').hide();
 		$('#Submit')
			.after('<div class="Loader"></div>')
			.attr('disabled','disabled');
		$.post(action, { 
			name: $('#name').val(),
			email: $('#email').val(),
			telefoon: $('#telefoon').val(),
			comments: $('#comments').val()
		},
			function(data){
				document.getElementById('Message').innerHTML = data;
				$('#Message').slideDown('normal');
				$('#ContactForm .Loader').fadeOut('normal',function(){$(this).remove()});
				$('#ContactForm #Submit').attr('disabled',''); 
				if(data.match('success') != null) $('#ContactForm').slideUp('normal');
			}
		);
		});
		return false; 
	});
});
