function getHTTPObject(){
	var xmlhttp;
	// Attempt to initialize xmlhttp object
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
    catch (e) {
		// Try to use different activex object
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E) {
			xmlhttp = false;
		}
	}
	// If not initialized, create XMLHttpRequest object
	if (!xmlhttp) {
		if (typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		else {
			alert("This browser does not support AJAX.");
			return null;
		}
	}
	return xmlhttp;
}

// Implement business logic
function change_filter(nume,cat_id,filtru,val,selectat){
	httpObject = getHTTPObject();
	if (httpObject != null) {
		loc = '/ajax/categorie_ajax/' + nume + '/' + cat_id + '/0/' + filtru + '/' + val + '/' + selectat;
		httpObject.open("GET", loc, true);
		httpObject.onreadystatechange = showNewProducts;
		httpObject.send(null);
	}
}

function showNewProducts(){
	var products_content = document.getElementById('products_content');
	if(httpObject.readyState == 4){
		products_content.innerHTML = httpObject.responseText;
		document.getElementById('asteapta').innerHTML = '';
	} else {		
		document.getElementById('asteapta').innerHTML = '<div class="mesaj">Va rugam asteptati...</div>';
	}
	
}
