change it as the following
function main()
{
PageMethods.custref(ddlpf.options[ddlpf.selectedIndex].value,custref1.value,custSuc,custErr);
function custSuc(boo)
{
if(boo==true)
{message("Cust ref already exists");btn_enable(false);make_null();return;}
Pagemethods.set("true",suc,err);
function suc(res){//code}
function err(){}
}
function custErr(){}
}