window.imageReplaceCount = 0;

function imageReplace(show) {
var hasNotRun = 1;
var maxRun = window.imageReplaceURL.length;

//alert(show+ " = "+window.imageReplaceURL[window.imageReplaceCount]);


	while(hasNotRun || (window.imageReplaceURL[window.imageReplaceCount].indexOf('<')!=-1 && maxRun>-1)) {
		if(show=='p') {
			window.imageReplaceCount--;
			if(window.imageReplaceCount<0) { window.imageReplaceCount = window.imageReplaceURL.length-1; }

		} else if(show=='n') {
			window.imageReplaceCount++;
			if(window.imageReplaceCount>=window.imageReplaceURL.length) { window.imageReplaceCount = 0; }
		} else if(show=='f') {
		document.getElementById( window.imageReplaceID).src = window.imageReplaceURL[window.imageReplaceCount]; return;
		}else {
		document.getElementById( window.imageReplaceID).src = window.imageReplaceURL[show]; return;
		}
		hasNotRun = 0; 
		maxRun--;
	}
	document.getElementById( window.imageReplaceID).src = window.imageReplaceURL[window.imageReplaceCount];
}

function imageReplacePerLoad() {
    if (document.images) {
      preload_image_object = new Array();
       var i = 0;
	if(typeof(window.imageReplaceURL) != "undefined") {
       for(i=0; i<window.imageReplaceURL.length; i++) {
		if(window.imageReplaceURL[i].indexOf('<')==-1) {
		         preload_image_object[i] = new Image()
		         preload_image_object[i].src = window.imageReplaceURL[i];
		}
	}
	}
    }
}


function imageReplaceNext() { imageReplace('n'); }
function imageReplacePrevious() { imageReplace('p'); }
function imageReplaceFlipBack() { imageReplace('f'); }




/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}
