I guess what you are trying to do is when you click on a large image, it will have a thumbnail URL
Give this href id
<a href="" id="img_href"><?php echo $_helper->productAttribute($_product, $_img, 'image'); ?></a>
Do you use jquery or prototype (if it is magento by default)
Prototype
$('img_href').setAttribute('href', this.href); //$('img_href').href = this.href; // or
JQuery
$("#img_href").attr("href", this.href);
Plain javascript
document.getElementById ('img_href'). href = this.href;
Update onclick thumbnail
onclick="$('image').src = this.href; $('img_href').setAttribute('href', this.href); return false;"
source share