
function viewEvent(id) {
		refreshComments(id,"event");
		document.getElementById("event_details").style.display = "none";
		document.getElementById("pg_description").style.display = "none";
		document.getElementById("loader").style.display = "block";
		var bingArgs = {
				method: 'post',
				postBody: 'id=' + id,
				onSuccess: function(data) {
					fadeBlock("event_details","open");
					document.getElementById("loader").style.display = "none";
					var obj = eval('(' + data.responseText + ')');
					document.getElementById("event_name").innerHTML = obj.title;
					document.getElementById("event_date").innerHTML = obj.date;
					document.getElementById("event_description").innerHTML = obj.description;
					document.getElementById("event_time").innerHTML = obj.time;
					document.getElementById("sid").value = id;
						
				},
				on404: function(data) {
					alert('Error 404: location "' + data.statusText + '" was not found.');
				},
				onFailure: function(data) {
					alert('Error ' + data.status + ' -- ' + data.statusText);
				}
			}
			
		new Ajax.Request('/PHP/getEvents.php', bingArgs);
	}
	function addAttendee(eid) {
		var bingArgs = {
				method: 'post',
				postBody: 'action=addAttendee&event_id=' + eid + '&user_id=<?= $_SESSION["userID"] ?>',
				onSuccess: function(data) {
				fadeBlock("notify_box","open");
				document.getElementById("loader").style.display = "none";
				var response = data.responseText;
				if(response.indexOf("OK") != -1) {
					//Success! Display success message and redirect.
					document.getElementById("notify").style.color = "green";
					document.getElementById("notify").innerHTML = "Added.";
				} else {
					//Display error message from the server.
					document.getElementById("notify").style.color = "red";
					document.getElementById("notify").innerHTML = response;
				}
						
				},
				on404: function(data) {
					alert('Error 404: location "' + data.statusText + '" was not found.');
				},
				onFailure: function(data) {
					alert('Error ' + data.status + ' -- ' + data.statusText);
				}
			}
			
		new Ajax.Request('/PHP/getEvents.php', bingArgs);
	}
	function checkValues(id) 
	{
		//Put the tinyMCE values into the actual fields
		tinyMCE.triggerSave();
		
		var string = "Please fill out the required information:\n ";
	  
		if (document.getElementById("Comment").value == "") 
		  string += "\n -Comment";
	
		if (string == "Please fill out the required information:\n ")
			addComment(id);
		else
		{
			alert(string);
			return;
		}	
	}
	
	function init(initial_id) {
		if(initial_id != "-1") viewEvent(initial_id);
	}