// JavaScript Document
var path="/hoathinh.com.vn/";
var xmlhttpProduct;
var xmlhttpOtherProduct;

            function getxmlhttpobject()
                {
                    var xmlhttp=null;
                    try{
                        //Firefox, Opera 8.0+, Safari
                        xmlhttp = new XMLHttpRequest();
                        }    
                        catch(e){
                            try{
                                //IE 5.5 +
                                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                                }
                                catch(e){                        
                                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");                            
                                }
                            }
                            return xmlhttp;
                    }
					           
/*-------------------------------------------------------------------------------------------------------------------------------*/			function stateChanged()
{
      if(xmlhttpProduct.readyState==3)        
      {
          document.getElementById('resultProductHome').innerHTML='<img src="'+path+'images/loading2.gif" width=20 />'+'<span>Đang tải dữ liệu</span>';
      }
      if(xmlhttpProduct.readyState==4)        
      {
          document.getElementById('resultProductHome').innerHTML=xmlhttpProduct.responseText;
      }
}
function listProductHome(id,page)
{
    var url= path+"listProductHome.php";
					
	xmlhttpProduct=getxmlhttpobject();
    if(xmlhttpProduct==null){
          alert("Trinh duyet cua ban khong ho tro ajax!");
          return false;
    }             
    url=url+"?id="+id+"&page="+page;
	//	alert(url);
    xmlhttpProduct.onreadystatechange=stateChanged; 
    xmlhttpProduct.open("GET",url,true);
    xmlhttpProduct.send(null);//goi du lieu 
}   
/*-------------------------------------------------------------------------------------------------------------------------------*/		

/*-------------------------------------------------------------------------------------------------------------------------------*/
function isEmail(emailstr)
{
	dotchar = emailstr.indexOf('.');
	atchar = emailstr.indexOf('@');
	dotlast = emailstr.lastIndexOf('.');
	spacechar = emailstr.indexOf(' ');
	len = emailstr.length;
	if( (dotchar == -1) || (atchar == -1) || (spacechar != -1) || (dotlast < atchar) || (dotlast == len - 1))
	{
		return false;
	}
	else
	{
		return true;
	}
}
/*-------------------------------------------------------------------------------------------------------------------------------*/
function fOtherProduct(id,cat,page)
{
	var url= path+"listOrtherProductHome.php";
					
	xmlhttpOtherProduct=getxmlhttpobject();
    if(xmlhttpOtherProduct==null){
          alert("Trinh duyet cua ban khong ho tro ajax!");
          return false;
    }             
    url=url+"?id="+id+"&cat="+cat+"&page="+page;
	//	alert(url);
    xmlhttpOtherProduct.onreadystatechange=stateChanged_otherproduct; 
    xmlhttpOtherProduct.open("GET",url,true);
    xmlhttpOtherProduct.send(null);//goi du lieu 	
}
function stateChanged_otherproduct()
{
      if(xmlhttpOtherProduct.readyState==3)        
      {
          document.getElementById('ortherproduct').innerHTML='<img src="'+path+'images/loading2.gif" width=20 />'+'<span>Đang tải dữ liệu</span>';
      }
      if(xmlhttpOtherProduct.readyState==4)        
      {
          document.getElementById('ortherproduct').innerHTML=xmlhttpOtherProduct.responseText;
      }
}
/*-------------------------------------------------------------------------------------------------------------------------------*/

