/**
 * Interface for Router
 */
var CRouter = function(map) {

	this.findRoute = function(route) {}
	
	this.createRoute = function(route) {}
	
};

/*s
 * Ajax Implementation
 */	
var RouterRequest = function(url, options) {
	
	this.blankFunction = function(transport) { alert(transport.responseText) };

	this.getTranport = function() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	};
	
	this.request = function(url) {			
		var method = me.options.method;		 
		var async = me.options.async || true;
		
		method = method.toUpperCase();
		method = ((method == "POST") || (method == "GET")) ? method : "GET";
		
		if (method == "GET") {
			url += "?" + me.options.params;
		}		
		
		if(__monitor == undefined || __monitor == null){
        	__monitor = new ActivityMonitor();
        }
        
		if(__monitor){
			__monitor.on();		
		}
		    		
   		me.transport.open(method, url, async);
   	    me.transport.onreadystatechange = me.onStateChange;
   		me.transport.send(me.options.params);

	    // Force Firefox to handle ready state 4 for synchronous requests
	    if (!async) me.onStateChange();					
	};
	
	this.onStateChange = function() {
		if (me.transport.readyState != 4) { return false; }
		if(__monitor){ __monitor.off();}			
		var _function = me.options.callback || me.blankFunction;
		_function(me.transport);					
	};
	
	var me = this;
	this.options = options || {};
	this.transport = me.getTranport();
	this.request(url);	
	
};
