// JavaScript Document
function validateProcess(status) {
	error = "none";
	if ($('#name').val() == ""){
		$('#nameError').html(" You did not enter your name");
		error = "yes";
	}
	else
	{$('#nameError').html("");
	a = $('#name').val();
	
	}
	
	if ($('#city').val() == ""){
		$('#cityError').html(" You did not enter your city");
		error = "yes";
	}
	else
	{$('#cityError').html("");
	b = $('#city').val();
	c = $('#state').val();
	
	}
	
	d = $('#comment').val();
	
	
	//e = document.getElementById('coming');
	//e = e.checked;
	
	f = $('#partyNum').val();
	
	
	if (error == "none" && status=="preview"){
		
		var result = ""
		var g = "";
		var arr = Array("alum","curStudent","curFaculty","emeritus","staff","famFriend","congress","parent","futStudent","commMember");
		for (i=0;i<arr.length;i++){
			var z = arr[i];
			y = document.getElementById(z);
			if (y.checked == true) {
				g += ","+arr[i];
			}
		}
		//if (e==true && f==""){
			//f=1;
		//}
		result = "<h3>Preview</h3>";
		result += "<p><strong>From:</strong> "+a+"</p>";
		result += "<p>"+d+"</p>";
		//if (e==true){result += "<p>Number Attending: "+f+"</p>";}
				
		
		result += "<p><input type=\"button\" onclick=\"edit()\" value=\"Edit\" />&nbsp;&nbsp;<input type=\"button\" onclick=\"validateProcess('submit')\" value=\"Submit\" /></p>";
		$('#button').addClass('hide');
		$('#checkboxes').addClass('hide');
		$('#form').addClass('hide');
		$('#search').addClass('hide');
		$('#preview').removeClass('hide');
		$('#preview').html("");
		$('#preview').html(result);
	}
		else if(error == "none" && status=="submit"){
			var result2 = "";
			var g = "";
			var arr = Array("alum","curStudent","curFaculty","emeritus","staff","famFriend","congress","parent","futStudent","commMember");
			for (i=0;i<arr.length;i++){
				var z = arr[i];
				y = document.getElementById(z);
				if (y.checked == true) {
					g += arr[i]+",";
				}
			}
		h = $('#blk').val();
		
		/*if (e==true){
				e = "yes";}
			else {
				e = "no";}
		
		if (e=="yes" && f=="") {
			f = 1;
		}*/
		
			$.post("process/form_proc.php",{a:a,b:b,c:c,d:d,g:g,h:h}, function () {window.location = "comments.php"
});
			$('#comments').removeClass();
					
		}
}

function edit () {
	$('#form').removeClass('hide');
	$('#checkboxes').removeClass('hide');
	$('#button').removeClass('hide');
	//$('#search').removeClass('hide');
	$('#preview').addClass('hide');
	$('#preview').html("");
}
	

function showHide () {
	a = document.getElementById('coming');
	if (a.checked == true) {
		$('#partyNumCell').removeClass();
		$('#partyNumCell').addClass('show');
		a = $('#partyNum').val('1');
		a.focus();
	}
	else {
		$('#partyNumCell').removeClass();
		$('#partyNumCell').addClass('hide');
		$('#partyNum').val("");
	}
}
function validateNum() {
	a = $('#partyNum').val();
	if (a.match(/\b\d+\b/g)){
		if (a > 15) {
			if(confirm("You have elected to bring "+a+" guests. If this is the number of guests you intend to bring, click \"OK\". Otherwise click \"Cancel\" and re-enter the correct number.")){
					 b = document.getElementById('comment');
					 b.focus();
				   }
				   else
				   {
					   b = document.getElementById('partyNum');
					   b.focus();
				   }
		}
	}
	else
		{ $('#partyNum').val("");}
		
}
function nameSearch() {
	a = $('#nameSearch').val();
	$.post("process/name_search_proc.php",{a:a}, function (data) {$('#comments').html(data);});
}

function deleteEntry(a){
	if (confirm("You are about ready to delete an entry that can not be recovered.  If you want to delete this entry click \"OK\", otherwise click \"Cancel\"")) {
		$.post("../process/delete_proc.php",{a:a}, function (data) {$('#editDelete').html(data);});
	}
}
function getEdit(a){
		$.post("../process/get_edit_proc.php",{a:a}, function (data) {$('#edit').html(data);});
	}


		
	