var req;
var async = true;
function AjaxRequest(url, handler) {
	if (handler == null) {
		async = false;
	}
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        if (handler != null) {
	        req.onreadystatechange = handler;
	    }
        req.open("GET", url, async);
        req.send(null);

    } else if (window.ActiveXObject) {

        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
	        if (handler != null) {
            	req.onreadystatechange = handler;
            }
            req.open("GET", url, async);
            req.send("");
        }
    }
}

function createQuery(form) {
    var elements = form.elements;
    var pairs = new Array();

    for (var i = 0; i < elements.length; i++) {

        if ((name = elements[i].name) && (value = elements[i].value) && (tagname = elements[i].tagName) && (type = elements[i].type)){
            name = encodeURIComponent(name);
            value = encodeURIComponent(value);
            if (tagname=="INPUT"){
	            if (type=="text"){
	            	pairs.push(name + "=" + value);
	            }
	            if (type=="checkbox"){
	            	if (elements[i].checked){
	            		pairs.push(name + "=" + value);            	
	            	}else{
	 					pairs.push(name + "=");           	
	            	}
				}
				if (type=="radio"){
	            	if (elements[i].checked){
	            		pairs.push(name + "=" + value);        	
	            	}
				}
				if (type=="hidden"){
	            	pairs.push(name + "=" + value);
	            }
	            if (type=="password"){
	            	pairs.push(name + "=" + value);
	            }
    		}
    		if (tagname=="SELECT"){
    			val = elements[i].options[elements[i].selectedIndex].value;
    			val = encodeURIComponent(val);
    			pairs.push(name + "=" + val);
    		}
    	}
    }

    return pairs.join("&");
}