	var SimpleExternalRequest = function(targetElementId, url, method, parameters, completeFunction) {
        var targetElement = $(targetElementId);
        if (targetElement == null) {
            throw 'Target element is null!';
        }
        if (url == null) {
            throw 'URL has to be provided';
        }
        if (method == null) {
            method = 'get';
        } else if (method != 'get' && method != 'post') {
            throw 'Method should be get or post'; 
        }

        if(!completeFunction)
        	completeFunction = compFunc;
        
        var myAjax = new Ajax.Updater(
            { success: targetElement }, 
            url, 
            { 
                method: method,
                parameters: parameters, 
                onFailure: errFunc,
                onComplete:completeFunction,
                evalScripts: true
            });
    };
    

    
    
	var SimpleRequest = function(targetElementId, url, method, parameters, completeFunction) {
        var targetElement = $(targetElementId);
        if (targetElement == null) {
            throw 'Target element is null!';
        }
        if (url == null) {
            throw 'URL has to be provided';
        }
        if (method == null) {
            method = 'get';
        } else if (method != 'get' && method != 'post') {
            throw 'Method should be get or post'; 
        }

        Maple.removeTinyMCEEditors(targetElement);

        if(completeFunction == null)
        	completeFunction = compFunc;
        
        if(parameters != null && parameters.length > 0)
        {
        	parameters += "&";
        }
        if(parameters)
        	parameters += "_ajurl_="+url;
        else
        	parameters = "_ajurl_="+url;
        url = "/pub/ajaxUser.jsp";	

        var myAjax = new Ajax.Updater(
            { success: targetElement }, 
            url, 
            { 
                method: method,
                parameters: parameters, 
                onFailure: errFunc,
                onComplete:completeFunction,
                evalScripts: true
            });
    };

 	var SimpleRequestNoProcess = function(url, method, parameters, completeFunction) {
        if (url == null) {
            throw 'URL has to be provided';
        }
        if (method == null) {
            method = 'get';
        } else if (method != 'get' && method != 'post') {
            throw 'Method should be get or post'; 
        }
        
        
        if(completeFunction == null)
        	completeFunction = compFunc;

        var myAjax = new Ajax.Updater(
            { success: null }, 
            url, 
            { 
                method: method,
                parameters: parameters, 
                onFailure: errFunc,
                onComplete:completeFunction,
                evalScripts: false
            });
    };   
    
    function formRequest(formElementId) {
		Event.observe(formElementId, 'submit', handleSubmitEvent, true);
    }
    
handleSubmitEvent =     function (event,completeFunction) {
    	var formElement = Event.element(event);
        if (formElement.tagName.toLowerCase() != 'form') {
            throw 'Element ' + formElement + ' is not a FORM element!';
        }
        
	Maple.removeTinyMCEEditors(formElement.parentNode);        
        var method = formElement.method;
        if (method == null) {
            method = 'get';
        }
        var url = formElement.action;
         if (url == null) {
        	throw 'No action defined on ' + formElement;
        }
        
             if(completeFunction == null)
        	completeFunction = compFunc;
 
        try {
         	Event.stop(event);
			var myRequest = new Ajax.Updater(
				{ success: formElement.parentNode }, 
				url, 
				{ 
					method: method, 
					parameters: Form.serialize(formElement),
					evalScripts: true,
					onFailure: errFunc,
	               onComplete: completeFunction
					
				});
		} finally {
			return false;
		}
    }

    var handlerFunc = function(t) {
    	alert(t.responseText);
	}

	var errFunc = function(t)
	 {
    	if(t.status == '401')
	 	{
	 		alert("Your session has expired, please sign-on again");
	 		window.history.go(0);
	 	}
	 	else if(t.status == '404')
	 	{
	 		alert('404 [' + t.statusText + ']:' + t.responseText);
	 	}
	 	else
	 	{
   			alert('Error ' + t.status + ' -- ' +  t.statusText + "["+t.readyState+"]");
    	}
	}
	
	var compFunc = function(originalRequest) 
	{

	}

