			var xmlHttp; // AJAX object

			/**
			 * Create the AJAX object based on browser type
			 **/
			function createXMLHttpRequest() {
				// Check for IE
			    if (window.ActiveXObject) {
			        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			    } else if (window.XMLHttpRequest) {
			        xmlHttp = new XMLHttpRequest();
			    }
			}

			/**
			 * Has the user submitted a review for this event?
			 **/
			function hasSubmittedReview(guid) {
				return (getCookie("review" + guid) !== null);
			}

			/**
			 * Mark the event as being reviewed by this user for half an hour
			 * just in case this is a common/communal computer. This is to protet
			 * multiple submissions by the same user.
			 **/
			function markAsReviewed() {
				var reviewHeadingInput = document.getElementById("reviewHeadingInput");
				var associatedContentGUId = reviewHeadingInput.name;
				
				setCookie("review" + associatedContentGUId, "reviewed");
			}
			
			/**
			 * Create the createAddQueryString
			 **/
			function createAddQueryString(guid, heading, message) {
				return "heading=" + heading + "&body=" + message + "&associatedContentGUId=" + guid;
			}
			
			/**
			 * Display the word count of the text area within the word count div
			 **/
			function displayWordCount() {
				var wordCountDiv = document.getElementById("wordCount");
				if(wordCountDiv.hasChildNodes()) {
					wordCountDiv.removeChild(wordCountDiv.childNodes[0]);
				}
				if (countWords(document.getElementById('reviewBodyTextArea')) > 300) {
					output = "A maximum of 300 words is allowed. Your current word count = " + countWords(document.getElementById('reviewBodyTextArea')) + ". Please reduce the size of your message.";
					wordCountDiv.setAttribute("class", "error");
				} else {
					output = "A maximum of 300 words is allowed. Your current word count = " + countWords(document.getElementById('reviewBodyTextArea'));
					wordCountDiv.setAttribute("class", "");

				}
				// Post Message
				wordCountDiv.appendChild(document.createTextNode(output))
			}
			
			/**
			 * Validate that the input are not empty
			 **/
			function validateInputs() {
				var reviewHeadingInput = document.getElementById("reviewHeadingInput");
				var reviewBodyTextArea = document.getElementById("reviewBodyTextArea");
				
				// Check for valid content
				if ( (trimAll(reviewHeadingInput.value) == '') ||
				     (trimAll(reviewBodyTextArea.value) == '') ) {
				    // Invalid content so display error message
					showMessage("Please provide both a review heading and a review", true);
				} else if (countWords(document.getElementById('reviewBodyTextArea')) > 300) {
					showMessage("Please reduce your review to 300 words or less", true);
		        } else {
		            // Inputs are fine at a high level so submit them
		        	submitReview();
		        }
				     
			}
			
			/**
			 * Validate the content of the review for profanity or any other undesirable
			 * content.
			 **/
			function submitReview() {
				var reviewHeadingInput = document.getElementById("reviewHeadingInput");
				var reviewBodyTextArea = document.getElementById("reviewBodyTextArea");

				var associatedContentGUId = reviewHeadingInput.name;
				var heading = reviewHeadingInput.value;
				var body = reviewBodyTextArea.value;
				
				createXMLHttpRequest(); // Create AJAX object
				
				// Create Message
			    var url = appPath + "/event/review.do?" 
			        + createAddQueryString(associatedContentGUId, heading, body);

				// Send Message
			    xmlHttp.onreadystatechange = handleAddStateChange;
			    xmlHttp.open("GET", url, true);
			    xmlHttp.send(null);
    				
				// Display "Sumitting" message to user so they know something is happening
				//TODO
			}
			
			/**
			 * This is the method that handles the response from the server upon submitting
			 * the review
			 **/
			function handleAddStateChange() {
			    if(xmlHttp.readyState == 4) {
			        if(xmlHttp.status == 200) {
			            if (xmlHttp.responseText.substring(xmlHttp.responseText.length - 1, xmlHttp.responseText.length) == "0") {
			            	// Mark event as reviewed
			            	markAsReviewed();
			            	showMessage("Thank you for your review");
			            	displayResults();
			            } else {
			            	showMessage("It seems that your review contains profanity or URL's. Please remove any objectionable content and resubmit.", true);
			            }
			        }
			        else {
			        	showMessage("Sorry, we were unable to submit your review at this moment due to a problem with our system. Please try again at another time.", true);
			        }
			    }
			}
			
			/**
			 * Submit a new review of an event
			 **/
			function displayResults() {
				var reviewInput = document.getElementById("reviewHeadingInput");
				var reviewTextArea = document.getElementById("reviewBodyTextArea");
				var currentTime = new Date();
				
				appendNewReview(reviewInput.value, reviewTextArea.value, currentTime);
				removeReviewInputBox();
			}
			
			/**
			 * Append a new review to the end of the list of reviews
			 **/
			function appendNewReview(heading, review, date) {
				var reviewContentContainerDiv = document.getElementById("reviewContentContainer");
				var reviewEntryDiv = document.createElement("div");
				var reviewDateDiv = document.createElement("div");
				var reviewHeadingtDiv = document.createElement("div");
				var reviewBodyTextAreaDiv = document.createElement("div");
				
				// Populate elements
				reviewEntryDiv.setAttribute("id", "reviewEntry");

				// Alternate background color
				if ( (reviewContentContainerDiv.childNodes.length - 2) % 2 == 1) {
					reviewEntryDiv.setAttribute("class", "dark");
				} else {
					reviewEntryDiv.setAttribute("class", "light");
				}
				
				// Populate Heading
				reviewHeadingtDiv.setAttribute("id", "reviewHeading");
				reviewHeadingtDiv.appendChild(document.createTextNode(heading));
				
				// Format and Populate Date
				reviewDateDiv.setAttribute("id", "reviewDate");
				reviewHeadingtDiv.appendChild(document.createTextNode(", " + formatDate(date, "MMM. dd, yyyy")));
				
				// Populate Body
				reviewBodyTextAreaDiv.setAttribute("id", "reviewBody");
				reviewBodyTextAreaDiv.appendChild(document.createTextNode(review));
				
				reviewEntryDiv.appendChild(reviewHeadingtDiv);
				reviewEntryDiv.appendChild(reviewBodyTextAreaDiv);
				reviewContentContainerDiv.appendChild(reviewEntryDiv);
			}
			
			/**
			 * Show the review input box so the user can enter a new review
			 **/
			function showReviewInputBox(guid) {
				var reviewEntryFormDiv = document.getElementById("reviewEntryForm");
				
				// Remove the form if it's already displayed
				if(reviewEntryFormDiv.hasChildNodes()) {
					reviewEntryFormDiv.removeChild(reviewEntryFormDiv.childNodes[0]);
				}
				
				// Create base elements
				var reviewForm = document.createElement("form");
				var formContainer = document.createElement("div");
				var headingContainerDiv = document.createElement("div");
				var headingText = document.createElement("div");
				var headingInputDiv = document.createElement("div");
				var bodyTextAreaDiv = document.createElement("div");
				var headingInput = document.createElement("input");
				var bodyTextArea = document.createElement("textarea");
				var input = createInputButton("submit", "Submit Review", "validateInputs();");
				var wordCountDiv = document.createElement("div");
				var br = document.createElement("br");
				
				// Populate elements
				formContainer.setAttribute("align", "left");
				
				wordCountDiv.setAttribute("id", "wordCount");
				
				headingText.setAttribute("id", "reviewFormHeading");
				headingInputDiv.setAttribute("id", "reviewFormHeadingInput");
				
				headingInput.setAttribute("id", "reviewHeadingInput");
				headingInput.setAttribute("name", guid);
				headingInput.setAttribute("maxlength", "200");
				headingInput.setAttribute("size", "50");
				headingInput.setAttribute("class", "reviewHeading");

				bodyTextArea.setAttribute("id", "reviewBodyTextArea");
				bodyTextArea.setAttribute("rows", "5");
				bodyTextArea.setAttribute("cols", "70");
				bodyTextArea.setAttribute("class", "reviewBody");
				bodyTextArea.setAttribute("onchange", "displayWordCount();");
				bodyTextArea.setAttribute("onkeydown", "displayWordCount();");
				bodyTextArea.setAttribute("onkeyup", "displayWordCount();");
				
				// Clear Mesages
				clearMessages();
				
				// Build From
				wordCountDiv.appendChild(document.createTextNode("A maximum of 300 words is allowed."));
				bodyTextAreaDiv.appendChild(bodyTextArea);
				headingText.appendChild(document.createTextNode("Heading"));
				headingInputDiv.appendChild(headingInput);
				headingContainerDiv.appendChild(headingText);
				headingContainerDiv.appendChild(headingInputDiv);
				formContainer.appendChild(headingContainerDiv);
				formContainer.appendChild(bodyTextAreaDiv);
				formContainer.appendChild(input);
				formContainer.appendChild(wordCountDiv);
				reviewForm.appendChild(formContainer);
				reviewEntryFormDiv.appendChild(reviewForm);
			}
			
			/**
			 * Remove Review input box
			 **/
			function removeReviewInputBox() {
				var reviewEntryFormDiv = document.getElementById("reviewEntryForm");
				if(reviewEntryFormDiv.hasChildNodes()) {
					reviewEntryFormDiv.removeChild(reviewEntryFormDiv.childNodes[0]);
				}
			}
			
			/**
			 * IE and firefox seem to act differently when creating a input box with javascript.
			 **/
			function createInputButton(name, value, onclick) {
				var input;
				if (browser.isIE)
				{
					var inputString = "<input type='button' value='" + name + "' value='" + value + "' onclick='" + onclick + "' />";
					input = document.createElement(inputString);
				} else {
					input = document.createElement("input");
					input.setAttribute("type", "button");
					input.setAttribute("name", name);
					input.setAttribute("value", value);
					input.setAttribute("onclick", onclick);
				}
				
				return input;
			}
			
			/**
			 * Display a message
			 **/
			function showMessage(message, isError) {
				var reviewMessageDiv = document.getElementById("reviewMessage");

				// Clear any existing messages
				if(reviewMessageDiv.hasChildNodes()) {
					reviewMessageDiv.removeChild(reviewMessageDiv.childNodes[0]);
				}
				
				// If the message is an error message then change the style
				if (isError) {
					reviewMessageDiv.setAttribute("class", "error");
				} else {
					reviewMessageDiv.setAttribute("class", "general");
				}
				
				reviewMessageDiv.appendChild(document.createTextNode(message));
			}
			
			/**
			 * Clear any messages that may be displayed
			 **/
			function clearMessages() {
				var reviewMessageDiv = document.getElementById("reviewMessage");

				// Clear any existing messages
				if(reviewMessageDiv.hasChildNodes()) {
					reviewMessageDiv.removeChild(reviewMessageDiv.childNodes[0]);
				}
			}
			
			/**
			 * Start the review process by as follows:
			 *  1) check if they have already submitted a review
			 *    1.1) if YES then display an appropriate message
			 *    1.2) if NO then show the review form
			 **/
			function startReviewProcess(guid)
			{
			    if (!supportsCookies()) {
			    	showMessage("Sorry, one those with cookie enabled browers can submit reviews. This is done in order to prevent people from entering multiple reviews. Please enable cookies on your browser and try again.", true);
				} else if (hasSubmittedReview(guid)) {
					showMessage("Sorry, it seems that you have already submitted a review for this event", true);
				} else {
					showReviewInputBox(guid);
				}
			}
