<!--
var AjaxRequest = function(){
	// Property: id of the element to be updated
	this.id = "";
	// Property: Defines which url should be accessed
	this.url = "";
	// Property: Defines parameters that should be sent
	this.params = "";
    // Property: Defines what function should be excuted at onXXX
	this.Failure = "";
	this.Complete = "";

    // Member variable: Hold instance of this class
    var thisObject;
	this.Update = function(){
		thisObject = this;
		var myAjax = new Ajax.Request(
			thisObject.url,
			{
				method: 'get',
				parameters: thisObject.params,
				onFailure: function(){
					if(thisObject.Failure != ""){
						thisObject.Failure();
					}
				},
				onComplete:  function(r){
					if(thisObject.Complete != ""){
						thisObject.Complete(r);
					}
				}
			}
		);
	}
}

var IdUpdater = function(){
	// Property: id of the element to be updated
	this.id = "";
	// Property: Defines which url should be accessed
	this.url = "";
	// Property: Defines parameters that should be sent
	this.params = "";
    // Property: Defines what function should be excuted at onXXX
	this.Failure = "";
	this.Complete = "";

    // Member variable: Hold instance of this class
    var thisObject;
	this.Update = function(){
		thisObject = this;

		var myAjax = new Ajax.Updater(
			{success: $(thisObject.id)},
			thisObject.url,
			{
				method: 'get',
				parameters: thisObject.params,
				onFailure: function(){
					if(thisObject.Failure != ""){
						thisObject.Failure();
					}
				},
				onComplete:  function(r){
					if(thisObject.Complete != ""){
						thisObject.Complete(r);
					}
				}
			}
		);
	}
}

var PostForm = function(){
	// The HTMLFormElement
	this.TheForm;
	// what additional parameters should be passed
    this.params;
	// Property: Whether the page should scroll to top
	this.Scroll = new Boolean(false);
	// Property: Id of item that was clicked
	this.ClickId = ""
    // Property: Defines what function should be excuted at onXXX
	this.Create = "";
	this.Uninitialized = "";
	this.Loading = "";
	this.Loaded = "";
	this.Interactive = "";
	this.Exception = "";
	this.Failure = "";
	this.Success = "";
	this.Complete = "";
    // Member variable: Hold instance of this class
    var thisObject;
	this.BuildParams = function(aForm, theParams){
		for (var n=0; n < aForm.elements.length; n++) {
			var theElement = aForm.elements[n];
			var someName = theElement.name;
			var someValue = theElement.value;
			
			if (someValue != null)
			{
			 theParams[someName] = someValue;
			}
		}
		return theParams;
	}
	this.Post = function(){
		thisObject = this;
		if(thisObject.TheForm == null || thisObject.TheForm == ""){
			return;
		}
		// this sets the coordinates of the click, if needed
		if(thisObject.ClickId != ""){
			var buttonXVar = thisObject.ClickId + ".x";
			var buttonYVar = thisObject.ClickId + ".y";
			thisObject.params[buttonXVar] = 1;
			thisObject.params[buttonYVar] = 1;
		}
		thisObject.params = thisObject.BuildParams(thisObject.TheForm, thisObject.params);
		var myAjax = new Ajax.Request(
			thisObject.TheForm.action,
			{
				parameters: thisObject.params,
				onCreate: function(){
					if (thisObject.Scroll){
						scroll(0,0);
					}
					if(thisObject.Create != ""){
						thisObject.Create();
					}
				},
				onUninitialized: function(){
					if(thisObject.Uninitialized != ""){
						thisObject.Uninitialized();
					}
				},
				onLoading: function(){
					if(thisObject.Loading != ""){
						thisObject.Loading();
					}
				},
				onLoaded: function(){
					if(thisObject.Loaded != ""){
						thisObject.Loaded();
					}
				},
				onInteractive: function(){
					if(thisObject.Interactive != ""){
						thisObject.Interactive();
					}
				},
				onException: function(){
					if(thisObject.Exception != ""){
						thisObject.Exception();
					}
				},
				onFailure: function(){
					if(thisObject.Failure != ""){
						thisObject.Failure();
					}
				},
				onSuccess: function(r){
					if(thisObject.Success != ""){
						thisObject.Success(r);
					}
				},
				onComplete:  function(r){
					resetForm(thisObject.TheForm);
					if(thisObject.Complete != ""){
						thisObject.Complete(r);
					}
				}
			}
		);
	}
}

// Register global responders that will occur on all AJAX requests
Ajax.Responders.register(
	{
		onCreate: function(request) {
			request['timeoutId'] = window.setTimeout(
				function() {
					// If we have hit the timeout and the AJAX request is active, abort it and let the user know
					if (callInProgress(request.transport)) {
						request.transport.abort();
						// Run the onFailure method if we set one up when creating the AJAX object
						if (request.options['onFailure']) {
							request.options['onFailure'](request.transport, request.json);
						}
					}
				},
				serverTimeoutSecs*1000 // in seconds
			);
		},
		onComplete: function(request) {
			// Clear the timeout, the request completed ok
			window.clearTimeout(request['timeoutId']);
		}
	}
);

function resetForm(theForm){
	// reset text fields
	var inputs = theForm.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++) {
		var input = inputs[i];
		if ((input.type == "text")){
			if(IsNumeric(input.value)){
				input.value = 0;
			} else {
				input.value = "";
			}
		}
	}
	// reset select options
	var theSelects = theForm.getElementsByTagName('select');
	for (i=0;i<theSelects.length;i++){
		for (j=0;j<theSelects[i].options.length;j++){
			if(j == 0){
				theSelects[i].options[j].selected=true;
			} else {
				theSelects[i].options[j].selected=false;
			}
		}
	}
}

function isInnerHTMLEmpty(elementId){
	if($(elementId).innerHTML == ""){
		return true;
	}
	return false;
}

function IsNumeric(strString){
	var strValidChars = "0123456789";
	var strChar;
	var isNumeric = true;
	if (strString.length == 0) return false;
		//  test strString consists of valid characters listed above
		for (z = 0; z < strString.length && isNumeric == true; z++){
		strChar = strString.charAt(z);
		if (strValidChars.indexOf(strChar) == -1){
			isNumeric = false;
		}
	}
	return isNumeric;
}

function timer_tick(){
	if(this.Pause == "" || this.Pause() != true){
	    if(this.Secs-- < 1 && (this.Verify == null || this.Verify() == true)){
		    this.Stop();
		}
	} else if(this.ResetSecs != "") {
		this.Secs = this.ResetSecs;
	}
}

// Declaring class "Timer"
var Timer = function(){
    // Property: Frequency of elapse event of the timer in millisecond
    this.Interval = 1000;
    // Property: How many seconds assigned to timer
    this.Secs = 0;
    // Property: How many seconds assigned to timer after pause
    this.ResetSecs = "";
    // Property: Whether the timer is enable or not
    this.Enable = new Boolean(false);
    // Property: Defines what function should be excuted when the process completes
    this.Finish;
    // Property: Defines what function should be excuted in order to determine
    // whether the timer should be paused or not
    this.Pause = "";
    // verify that something has happened or not
    this.Verify;
    // Event: Timer tick
    this.Tick = timer_tick; // default function
    // Member variable: Hold interval id of the timer
    var timerId = 0;
    // Member variable: Hold instance of this class
    var thisObject;
    // Function: Start the timer
    this.Start = function(){
        this.Enable = new Boolean(true);
        thisObject = this;
        if (thisObject.Enable){
            thisObject.timerId = setInterval(
            function(){
                thisObject.Tick();
            }, thisObject.Interval);
        }
    };
    // Function: Stops the timer
    this.Stop = function(){
    	clearInterval(thisObject.timerId);
    	if(thisObject.Enable == true){
	        thisObject.Enable = new Boolean(false);
	        thisObject.Finish();
        }
    };
};

function callInProgress(xmlhttp) {
	switch (xmlhttp.readyState) {
		case 1: case 2: case 3:
			return true;
			break;
		// Case 4 and 0
		default:
			return false;
			break;
	}
}
-->
