/** general fixes */
if ( !Array.prototype.push ) {
	Array.prototype.push = function ( item ) {
		this [ this.length ] = item;
		return this.length;
	}
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}
/* end general fixes */

if ( !oGod ) {
	var oGod = new Object();
}

addLoadEvent( function() { oGod.oGallery = new cGallery(); } );

function cGallery() {
	var self = this;
	var oFocus = document.getElementById("product-focus");
	var oFocusImg;
	var oFocusText;
	var oSelector = document.getElementById("product-selector");
	var oThumbs;
	
	if ( oFocus && oSelector ) {
		oThumbs = oSelector.getElementsByTagName("img");
		oFocusImg = document.getElementById("focus-img").getElementsByTagName("img")[0];
		oFocusText = document.getElementById("focus-text");
		
		var oThumb, i = 0;
		while ( oThumb = oThumbs[i++] ) {
			oThumb.onclick = swapFocusImg;
		}
	}
	
	function swapFocusImg() {
		var j = 0;
		while ( this != oThumbs[j] ) {
			j++
		};
		//var sFirstpart = this.src.slice( 0, this.src.indexOf("-tn") );
		//var sLastpart = this.src.slice( this.src.indexOf("-tn") + 3 );
		var sNewFocusImgFilename = this.src.slice( 0, this.src.indexOf("_tn") ) + this.src.slice( this.src.indexOf("_tn") + 3 );
		oFocusImg.src = sNewFocusImgFilename;
		oFocusText.innerHTML = aFocusTexts[j];
	}
}