



function CGeneric(oName)
{
	this.oName=oName;
	
	this.CreateXMLHttpRequestObject=CGeneric_CreateXMLHttpRequestObject;
	this.PostWithAjax=CGeneric_PostWithAjax;
	this.AjaxCallback=CGeneric_AjaxCallback;
}

//
function CGeneric_PostWithAjax(f,callbackName)
{
	//	Grab all form elements and turn them into a serialized string
	var formData='';
	for(var a=0;a<f.elements.length;a++){
		var element=f.elements[a];
		if(element.name!=''){
			formData+="&"+element.name+"="+escape(element.value);
		}
	}
	formData=formData.substr(1);
	
	//
	var http=this.CreateXMLHttpRequestObject();
	if(!http){
		return false;
	}
	
	//
	http.open("POST",f.action,true);
	
	//	Use a trick to keep us inside our object
	toEval="http.onreadystatechange=function(){"+this.oName+".AjaxCallback(http,'"+callbackName+"');}";
	eval(toEval);
	
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", formData.length);
	http.setRequestHeader("Connection", "close");
	
	http.send(formData);
	
	return true;
}

//
function CGeneric_CreateXMLHttpRequestObject()
{
	var req;
	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest){
		req = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		req = new ActiveXObject( "Microsoft.XMLHTTP" );
	}
	else{
		alert("Error: Your browser doesn't seem to support our type of AJAX object. Please notify the admins.");
		return false;
	}
	
	return req;
}

//
function CGeneric_AjaxCallback(http,callbackName)
{
	if(http.readyState==4){
		if(http.status == 200 ){
			eval(callbackName+"(http.responseText);");
		}
	}
	
	return true;
}










