
function loadImages(q,p)
{
if(typeof(p)!="undefined")
{ var li_count = $(".images-list div ul li").length;
  $.ajax({
  type: "GET",
  url: "ajax.php",
  data: "q="+q+"&p="+p+"",
  success: function(msg){
    if(msg == "end")
    {
      if(li_count == 0)
       {
       $(".images-list div").html("Your search did not match any updates.");
       }

      $("#loadmore").html("End.");
      return false;

    }
    $(".images-list div ul").append(msg);

  }
});
}
else {
return false;
}
}


$(document).ready(function(){
 $("#loadmore").live("click",function(){
  $(this).html("searching...");
  var q = $("#query").val();
  var p = $("#page").val();
  $("#query").remove();
  $("#page").remove();
  loadImages(q,p);
 })

 $("#loadmore").ajaxStart(function(){
  $(this).html("searching...");
 });
  $("#loadmore").ajaxComplete(function(){
  $(this).html("Load More");
 });

})
