jQuery(document).ready(function($jq) {	
$jq('#newsearch').click(function(){ $jq('#mlname').val('');$jq('#vlist, #accountinfo, #dlist').html(' ');
$jq('#mlname').focus();});
$jq('#mlname').keyup(function(){
if ($jq(this).val().length >= 3){
$jq('#status').show();
var action = $jq('#action').val();
$jq.ajaxSetup({cache: false});
$jq.get("", {ncgmembership: 'ajax-handler', mlname: $jq(this).val(), action: action},function(data){
$jq('#vlist').html(data).show();$jq("#status").hide();
});
return false;
}
else if($jq(this).val().length == 0){
$jq('#status').hide();
$jq('#vlist').html(' ');
}//end zero case
});

});//end of ready function	


function loadAccount(){
jQuery(document).ready(function($jq) {	
$jq('#memberlist > li').click(function(){
$jq.ajaxSetup({cache: false});
$jq.get("", {action:'loadaccount',acct_id:$jq("#acctid", this).val(),ncgmembership:'ajax-handler'},function(data){
$jq('#vlist').html(data).show();
  });
  });//end of click function
});//end of ready function
}//end of loadAccount



function getDetails(){
jQuery(document).ready(function($jq) {	
$jq('.details').toggle(function(){
  $jq(this).parent("td").parent("tr").next().children("td.mdetails").show();$jq(this).text('- Hide Details');
  }, function(){
   $jq(this).parent("td").parent("tr").next().children("td.mdetails").hide();$jq(this).text('+ View Details');
  });
});
}

function showBilling(){
jQuery(document).ready(function($jq) {	
$jq("input[name='aid']").click(function(){
var acct_id = $jq(this).val();
$jq.ajaxSetup({cache: false});
$jq.get("", {ncgmembership: 'ajax-handler', acct_id: acct_id, action: 'billing'},function(data){
$jq('#dlist').html(data).show();
});
});

});//end of doc.ready

}//end of showBilling

function addBill(){
jQuery(document).ready(function($jq) {	
$jq("#newbill").submit(function(){
var str = $jq("#newbill").serialize();
str +="&action=addbill&ncgmembership=ajax-handler";
$jq.ajaxSetup({cache: false});
$jq.get("", str,function(data){
$jq('#dlist').html(data).show();
});

return false;
});

//make the records inline editable
$jq('.edit').editable(' ',{
  cancel: 'Cancel',
  submit: 'OK',
  indicator: 'saving...',
  tooltip: 'Click to edit',
  submitdata: { ncgmembership: "ajax-handler", action: "editbill"}
  });

//add the inline delete functionality
$jq('.deleterow').click(function(){
  var row =$jq(this).val();
  //make them confirm
  var answer = confirm("Are you sure you want to delete it?");
  if(answer){
  //do the delete
  $jq.ajaxSetup({cache: false});
  $jq.get("",{ncgmembership: 'ajax-handler', bid: row, action: 'deletebill'},function(data){
  return(data);
  });
  $jq('#'+row).remove();
  }
  });//end of inline delete
  
});//end of doc.ready

}//end of addbill