Your javascript for your link has attributes missing
NOW:
onclick="w(
'.$newwidth.','.$newheight.'
SHOULD BE:
onclick="window.open(
width='.$newwidth.',height='.$newheight.'
View help here
Also, you should not mix single quotes with your PHP and the javascript.
Use the following:
$image = $homes['images'][$images];
echo "<a href=\"#\" onClick=\"window.open('$directory/$image','','width=$newwidth,height=$newheight,resizable,top=0,left=0');\"><img src=\"$directory/$image\" border=\"0\" width=\"100\" height=\"100\"></a>";