function createRequestObject() { 
	var objXMLHttp=null
	if (window.XMLHttpRequest) {
		objXMLHttp=new XMLHttpRequest()
	} else if (window.ActiveXObject) {
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

var http = createRequestObject();
var the_div_id;

function sndReq(action) {
    http.open('get', action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}




function sndCommentFormReq(f,action,div_id) {
    var str = getFormValues(f,""); 
    action = action + "?" + str;
    http.open('get', action);
    //http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    the_div_id=div_id;
    http.onreadystatechange = handleResponse;
    http.send(null);

} 

function getFormValues(fobj,valFunc) 

{ 



   var str = ""; 

   var valueArr = null; 

   var val = ""; 

   var cmd = ""; 

   for(var i = 0;i < fobj.elements.length;i++) 

   { 

       switch(fobj.elements[i].type) 

       { 

           case "text": 

                if(valFunc) 

                { 

                    //use single quotes for argument so that the value of 

                    //fobj.elements[i].value is treated as a string not a literal 

                    cmd = valFunc + "(" + 'fobj.elements[i].value' + ")"; 

                    val = eval(cmd) ;

                } 

                str += fobj.elements[i].name + 

                 "=" + escape(fobj.elements[i].value) + "&"; 

                 break; 

           case "textarea": 

                if(valFunc) 

                { 

                    //use single quotes for argument so that the value of 

                    //fobj.elements[i].value is treated as a string not a literal 

                    cmd = valFunc + "(" + 'fobj.elements[i].value' + ")"; 
                    val = eval(cmd) ;

                } 

                str += fobj.elements[i].name + 

                 "=" + escape(fobj.elements[i].value) + "&"; 

                 break; 

           case "hidden": 

                if(valFunc) 

                { 

                    //use single quotes for argument so that the value of 

                    //fobj.elements[i].value is treated as a string not a literal 

                    cmd = valFunc + "(" + 'fobj.elements[i].value' + ")"; 

                    val = eval(cmd) ;

                } 

                str += fobj.elements[i].name + 

                 "=" + escape(fobj.elements[i].value) + "&"; 

                 break; 



           case "select-one": 

                str += fobj.elements[i].name + 

                "=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 

                break; 

       } 


   } 

   str = str.substr(0,(str.length - 1)); 

   return str; 

}



function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
            var update = response;
		document.getElementById(the_div_id).innerHTML = update;
	    }
	}

function handleArrayResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();


        if(response.indexOf('|' != -1)) {
            update = response.split('|');
          
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}