/* Research Database Management System (RDMS)
 ' Copyright(C) 2008 Graham Philips
 ' RDMS is licensed under the GNU General Public License.
 ' Please See license.html or http://www.gnu.org/licenses/gpl.txt for the full license
 ' If there are problems, see http://sourceforge.net/projects/rdms/ for support.
 '
 ' RDMS comes with ABSOLUTELY NO WARRANTY
 '  
 ' This program is free software; you can redistribute it and/or modify it under
 ' the terms of the GNU General Public License as published by the Free Software
 ' Foundation; either version 2 of the License, or (at your option) any later
 ' version. */

/* Functions for administrating paper classes */

var classDesc;

function updateClass(classID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Updating class...]";
	xmlHttp = new GetXmlHttpObject();
	classDesc = escape(document.getElementById('classDesc'+classID).value);
	if (classDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a class description";
	}
	else
	{
		url = "/includes/ajax/categories/updateclass.asp?classID="+classID+
			"&classDesc="+classDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','classDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function removeClass(classID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Removing class...]";
	xmlHttp = new GetXmlHttpObject();
	url = "/includes/ajax/categories/removeclass.asp?classID="+classID+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','classDisplayBox');};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function removeClassPrompt(classID)
{
	document.getElementById('messageDisplayBox').innerHTML = "<p class=\"himessage\">"+
		"You have chosen to remove this class. This will not be possible if there "+
		"are any papers still attached to the class. If you receive this error "+
		"please ensure that the corresponding papers that have caused the "+
		"failure have their class changed to another. Please <a "+
		"href=\"#\" onclick=\"removeClass("+classID+");return false;\""+
		">Confirm</a> or <a href=\"#\" onclick=\"clearMessageDisplayBox();"+
		"return false;\">Cancel</a> this action.</p>";
}

function addClass()
{
	document.getElementById('messageDisplayBox').innerHTML = "[Adding class...]";
	xmlHttp = new GetXmlHttpObject();
	classDesc = escape(document.getElementById('classDesc').value);
	if (classDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a class description";
	}
	else
	{
		url = "/includes/ajax/categories/addclass.asp?classDesc="+classDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','classDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

/* Functions for administrating paper types */

var typeDesc;

function updateType(typeID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Updating type...]";
	xmlHttp = new GetXmlHttpObject();
	typeDesc = escape(document.getElementById('typeDesc'+typeID).value);
	if (typeDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a type description";
	}
	else
	{
		url = "/includes/ajax/categories/updatetype.asp?typeID="+typeID+
			"&typeDesc="+typeDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','typeDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function removeType(typeID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Removing type...]";
	xmlHttp = new GetXmlHttpObject();
	url = "/includes/ajax/categories/removetype.asp?typeID="+typeID+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','typeDisplayBox');};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function removeTypePrompt(typeID)
{
	document.getElementById('messageDisplayBox').innerHTML = "<p class=\"himessage\">"+
		"You have chosen to remove this type. This will not be possible if there "+
		"are any papers still attached to the type. If you receive this error "+
		"please ensure that the corresponding papers that have caused the "+
		"failure have their type changed to another. Please <a "+
		"href=\"#\" onclick=\"removeType("+typeID+");return false;\""+
		">Confirm</a> or <a href=\"#\" onclick=\"clearMessageDisplayBox();"+
		"return false;\">Cancel</a> this action.</p>";
}

function addType()
{
	document.getElementById('messageDisplayBox').innerHTML = "[Adding type...]";
	xmlHttp = new GetXmlHttpObject();
	typeDesc = escape(document.getElementById('typeDesc').value);
	if (typeDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a type description";
	}
	else
	{
		url = "/includes/ajax/categories/addtype.asp?typeDesc="+typeDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','typeDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

/* Functions for administrating paper reviewal processes */

var reviewalDesc;

function updateReviewal(reviewalID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Updating reviewal process...]";
	xmlHttp = new GetXmlHttpObject();
	reviewalDesc = escape(document.getElementById('reviewalDesc'+reviewalID).value);
	if (reviewalDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a revieawl process description";
	}
	else
	{
		url = "/includes/ajax/categories/updatereviewal.asp?reviewalID="+reviewalID+
			"&reviewalDesc="+reviewalDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','reviewalDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function removeReviewal(reviewalID)
{
	document.getElementById('messageDisplayBox').innerHTML = "[Removing reviewal process...]";
	xmlHttp = new GetXmlHttpObject();
	url = "/includes/ajax/categories/removereviewal.asp?reviewalID="+reviewalID+"&sid="+Math.random();
	xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','reviewalDisplayBox');};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function removeReviewalPrompt(reviewalID)
{
	document.getElementById('messageDisplayBox').innerHTML = "<p class=\"himessage\">"+
		"You have chosen to remove this reviewal process. This will not be possible "+
		"if there are any papers still attached to the reviewal process. If you receive "+
		"this error please ensure that the corresponding papers that have caused the "+
		"failure have their revieawl process changed to another. Please <a "+
		"href=\"#\" onclick=\"removeReviewal("+reviewalID+");return false;\""+
		">Confirm</a> or <a href=\"#\" onclick=\"clearMessageDisplayBox();"+
		"return false;\">Cancel</a> this action.</p>";
}

function addReviewal()
{
	document.getElementById('messageDisplayBox').innerHTML = "[Adding reviewal process...]";
	xmlHttp = new GetXmlHttpObject();
	reviewalDesc = escape(document.getElementById('reviewalDesc').value);
	if (reviewalDesc.length === 0)
	{
		document.getElementById('messageDisplayBox').innerHTML = "Please enter a reviewal process description";
	}
	else
	{
		url = "/includes/ajax/categories/addreviewal.asp?reviewalDesc="+reviewalDesc+"&sid="+Math.random();
		xmlHttp.onreadystatechange = function(){xmlHttpResponse('messageDisplayBox','','reviewalDisplayBox');};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

// -->