function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function ajaxCall(script, parametres, target, callback) {	
	var xhr = createXHR();

	xhr.open("POST", script, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	xhr.send(parametres);
	
	if (target) {
		ajaxLoading(target);
	}
	
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && xhr.status == 200){
			if (target) {
				$(target).innerHTML = xhr.responseText;
			}
			if (callback) {
				eval(callback)
			}
		}
	}
	
}

function ajaxLoading(id) {
	$(id).innerHTML = '<div style="width: 100%; text-align: center;"><img src="_images/design/ajax-loader.gif" alt="Loading..." /></div>';
}
