/*
Look at the bottom of the file for the jquery magic. 
*/


Product.NewZoom = Class.create();
/**
 * Image zoom control
 *
 * @author Magento Core Team <core@magentocommerce.com>
 */
Product.NewZoom.prototype = {
 initialize: function(imageEl){
 	this.containerEl = $(imageEl).parentNode;
 	this.imageEl = $(imageEl);
 
 	this.imageEl.hide();
 	this.imageEl.removeClassName('prd_img_hdn'); 
	//for triggering onload event
	var evt = document.createEvent("HTMLEvents");
  	evt.initEvent("load", false, false);
	this.containerEl.dispatchEvent(evt);
 
 	Event.observe(this.imageEl, 'load', this.onImageLoad.bind(this));
 
 	Effect.Appear(this.imageEl, {duration: 0.450}); 
 },

 onImageLoad: function() {
    this.imageEl.hide();
    this.imageEl.removeClassName('prd_img_hdn');
    Effect.Appear(this.imageEl, {duration: 0.350});    
  }
}




jQuery(function(){
	 jQuery('.thumbnail').bind('click',function(){
		var new_img = jQuery(this).attr('href');
		var jqImg = jQuery('#image');
		if (jqImg.attr('src') != new_img) {
		    //jqImg.addClass('prd_img_hdn');
            var shrinkedImg=new_img.replace(/full/i,"image/343x400");;
            
            if(shrinkedImg){
                jqImg.attr('src',shrinkedImg);
            }
		    
		    var jqImgAnc=jQuery('#imageAnchor');
		    if(jqImgAnc){
		    	jqImgAnc.attr('href',new_img);
		    }
		    jQuery('#track_hint a').attr('href',new_img);
		}
		return false
	});
	jQuery('.fancybox').fancybox();
});



