// JavaScript Document
/* get news_home_ajax for home page*/
var xmlHttp;
function GetXmlHttpObject()
{
  var xmlHttp=null;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
  return xmlHttp;
}	 

function showNewsHome(catmain)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="include/news_home_ajax.asp";
url=url+"?catmain="+catmain;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=NewsHomestatuschange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function NewsHomestatuschange(){ 
if (xmlHttp.readyState==3)
{ 
document.getElementById("txtajaxNewsHome").innerHTML="<br><p align='center'><img src='image/loading.gif' border=0'></p>";
}
if (xmlHttp.readyState==4)
{
document.getElementById("txtajaxNewsHome").innerHTML =xmlHttp.responseText;
}
}
/* end get news_home_ajax*/
// lay mot ma code moi 
function getcodest() 
{ 
if (xmlHttp.readyState==3)
{ 
document.getElementById("refesh").innerHTML="Đang tải ...";
}
	if (xmlHttp.readyState==4)
	{ 
	document.formtofriend.code.value=xmlHttp.responseText;
	document.getElementById("refesh").innerHTML="";
	}
}
function getcodsecurity(){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getcodesecurity.asp";
url=url+"?usid="+Math.random();
xmlHttp.onreadystatechange=getcodest;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}	
////////////////////////////////////////////
function uptinchanger(){ 
if (xmlHttp.readyState==4){ 
var restext=xmlHttp.responseText;
	if(restext=="thanhcong"){
		alert("Dothi24h Up tin thành công cho Quý khách");
		location.reload();
		}		
	else if(restext=="thatbai"){
		alert("Làm mới thất bại lý do là\n Hết lần up \n or Server Error");	
		
	}
 }
}

function lammoi(id){
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="/include/up.asp";
url=url+"?id_house="+id;
xmlHttp.onreadystatechange=uptinchanger;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
