Your find function will always return null.
$.each(array,function(i,elem){
if(elem.id==param){
return i; //this is each iteration callback scope not find function scope
}
})
The find function should look like this:
function find(param){
var matched=null;
$.each(array,function(i,elem){
if(elem.id==param){
matched=i;
}
})
return matched;
}
Hope this is helpful for you.