﻿//Created by: Kevin Innes
//Date: 4.6.2007


 var http_request = false; 
 
   function makeRequest() 
   { 
  // document.getElementById('divShow').innerHTML = '<img id="img" src="../images/indicator_waitanim.gif"/>';
       if (window.XMLHttpRequest) {
        
           http_request = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) {
           http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
           //http_request = new ActiveXObject("Microsoft.XMLDOM");
       } 
                  
       var URL = "search.aspx?alpha=" + document.getElementById("alp").value + "&search=" + document.getElementById("txtSearch").value + "&page=" + document.getElementById("num").value  ;
                              
       http_request.onreadystatechange = Process; 
       http_request.open('Get', URL, false); 
	   //http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
       http_request.send(null); 
       
   } 
   
   
 function checkReadyState(_id, _1, _2, _3)
{
  switch(http_request.readyState)
  {
    case 1:
        document.getElementById(_id).innerHTML = '<img id="img" src="../images/indicator_waitanim.gif"/>';
       break;
    case 2:
      document.getElementById(_id).innerHTML = '<img id="img" src="../images/indicator_waitanim.gif"/>';
      break;
    case 3:
      document.getElementById(_id).innerHTML = '<img id="img" src="../images/indicator_waitanim.gif"/>';
      break;
    case 4:
     document.getElementById(_id).innerHTML = ' ';
      return http_request.status;
  } 
}
    
    
   function Process() { 
   
	        if (checkReadyState('divShow', '<img id="img" src="../images/indicator_waitanim.gif"/>', '<img id="img" src="../images/indicator_waitanim.gif"/>', '<img id="img" src="../images/indicator_waitanim.gif"/>') == "200")
                 {
                      var newdiv = document.createElement("div");
              newdiv.innerHTML = http_request.responseText;            
		  var container = document.getElementById("Grid");
              container.innerHTML = "";
          container.appendChild(newdiv);
		                                  
                 }
      }          
   
   
   function a(alpha){
      
   
    
   document.getElementById("alp").value = document.getElementById(alpha).id;
     
    document.getElementById("num").value = 1;
     document.getElementById("txtSearch").value = "";
    
     
   makeRequest();
  
         
     }
     
     
      function n(num){
      
   
    //alert(num);
 
   document.getElementById("num").value = document.getElementById(num).id;
    
   
    document.getElementById("txtSearch").value = "";
    
     
   makeRequest();
  
         
     }
 
   function Search(){
  
    document.getElementById("num").value = 1;
  makeRequest();
  
  }   

