some times .js throws me for a loop (there is one for the PUN contest).

I am trying to programmatically attach function calls to an object onclick event. Everything was fine except when I added the nested array loops. I have used var 'fn' to attempt to create a closure and store the value of 'fool ' at that point in the loop , so fn= foo[k] for all ks. but it always = the last value of foo[k]. I am sure I am missing something horrendously simple but I just cant see it at the moment and a fresh pair of eyes would be greatly appreciated.


Code:
function prepWidg(fix){
			var sel=new Array('.wDel', '.wUp','.wDwn', '.wAdd');
			var foo= new Array('delWidget', 'moveUp', 'moveDwn', 'newWidget');
 			for (k=0,ll=sel.length; k<ll; k++){		 	
			    bType=fix.querySelectorAll(sel[k]);
			    fool=foo[k];
  		 	 	for (i=0,l=bType.length;i<l; i++ ){
			 	 	 bType[i].onclick=function(e){  
			 	 	 	var fn=fool ; // currernt value of 'fool' should be stored  in this onclick funtion but it's nto so :(
			 	 	 	var self=this; 
			 	 	 	alert(fn); 
			 	 	 	master[fn](self); 
			 	 	 	return false; 
			 	 	 }
			 	}
		 	}
 		 	return fix;
		}