if (typeof(jQuery)!='undefined'){
  $(document).ready(function() {
    //alert('jq');
    $('#frmSearch').ajaxForm({
      dataType:'json',
      success:function(result) {
        //alert('success');
        //alert(result.debug);
        doSearchCallback(result); 
      },
      error:function(result, msg) {
        alert(result.responseText);
        alert("AjaxSearchFailed: ".msg);
      }
    });
  })
  function doSearchCallback(result) {
    //alert('response: '+result.success);
    $("#divResultCount").html("Found "+result.count+" matches:");
    $("#divSearchResult").html(result.html);
    $("#divSearchResult").show();
    $("#divResultCount").show();
    //alert(result.tblData);
    //$("#tblSearchResult2").dataTable({"aData":result.tblData});
    $("#divFeatured").hide();
    localAdjustLayout();
  }
  
  function localAdjustLayout() {
    var cHeight=$("#tblSearchResult").height();
    var frmHeight=$("#divSearchForm").height();
    var fHeight=$("#page_footer").height();
    var featHeight=$("#divFeatured").height;
    $("#main_content").height((cHeight+frmHeight+featHeight+fHeight)+'px');
    //$("#main_content").height((cHeight+frmHeight+fHeight)+'px');
    adjustLayout();
  }
  function doFormSubmit(frmId) {
    //alert(frmId);
    //return false;
    return true;
  }
  function doFormClear(frmId) {
    $('#frmSearch').clearForm();
    $("#divSearchResult").hide();
    $("#divResultCount").hide();
    $("#divFeatured").show();
    localAdjustLayout();
    //alert(frmId);
    //return false;
    return true;
  }
} // if jquery
