/* Javascript by Tyler Mulligan of Salter>Mitchell */
$(document).ready(function() {
	
	// Tabs
	var tabContainers = $('div.tabs > div');
	tabContainers.hide().filter(':first').show();
	
	$('.tab').click(function () {
			tabContainers.hide();
			tabContainers.filter(this.hash).show();
			$('.tab').removeClass('selected');
			$(this).addClass('selected');
			return false;
	}).filter(':first').click();
	
	// Fancy corners
	//$("#splash").corner("5px");
	$("#to_billboards").corner("cc:#7ac142 top 5px");
	$("#to_video").corner("cc:#7ac142 top 5px");
	
	// Billboards
	$("a[rel='billboards']").colorbox();

	// Setup validation for invite
	$("#invite_a_friend").validate({
		errorLabelContainer: $("#friend_errors")
	});
	// Clear box on first click
	$("#friend_email").click(function(){
		if ($(this).val()=="Enter Friend's Email") {
			$(this).val("");
		}
	});
	// On submit, check if it's a valid email
	$("#send_friend_email").click(function(){
		// Make sure the email box is valid
		if ($("#invite_a_friend").valid()) {
			// Get URL
			var url = $(this).attr("href");
			// Initiate Colorbox
			$.fn.colorbox({
				href:url+"/"+$("#friend_email").val(),
				open:true,
				iframe:true,
				height:468,
				intialHeight:100,
				width:640,
				initialWidth:400
			});
		}
		return false; // return false to not activate the link
	});
	// process enter as submission
	$('#invite_a_friend').bind("keypress", function(e) {
		if (e.keyCode == 13) {
			$("#send_email").click();
			return false;
		}
	});
	
	
	
	// Setup validation for invite
	$("#invite_a_parent").validate({
		errorLabelContainer: $("#parent_errors")
	});
	// Clear box on first click
	$("#parent_email").click(function(){
		if ($(this).val()=="Enter Parent's Email") {
			$(this).val("");
		}
	});
	// On submit, check if it's a valid email
	$("#send_parent_email").click(function(){
		// Make sure the email box is valid
		if ($("#invite_a_parent").valid()) {
			// Get URL
			var url = $(this).attr("href");
			// Initiate Colorbox
			$.fn.colorbox({
				href:url+"/"+$("#parent_email").val(),
				open:true,
				iframe:true,
				height:468,
				intialHeight:100,
				width:640,
				initialWidth:400
			});
		}
		return false; // return false to not activate the link
	});
	// process enter as submission
	$('#invite_a_parent').bind("keypress", function(e) {
		if (e.keyCode == 13) {
			$("#send_email").click();
			return false;
		}
	});

});

