The first code is some sort of text highlighting function
The second code is related to captcha. When you click on captcha image, that code loads new captcha image. Plus some additional code for right click protection and popup function when used {thumbnail_openwindow} in thumbnai_bit.html template.