
function f_ajax(method, url, params, id, toggle) {	
	var xmlHttp;
	var call;
	
	if(window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
		action(xmlHttp);
	}
	else if(window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		action(xmlHttp);
	}	
	function action(xmlHttp) {
		switch(method) {
			case 'get':
			get(xmlHttp);
			break;			
			case 'post':
			post(xmlHttp);
			break;
			default:
			alert('Must be "get" or "post". Yours is: '+method);	
		}
	}
	// Get Method
	function get(xmlHttp) {
		xmlHttp.open("GET", url+"&dummy="+new Date().getTime(), true);
		xmlHttp.send(null);
		fPass(xmlHttp);	
	}
	// Post Method
	function post() {
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", params.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(params);
		fPass(xmlHttp);
	}
	function fPass(xmlHttp) {
		xmlHttp.onreadystatechange=function(){			
			if(xmlHttp.readyState == 4) {
				response = xmlHttp.responseText;				
				switch(toggle) { 					
					case 'html'		 		: inner_html(id, response); fade_in();
					break;					
					
					case 'alert'	 		: alert(response);
					break;	
					
					default			 		: var noaction = 'no action';
				}				
			}			
		}
		
	}	
}








