
/****************************************************************************

  This file is part of the GamesCast.tv Website

	GamesCast.tv coded by Steve "GreasedScotsman" Huff, 
	Copyright 2010 Steve Huff
	
	It is distributed under the terms of the 
	GNU General Public License
		
***************************************************************************/
function submitNotification() {

		//$("#successMsg").show();
		$("#successMsg").html('');
		var hasError = false;

		if($("#nMessage").val() == '') {
			$("#successMsg").html('<p>You forgot to enter a notification message.</p>');
			$("#successMsg").fadeIn(500);
			$("#successMsg").fadeOut(5000);
			hasError = true;
		} 

		if(hasError == false) {
			
			$.post("/cms/addnotification.php", { nMessage: $("#nMessage").val(), nSource: $("#nSource").val(), nType: $("#nType").val(), nAuthor: $("#nAuthor").val() },
				function(data){
					$("#successMsg").html('<p><b>Success</b>: Your notification was posted.</p>');
					$("#successMsg").fadeIn(500);
					$("#successMsg").fadeOut(5000);
					
					notoficationsUpdate(nowlocal);
				}
			 );
			$("#nMessage").val("");
		}
		return false;
}

$(document).ready(function(){

	$("#notificationForm").submit(function(){ submitNotification(); });

	$("input[class='notification']").bind("keydown", function(event) {
		// track enter key
		var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
		if (keycode == 13) { // keycode for enter key
			// force the 'Enter Key' to implicitly click the Update button
			submitNotification();
			return false;
		} else {
			return true;
		}
	}); // end of function
});


// EOF
