

function m5_request(params, onload, onexception){
	this.request;
	this.params = params;
	this.onload = onload;
	this.onexception = onexception;
	this.create = m5_create_ajax_request;
	this.processRequest = m5_ajax_process_request;
	this.get = m5_ajax_get;
	this.post = m5_ajax_post;
	this.create();
	
	
	var req = this.request;
	
	function m5_ajax_process_request(){
		if(req.readyState == 4){
	        if(req.status == 200){
                
	        	eval(onload+'(req)');
                var s = req.responseText;
                while(s.indexOf("<script>") != -1){
                    start = s.indexOf("<script>");    
                    end = s.indexOf("</script>");
                    script = s.substring(start+8,end);
                    if(script.length > 5)eval(script);
                    s = s.substring(end+21,s.length);
                    
                }
	        }else{
	        	eval(onexception+'(req)');
	        }
		}
	}
	
}

function m5_create_ajax_request() {
    if (window.XMLHttpRequest) {
        this.request = new XMLHttpRequest();
        this.request.onreadystatechange = this.processRequest;
    }else if(window.ActiveXObject){
        this.request = new ActiveXObject("Microsoft.XMLHTTP");
        if(this.request)
            this.request.onreadystatechange = this.processRequest;
    }
}

function m5_ajax_get(url){
	if(this.request){
		if (window.XMLHttpRequest) {
			this.request.open("GET", url+'&request_mode=ajax', true);
	        this.request.send(null);
		}else if(window.ActiveXObject){
			this.request.open("GET", url+'&request_mode=ajax', true);
	        this.request.send();
		}	
	}else return false;
}

function m5_ajax_post(url, data){
	alert('Not working yet');
	return false;
}

function arrayIndexOf(array, value){
	for(var i = 0; i < array.length; i++)
		if(array[i] == value) return i;
	return -1;	
}


function create_dataset_window(dataset_name){
//	alert(dataset_name+'_relation');
	var win = _o(dataset_name+'_relation');
	alert(win)
	win.style.position = 'absolute';
	win.style.top = '100px';
	win.style.left = '100px';
	
}
