var currentImgNum=0;
var preloader=new Array();
function preloadListingImages(){
	if (photoArray.length>1) for (var i=0;i<photoArray.length;i++){
		preloader[i]=new Image();
		preloader[i].src=photoArray[i];
	}
}
//depends on addAnEvent function from main.js
addAnEvent(window,'load',preloadListingImages);
function swapNext(){
	if (photoArray.length>1) swapListingImage(1);
}
function swapPrev(){
	if(photoArray.length>1) swapListingImage(-1);
}
function swapListingImage(dir){
	currentImgNum+=dir;
	currentImgNum%=numPhotos;
	if(currentImgNum<0){
		currentImgNum=numPhotos-1;
	}else if (currentImgNum==numPhotos){
		currentImgNum=0;
	}
	if(document.getElementById){
		document.getElementById('homeImg').src=photoArray[currentImgNum];
	}else{
		document.layers['homeImg'].src=photoArray[currentImgNum];
	}
}

function swapListingImageIndex(index){
	if (index<1) {
		index = 1;
	} else if (index > numPhotos) {
		index = numPhotos;
	}
	if(document.getElementById){
		document.getElementById('homeImg').src=photoArray[index];
	}else{
		document.layers['homeImg'].src=photoArray[index];
	}
}

