	
	function toggleLayer(whichLayer)
	{
		if (document.getElementById)
		{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
		}
		else if (document.all)
		{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
		}
		else if (document.layers)
		{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
		}
	}
	
	function saveOrder(listclass,hiddenfield) {
		var order = Sortable.serialize(listclass);
		document.getElementById(hiddenfield).value = order;
		document.position.submit();
		return false;
	}


/*****************************************************************************
* Function: fadeBlock(myElement,command)
* Author: Jason Wagner
* Input: Uses the fade effect to open and close DIV (or other) elements.
* Returns: True on success
******************************************************************************/

	function fadeBlock(myElement,command) {
		
		if(command == "close") {
			new Effect.Fade(document.getElementById(myElement));
		}
		if(command == "open") {
			new Effect.Appear(document.getElementById(myElement));	 
		}
		return true;   
	}
	
/*****************************************************************************
* Function: redirectMe(url,sec)
* Author: Jason Wagner
* Input: Takes the url to redirect to. And the time before redirect, in seconds.
* Returns: N/A
******************************************************************************/
	function redirectMe(url,sec) {
		window.setTimeout("window.location.href = '" + url + "';",sec * 1000);
		return true;
	}
	
/*****************************************************************************
* Function: showVideo(filename)
* Author: Jason Wagner
* Input: Pops ups the video window
* Returns: N/A
******************************************************************************/
function showVideo(filename) {
	win=window.open('/PHP/playVideo.php?filename=' + filename,'jav','width=680,height=400,resizable=yes,scrollbars=yes');
	win.opener=self; win.moveTo(screen.width/2-360,screen.height/2-200);
}

/*****************************************************************************
* Function: refreshComments(id,type)
* Author: Jason Wagner
* Input: Refreshes the comment box with the newest comment
* Returns: N/A
******************************************************************************/
function refreshComments(id,type) {		
		var bingArgs = {
			method: 'post',
			postBody: 'id=' + id + '&Type=' + type,
			onSuccess: function(data) {
				var response = data.responseText;
				document.getElementById("comment_box").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('/comments/get/', bingArgs);
}

/*****************************************************************************
* Function: addComment(sid)
* Author: Jason Wagner
* Input: Adds the comment to page.
* Returns: N/A
******************************************************************************/
function addComment(sid) {
		
		document.getElementById("loader").style.display = "inline";
		//Javascript conflicts with "ID" name w/ calendar. Too many functions
		//and such. Built in the capability to pass an ID if need be.
		if(sid == null) 
			var id = document.getElementById("ID").value;
		else 
			var id = sid;
	
		var type = document.getElementById("Type").value;
		var comment = document.getElementById("Comment").value;
		comment = encodeURIComponent(comment);
		
		var bingArgs = {
			method: 'post',
			postBody: "ID=" + id + "&Type=" + type + "&Comment=" + comment,
			onSuccess: function(data) {
				document.getElementById("loader").style.display = "none";
				tinyMCE.setContent('');
				var response = data.responseText;
				if(response.indexOf("OK") != -1) {
					refreshComments(id,type);
				} else {
					//Display error message from the server.
					alert(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('/postcomment', bingArgs);
}


