// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject();
var sxmlHttp = createXmlHttpRequestObject();

// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject()
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)

    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}
// make asynchronous HTTP request using the XMLHttpRequest object
function processDetail(ID,cate_id,Album_id)
{
  // proceed only if the xmlHttp object isn't busy
  if (sxmlHttp.readyState == 4 || sxmlHttp.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    	name = "ID=" + ID;	
	//if (cate_id != "-1"){
		name += "&cate_id="+ cate_id;	
	//}
	//if (Album_id != "-1"){
		name += "&album_id=" + Album_id;	
	//}
	//alert(name);
    // execute the quickstart.php page from the server   
    //sxmlHttp.open("GET", "quickstart.php?ID=" +  name +"&cate_id="+ cate_id + "&album_id=" +Album_id , true);
	sxmlHttp.open("GET", "quickstart.php?" +  name, true);
   // define the method to handle server responses
    sxmlHttp.onreadystatechange = handleServerResponseDetail;
    // make the server request
    sxmlHttp.send(null);
  }
  else
    // if the connection is busy, try again after one second
    setTimeout('processDetail(ID)', 1000);
}

function strRep(){ 
var text="not java |||||"; 
var txt2=text.replace(/|||||/,"&"); 
} 


// executed automatically when a message is received from the server
function handleServerResponseDetail()
{
  // move forward only if the transaction has completed
  if (sxmlHttp.readyState == 4)
  {
    // status of 200 indicates the transaction completed successfully
    if (sxmlHttp.status == 200)
    {
      // extract the XML retrieved from the server
      xmlResponse = sxmlHttp.responseXML;
	 // responseXml = xmlHttp.responseXML;
      // obtain the document element (the root element) of the XML structure
      xmlDoc = xmlResponse.documentElement;      
      var Message="";
	    var zoom="";
	  var fieldID,sizeID;
	
	 // xmlDoc = responseXml.documentElement;  	
 	 fieldID = xmlDoc.getElementsByTagName("fieldid")[0].firstChild.data;
	 sizeID = xmlDoc.getElementsByTagName("size")[0].firstChild.data;
	 sizeID1 = xmlDoc.getElementsByTagName("sizeh")[0].firstChild.data;
	 //title = xmlDoc.getElementsByTagName("title")[0].firstChild.data;
	 //full_desc = xmlDoc.getElementsByTagName("desc")[0].firstChild.data;
	  // alert(sizeID);
	 //Message = Message + fieldID;
	 //alert(fieldID);
	//var fieldID = 'hinhdep010.jpg';
 	var  hinh= '<img src="images/albums/'+ fieldID +'" width="'+ sizeID + '" height="'+ sizeID1 +'" border="0">';
	 //alert(hinh);
	 if(sizeID > 400){
	  //zoom= zoom + '<a href="#" onClick="dv.showDV(hinh)">';	  
	 //zoom= zoom + '<a href="#" onClick="show()">';	  
 	  //zoom= zoom + '<img src="images/icon_zoomin.jpg" width="50" height="50" border="0" alt="Click here to see large image">';
	  //zoom= zoom + '</a>'; 
	 
	 }
	 //Message= Message + "<img src=images/albums/" + fieldID + " width=326 title='header=["+ title +"] body=["+ full_desc +"] delay=[400] fade=[on]'>"; 	
	 Message= Message + "<img src=images/albums/" + fieldID + " width=326 delay=[400] fade=[on]'>"; 	
	 //}
      // update the client display using the data received from the server
	 //alert(hinh);
	 document.getElementById("tung").innerHTML = hinh;   
	  document.getElementById("BodyNews").innerHTML = Message;   
      //document.getElementById("BodyNews1").innerHTML =  zoom;      
    }
    // a HTTP status different than 200 signals an error
    else
    {
      alert("Dieu khien tu Server bi loi roi: " + sxmlHttp.statusText);
    }
  }
}