function loadurl(dest,task){
	try { // Moz supports XMLHttpRequest. IE uses ActiveX.
	// browser detction is bad. object detection works for any browser
	xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP"); 
	} 
	catch (e) { 
	// browser doesn't support ajax. handle however you want
	} 
	
// the xmlhttp object triggers an event everytime the status changes 
// triggered() function handles the events
switch(task)
	{
	case 'events': xmlhttp.onreadystatechange = do_events; break;
	case 'news': xmlhttp.onreadystatechange = do_events; break;
	case 'book_kcc': xmlhttp.onreadystatechange = do_events; break;
	case 'send_friend': xmlhttp.onreadystatechange = do_friends; break;
	}
// open takes in the HTTP method and url.
xmlhttp.open("GET", dest);

// send the request. if this is a POST request we would have
// sent post variables: send("name=aleem&gender=male)
// Moz is fine with just send(); but
// IE expects a value here, hence we do send(null);
xmlhttp.send(null);

}


function do_events() {
	
	// if the readyState code is 4 (Completed)
	// and http status is 200 (OK) we go ahead and get the responseText
	// other readyState codes:
	// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		
		// xmlhttp.responseText object contains the response.  
		document.getElementById("ajax-loader").style.display = "none";
		document.getElementById("content_events").innerHTML = xmlhttp.responseText;			
		} 
	else if (xmlhttp.readyState == 1){document.getElementById("ajax-loader").style.display = "block";}
}

function do_friends() {
	
	// if the readyState code is 4 (Completed)
	// and http status is 200 (OK) we go ahead and get the responseText
	// other readyState codes:
	// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		
		// xmlhttp.responseText object contains the response.  
		document.getElementById("ajax-loader2").style.display = "none";
		document.getElementById("content_friends").innerHTML = xmlhttp.responseText;			
		} 
	else if (xmlhttp.readyState == 1){
		document.getElementById("content_friends").innerHTML = "";			
		document.getElementById("ajax-loader2").style.display = "block";
	}
}