    // AJAX Search for models
    
    var criteria = "date";
    var start_page = 0;

    var xmlHttp;

    function doAJAXCall(divid, url)
    {   
      xmlHttp=GetXmlHttpObject(eval("stateChanged_"+divid));
      xmlHttp.open("GET", url + "&r=" + Math.random(), true);
      xmlHttp.send(null);
    } 

    function stateChanged_topCocks() 
    { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
      { 
        document.getElementById("topCocks").innerHTML=xmlHttp.responseText;
      } 
    }
    
    function stateChanged_latestTopCocks() 
    { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
      { 
        document.getElementById("latestTopCocks").innerHTML=xmlHttp.responseText;
      } 
    }     

    function stateChanged_recentCocks() 
    { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
      { 
        document.getElementById("recentCocks").innerHTML=xmlHttp.responseText;
      } 
    } 

    function stateChanged_saveFavourite() 
    { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
      { 
        document.getElementById("saveFavourite").innerHTML=xmlHttp.responseText;
      } 
    }
    
    function stateChanged_slideshow() 
    { 
      if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
      { 
        document.getElementById("slideshow").innerHTML=xmlHttp.responseText;
      } 
    }    

    function GetXmlHttpObject(handler)
    { 
      var objXmlHttp=null;

      if (window.XMLHttpRequest) {
        objXmlHttp = new XMLHttpRequest();
        objXmlHttp=new XMLHttpRequest();
        objXmlHttp.onreadystatechange=handler;
        objXmlHttp.onload=handler;
        objXmlHttp.onerror=handler;
        return objXmlHttp;
      }
      else if (window.ActiveXObject) {
        try
        {       
          objXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
          objXmlHttp.onreadystatechange=handler;
          return objXmlHttp;          
        }
        catch(e)
        { 
          alert("Please enable ActiveX on your browser");
          return;
        }         
      }
    }   