function updateHash() {
	if (location.hash.slice(1) != "")
		redirectAJAX(location.hash.slice(1));
}
$(document).ready(function() {
	$("#cancel_button").click(function() {
		$("#sticky_note_table").fadeOut();
	});
});
function redirectAJAX(getVars) {
	var explode = getVars.split("->");
	if (explode[0].length > 0) {
		$("#binder_table").fadeIn();
		if ((explode[1].length > 0) && (explode[1].length > 0)) {
			if (explode[0] == "portfolio code")
				portfolio_code()
			else {
				$.get("ajax_content.php", {type: "portfolio", page: explode[1], client: explode[2]},
					function(data){
						$("#binder_body").html(data);
					}
				);
			}
		}
		else {
		$.get("ajax_content.php", {type: explode[0]},
			function(data){
				$("#binder_body").html(data);
			}
		);
		}
	}
	else {
		alert("value: " + explode[0]);
	}
}
function sendEmail(name, email, message) {
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (name.length <  1) {
		alert("The Name field is required...how should I refer to you in my response?");
	}
	else if (email.length < 1) {
		alert("The Email field is required...your email will not be published and is simply used for my response.");
	}
	else if (reg.test(email) == false) {
		alert("Invalid Email Address...make sure you have your email address typed in properly.");
	}
	else if (message.length < 1) {
		alert("You left the Message field blank...come on, there must be something you want to say.");
	}
	else {
		$.get("ajax_content.php", {type: "sendEmail", n: name, e: email, m: message},
			function(data){
				$("#binder_body").html(data);
			}
		);
	}
}
function updatePortfolio(client, page) {
	$("#portfolio_loading").fadeIn(1);
	window.location.hash = "portfolio->" + page + "->" + client;
	$.get("ajax_content.php", {type: "portfolio", page: page, client: client},
		function(data){
			$("#binder_body").html(data);
		}
	);
	$("#portfolio_loading").fadeOut();
}
function home() {
	$("#sticky_note_table").fadeOut();
	$("#binder_table").fadeOut();
}
function portfolio() {
	$("#binder_body").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	$("#binder_table").fadeIn();
	$("#portfolio_loading").fadeIn(1);
	window.location.hash = "portfolio->0";
	$.get("ajax_content.php", {type: "portfolio"},
		function(data){
			$("#binder_body").html(data);
		}
	);
	$("#portfolio_loading").fadeOut();
}
function portfolio_design() {
	$("#binder_body").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	$("#binder_table").fadeIn();
	$("#portfolio_loading").fadeIn(1);
	window.location.hash = "portfolio->0";
	$.get("ajax_content.php", {type: "portfolio"},
		function(data){
			$("#binder_body").html(data);
		}
	);
	$("#portfolio_loading").fadeOut();
}
function portfolio_code() {
	$("#binder_body").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	$("#about_loading").fadeIn(1);
	window.location.hash = "portfolio code->";
	$("#binder_table").fadeIn();
	$.get("ajax_content.php", {type: "portfolio code"},
		function(data){
			$("#binder_body").html(data);
		}
	);
	$("#about_loading").fadeOut();
}
function about() {
	$("#binder_body").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	$("#about_loading").fadeIn(1);
	window.location.hash = "about->";
	$("#binder_table").fadeIn();
	$.get("ajax_content.php", {type: "about"},
		function(data){
			$("#binder_body").html(data);
		}
	);
	$("#about_loading").fadeOut();
}
function contact() {
	$("#binder_body").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	window.location.hash = "contact->";
	$("#binder_table").fadeIn();
	$.get("ajax_content.php", {type: "contact"},
		function(data){
			$("#binder_body").html(data);
		}
	);
}
function loadBlog(id,title) {
	$("#blog_content").html("");
	window.location.hash = "blog->" + title;
	$("#blog_div").fadeIn();
	$("#blog_content").html("<p align=center><img src='images/loading_circle.gif'>&nbsp;Loading...</p>");
	$.get("ajax_content.php?id=" + id, {type: "blog"},
		function(data){
			$("#blog_content").html(data);
		}
	);
}
