function requestRight(cid) {
	jQuery.get("right.php", { cid:cid }, function(data) {
		jQuery('#right').html(data);
		jQuery('#left_nav a').removeClass('active');
		jQuery('#menu-'+cid).addClass('active');
   });
}

function requestContent(cid) {
	jQuery.get("content.php", { cid:cid }, function(data) {
		jQuery('#content').html(data);
   });
}



function manageHistory() {
	/* * jQuery history * */
	/* The following script is added to the document onready queue */
	jQuery(function() {
		/* The "historyadd" event is triggered whenever navigation occurs. */
		jQuery('#left_nav').historyadd(function(e, currentHash, previousHash) {
			requestContent(currentHash);
			requestRight(currentHash);
		});
		/* The "history" event is triggered whenever the user presses the back button or jumps backwards or forwards in their browser's history list. */
		jQuery('#left_nav').history(function(e, currentHash, previousHash) {
			if(currentHash != '') {
				requestContent(currentHash);
				requestRight(currentHash);
			}
		});
		/* Use getCurrent() function to get the hash for the initial load or if the user refreshes the page */
		var initialHash = jQuery.history.getCurrent();
		if (initialHash == '') initialHash = 1;
		requestContent(initialHash);
		requestRight(initialHash);
		
	});
}


function checkForm(formObj) {
	var formOK = true;
	
	formOK = checkEmail(formObj.email.value);  // check email address

	if (formOK == true) {
		formObj.submit();
	}

}


function checkEmail(email) {
	if (email.length == 0) {
		window.alert("You must provide your e-mail address.");
		return false;
	}
	if (email.indexOf("/") > -1) {
		window.alert("E-mail address has invalid character: /");
		return false;
	}
	if (email.indexOf(":") > -1) {
		window.alert("E-mail address has invalid character: :");
		return false;
	}
	if (email.indexOf(",") > -1) {
		window.alert("E-mail address has invalid character: ,");
		return false;
	}
	if (email.indexOf(";") > -1) {
		window.alert("E-mail address has invalid character: ;");
		return false;
	}
	if (email.indexOf("@") < 0) {
		window.alert("E-mail address is missing @");
		return false;
	}
	if (email.indexOf("\.") < 0) {
		window.alert("E-mail address is missing .");
		return false;
	}
	return true;
}
	
