function whichButton() {
	var key = null;
	document.onkeyup=function (event) {
		if(!event) {
			event=window.event;
			key = (window.event.keyCode);
		} else {
			key = (event.which);
		}
		
		if (key == 37) {
			// left
			
			goPrevious();
			
		} else if (key == 39) {
			//right
			goNext();
		}
	}
}

function checkImageIndex(){
	try {
		var urlIndex = location.href.split("#")[1];
		if (urlIndex != undefined) {
			indexToShow = urlIndex - 1;
			return indexToShow;
		} else {
			return 0;
		}
	} catch (error) {
		return 0;
	}	
}

function pauseGallery() {
	myGallery.clearTimer();
	isPaused = 1;
}

function goPrevious() {
	myGallery.prevItem();
	pauseGallery();
}

function goNext(){
	myGallery.nextItem(); 
	pauseGallery();
}

function resumeGallery() {
	myGallery.options.timed = true;
	myGallery.prepareTimer();
	myGallery.doSlideShow();
}


function PausePlayGallery() {
	
	if (isPaused == 0) {
		pauseGallery();
	    isPaused = 1;
	} else {
		resumeGallery();
		isPaused = 0;
    }
}