// Changes a products image based on the location of the full size one in the alt tag of the thumbnail
// A JQuery conflict safe version, $ is replaced with document.id
// -----------
// By: David Rugendyke
// Ver: 0.1
window.addEvent('domready', function() {
	
	
	
	});

function imageSwap() {
	
	var mainThumb = document.id('thumbImage').getElement('img');
	var mainThumbHref = document.id('thumbImage').getElement('a');
	
	var count = 0;
	
	$$('.thumbImage').each(function(el) {
		
		var imageEl = document.id(el).getElement('img');
		var imagePath = imageEl.get('alt');
		// Create some new zoom settings
		var zoomHref = imagePath.replace('&w=268&h=700', '&w=600&h=900');
			
		el.addEvent('click', function() {
				mainThumbHref.set('href', zoomHref);
				mainThumb.set('src', imagePath);
		});
		
		count++;
					
	});	
}

// The variation method requires a dynamic image too through a diff manner
function imageSwapVariation(thumbUrl) {
	
	if(document.id('thumbImage')) {
	
		var mainThumb = document.id('thumbImage').getElement('img');
		var mainThumbHref = document.id('thumbImage').getElement('a');
		
		var zoomHref = thumbUrl.replace('product_images', 'showImage.php?resize=true&w=600&h=900&file=product_images');
		var imagePath = thumbUrl.replace('product_images', 'showImage.php?resize=true&w=268&h=700&file=product_images');
		
		mainThumbHref.set('href', zoomHref);
		mainThumb.set('src', imagePath);
	
	}
	
}

