The sample has two errors...
1. Change this line
link.href="/image-search/v1/javascript:imageSearch.gotoPage("+i+');';
to this
link.href="javascript:imageSearch.gotoPage("+i+');';
2. Change this line
newImg.src="/image-search/v1/result.tbUrl;"
to this
newImg.src=result.tbUrl;