if (!window.XMLHttpRequest) 
{ 
    window.XMLHttpRequest = function() 
    { 
        var types = [ 
            'Microsoft.XMLHTTP', 
            'MSXML2.XMLHTTP.5.0', 
            'MSXML2.XMLHTTP.4.0', 
            'MSXML2.XMLHTTP.3.0', 
            'MSXML2.XMLHTTP' 
        ]; 

        for (var i = 0; i < types.length; i++) 
        { 
            try 
            { 
                return new ActiveXObject(types[i]); 
            } 
            catch(e) {} 
        } 

        return undefined; 
    } 
}


function cRequest(){
	
	this.sArgs	= '';
	this.sUrl	= '';
	this.sType	= 'GET';
	var xmlhttp	= new XMLHttpRequest(); 
	
	
	this.addArgument = function (name, value){
		
		this.sArgs += escape(name) + '=' + escape(value) + '&';
	};
	this.clearArguments = function(){
		this.sArgs = '';
	};
	this.getContent = function(){
				
		if (this.sType.toUpperCase() == 'POST'){
			xmlhttp.open('POST', this.sUrl, false);
			xmlhttp.setRequestHeader('Content-type',	'application/x-www-form-urlencoded');	
			xmlhttp.setRequestHeader('Content-length',	this.sArgs.length);	
			xmlhttp.setRequestHeader('Connection',		'close');	
			xmlhttp.send(this.sArgs);
		} else {					
			var seperator = '?';
			if (this.sUrl.indexOf('?') > 0){
				seperator = '&';
			}
			xmlhttp.open('GET', this.sUrl + seperator + this.sArgs, false);
			xmlhttp.send(null);			
		}
		this.clearArguments();
		return xmlhttp;
	};
	
	
	this.sendForm = function(oForm){

		this.sUrl 	= oForm.action;
		this.sType	= oForm.method;

		var aInputs  = oForm.getElementsByTagName('input');	
		var i = aInputs.length;
		while (i--){
			if (aInputs[i].type == 'checkbox' || aInputs[i].type == 'radio'){
				if (aInputs[i].checked){
					this.addArgument(aInputs[i].name, aInputs[i].value);
				}
			} else {
				this.addArgument(aInputs[i].name, aInputs[i].value);
			}
		}
		var aSelects = oForm.getElementsByTagName('select');
		for (var i = 0; i < aSelects.length; i++){
			for (var j=0; j < aSelects[i].options.length; j++){
				if (aSelects[i].options[j].selected){
					this.addArgument(aSelects[i].name, aSelects[i].options[j].value);
				}
			}
		}
		var aTextareas  = oForm.getElementsByTagName('textarea');	
		var i = aTextareas.length;
		while (i--){
			this.addArgument(aTextareas[i].name, aTextareas[i].value);
		}		
		return this.getContent();		
	};
}
