function post(url,id, parameters) {  
http_request = false;  
if (window.XMLHttpRequest) { // Mozilla, Safari,...  
http_request = new XMLHttpRequest();  
if (http_request.overrideMimeType) {  
http_request.overrideMimeType('text/html');  
}  
} else if (window.ActiveXObject) { // IE  
try {  
http_request = new ActiveXObject("Msxml2.XMLHTTP");  
} catch (e) {  
try {  
http_request = new ActiveXObject("Microsoft.XMLHTTP");  
} catch (e) {}  
}  
}  
if (!http_request) {  
alert('Cannot create XMLHTTP instance');  
return false;  
}  
http_request.onreadystatechange = function()  
   {    
   		
      document.getElementById(id).innerHTML = "<center><img src=images/ajax-loader.gif /></center>";
       if (http_request.readyState == 4) {  
       if (http_request.status == 200) {  
       //alert(http_request.responseText); 
	   document.getElementById(id).innerHTML=null;
       result = http_request.responseText;  
       document.getElementById(id).innerHTML = result;
       } else {  
		   if(confirm('Sảy ra lỗi ở trình duyệt.Click OK để refesh')); 
		   {
				window.location.reload(true);			   
		   }
       return false;
       }  
       }  
   }    
http_request.open('POST', url, true);  
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");  
http_request.setRequestHeader("Content-length", parameters.length);  
http_request.setRequestHeader("Connection", "close");  
http_request.send(parameters);  
return true;
}

function loadContent(page){
	//alert("OK");
poststr="data=home";
post('index4.php?page='+page,'hienthi',poststr);
}
function product_new(page){
	//alert("OK");
poststr="data=newproduct";
post('index4.php?page='+page,'show_product_new',poststr);
}

function product_new2(page){
	//alert("OK");
poststr="data=newproduct";
post('index4.php?page='+page,'show_product_new2',poststr);
}

function postContact(page){
poststr="DATA="+ encodeURIComponent(document.getElementById("name").value)+  
" "+ encodeURIComponent(document.getElementById("address").value)+
" "+ encodeURIComponent(document.getElementById("phone").value)+
" "+ encodeURIComponent(document.getElementById("fax").value)+
" "+ encodeURIComponent(document.getElementById("email").value)+
" "+ encodeURIComponent(document.getElementById("noidung").value)
" "+ encodeURIComponent(document.getElementById("mabaove").value);
post('modules/testAjax.php','hienthi',poststr);
}
function loadSubCat(page,giatri){
poststr="cat_pd="+ giatri;
post('loadMenu.php',page,poststr);
}