var elLargeViewer    = null;
var elLargeViewerPrint    = null;
var arrThumbnailList = [];
var photoIndex       = 0;

var display_large_from_thumb_url = function(url) {
	url = url.replace(/id=/, 'idl=');
	elLargeViewer.style.backgroundImage = url;

	url = url.substr(4, url.length-5);
	elLargeViewerPrint.src = url;
}


var display_next_large_photo = function(el) {
	if( el && el.blur ) {
		el.blur();
	}

	if ( arrThumbnailList && arrThumbnailList.length  && arrThumbnailList.length > 0 ) {
		++photoIndex;

		if ( photoIndex >= arrThumbnailList.length ) {
			photoIndex = 0;
		}

		arrThumbnailList[photoIndex].onclick();

		//display_large_from_thumb_url(arrThumbnailList[photoIndex].style.backgroundImage);
	}
}

var display_prev_large_photo = function(el) {
	if( el && el.blur ) {
		el.blur();
	}

	if ( arrThumbnailList && arrThumbnailList.length  && arrThumbnailList.length > 0 ) {
		--photoIndex;

		if ( photoIndex < 0 ) {
			photoIndex = arrThumbnailList.length-1;
		}

		arrThumbnailList[photoIndex].onclick();

		//display_large_from_thumb_url(arrThumbnailList[photoIndex].style.backgroundImage);
	}
}

window.onload = function() {
	arrThumbnailList = $$('#right-column ul li a');

	elLargeViewer = $('house-viewer');
	elLargeViewerPrint = $('house-viewer-print');
}


