


function prepareImageSwap(){
	if(checkDOM()){
		if(!document.getElementById('product_images')) return false;
		
		var prodContainer = document.getElementById('product_images');
		var thumbs = prodContainer.getElementsByTagName('img');
		
		for(var i=0;i<thumbs.length;i++){
			if(i>0){
				thumbs[i].onclick = function(){
					var src = this.getAttribute('src');
					
					src = src.replace(/thumbs/, 'large');

					thumbs[0].setAttribute('src', src);
				}
			}
		}
	}
	return true;
}





function checkDOM(){
var DOMCompatable=true;
	if (!document.getElementById){
		DOMCompatable= false; 
	}

	if (!document.getElementsByTagName){
		DOMCompatable=false;
	}
	
 return DOMCompatable; 
 	
}


function addLoadEvent(func) {
	//acknowledged use from DOM Scripting by J Keith
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(prepareImageSwap);