$(document).ready(function(){	
	$('.projectdescription').css('display','none');
	
	$('.projectItem').hover(function() {
		var child = $(this).find('.projectdescription');
		child.stop(false, true).fadeIn(300);
		
	}, function() {
		$(this).children('.projectdescription').removeClass('active');
		var child = $(this).find('.projectdescription');
		child.stop(false, true).fadeOut(500);
	});
	
	$('.blogItem').hover(function() {
		$(this).children('img').stop(false, true).animate({
			opacity: 0.6
		});
	}, function() {
		$(this).children('img').stop(false, true).animate({
			opacity: 1
		});
	});
	
	$('.slider').hide();

	//if (document.documentElement.clientWidth > 500) {
		if($('.slider .selected').length) {
			var sel_slide = $('.selected').parents('.slider');
			sel_slide.show();
			sel_slide.prev().addClass('active');
		} else {	
			$('.slideheading:first').addClass('active');
			$('.slider:first').show();
		}
	//}
	
	$('.slideheading').click(function() {
		var sliderHead = $(this);
		if(sliderHead.next().is(':hidden')) {
			$('.active').next().slideUp(750);
			$('.slideheading').removeClass('active');
			sliderHead.addClass('active').next().slideDown(750);
		} else {
			sliderHead.removeClass('active').next().slideUp(750);
		}
	}); 
}); 


jQuery(function() {
	jQuery("#signup form").submit(function() {
		if (jQuery('#name').val() == '') {
			alert('Please enter a name');
			return false;	
		}
		if (jQuery('#email').val() == '') {
			alert('Please enter an e-mail address');
			return false;
		}
		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);
		if (!pattern.test(jQuery('#email').val())) {
			alert('Please enter a valid e-mail address');
			return false;
		}
		var str = jQuery(this).serialize();
		jQuery.ajax({
		type: "POST",
		url: this.action,
		data: str,
		success: function(msg){
			jQuery('#ajaxReturn').ajaxComplete(function(event, request, settings){
				jQuery("#signup form").fadeOut('500', function() {
					jQuery('#ajaxReturn').html(msg);
					jQuery('#ajaxReturn').fadeIn('700');
				});
			});
		}
		});
	return false;
	});
});
