$(function(){
	$('.front h1').bind('click', function() {
		window.location = "http://mindboxstudios.com";
		return false;
	});
});

$(function(){
	$('#frm_contact').ps_formify();
	nav_fade();
	nav_pic_fade();
	li_roll();
	if($('.front').length > 0){
	   nav_scroll();	
	}
	contact_send();
});

function nav_fade(){
	var speed = 300;
	$('#header ul > li > div').hide();
	$('#header ul > li').hover(function(){
		$(this).find('div').stop().fadeTo(speed, 1, function(){
			if (jQuery.browser.msie){$(this).get(0).style.removeAttribute('filter');}
		});
	}, function(){
		$(this).find('div').stop().animate({opacity:'hide'}, speed);
	});
}

function nav_pic_fade(){
	$('#team_txt li img').hide();
	$('#team_txt li').hover(function(){
		$(this).find('img').stop().fadeTo(300, 1);
	}, function(){
		$(this).find('img').stop().fadeTo(300, 0);
	});
}

function li_roll(){
	var speed = 350;
	var so = .65;
	$('#pieces span').fadeTo(0, .85);
	$('#pieces li img').fadeTo(0, so);
	$('#pieces li').hover(function(){
		$(this).find('img').stop().fadeTo(speed, 1);
		$(this).find('span').stop().animate({top:0}, 200);
	}, function(){
		$(this).find('img').stop().fadeTo(speed, so);
		$(this).find('span').stop().animate({top:-40}, 200);
	});
}

function nav_scroll(){
	var t = $('.front #team').offset().top - 70; 
	var h = $('#content_top').offset().top - 70;
	var w = $('#content').offset().top - 70;
	var l = $('#location').offset().top - 70;
	$('.about').click(function(){
		$(document).scrollTo($('#about'), 800);
		return false;
	});
	$('.work').click(function(){
		$(document).scrollTo(w, 800);
		return false;
	});
	$('.team').click(function(){
		$(document).scrollTo(t, 800);
		return false;
	});
	$('.homeslice').click(function(){
		$(document).scrollTo(h, 800);
		return false;
	});

	$('.location').click(function(){
		$(document).scrollTo(l, 800);
		return false;
	});
}

function contact_send(){
	$('.not-front #content h2').hide();
	$('#submit').click(function(){
		var str = $('#frm_contact').serialize();
		$.ajax({
			type: 'POST',
			url: '../includes/mailer.php',
			data: str,
			success: function(msg){
				msg = jQuery.trim(msg);
				if(msg != ''){
					if(msg == 'success'){
						$('#frm_contact').fadeOut(function(){
							$('h2').html('Thank you! We have recieved your message.');
							$('h2').fadeIn();
						});
					}else{
						$('h2').html(msg);
						$('h2').fadeIn();
					}
				}
			}
		});
		return false;
	});
}









