﻿function ajax(url, qs, load, method, container, bigload) {
	if (bigload != false)
	{
		try {
			document.getElementById(container).innerHTML = "<div style=\"text-align: center;\"><img src=\"images/loading.gif\" class=\"bigload\" /></div>";
			load = null;
		}
		catch (Error) { }
	}
	try {
		document.getElementById(load).style.visibility = "visible";
	}
	catch (Error) { }
	
	var xmlHttp;
    
    try {  // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();  
    }
    catch (e) {  // Internet Explorer
        try {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX.  You should consider upgrading your browser since this and many other sites use AJAX often.");
            }
        }
    }
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState==4) {
			try {
				document.getElementById(load).style.visibility = "hidden";
			}
			catch(Error) {}
			
			if (xmlHttp.status.toString().substring(1) == "4" || xmlHttp.status.toString().substring(1) == "5")
			{
				alert("There was a problem processing your request.  (Error code " + xmlHttp.status + ")  Please try again later.");
			}
			else
			{	
				if (container != null) {
					document.getElementById(container).innerHTML = xmlHttp.responseText;
				}
			}
			xmlHttp = null;
        }
    }
	if (method == "POST") {
		xmlHttp.open("POST", url, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(qs);
    }
    else {
		xmlHttp.open("GET", url, true);
		xmlHttp.send(null);
    }
}