var imagesize = 1;
var currentimage = 1;
var totalimages = 9;

function nextImage(){
	if(document.getElementById('imagespace')){
		if(currentimage < totalimages){
			currentimage += 1;
		}
		else{
			currentimage = 1;
		}
		
		if(imagesize == 1){
			document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '.jpg" id="randomimagesmall" alt="Random Picture" />';
		}
		else{
			document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '-full.jpg" id="randomimagelarge" alt="Random Picture" />';
		}
	}
}

function previousImage(){
	if(document.getElementById('imagespace')){
		if(currentimage != 1){
			currentimage -= 1;
		}
		else{
			currentimage = totalimages;
		}

		if(imagesize == 1){
			document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '.jpg" id="randomimagesmall" alt="Random Picture" />';
		}
		else{
			document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '-full.jpg" id="randomimagelarge" alt="Random Picture" />';
		}
	}
}

function enlargeImage(){
	if(document.getElementById('imagespace')){
		imagesize = 2;
		document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '-full.jpg" id="randomimagelarge" alt="Random Picture" />';
		
	}
}

function shrinkImage(){
	if(document.getElementById('imagespace')){
		imagesize = 1;
		document.getElementById('imagespace').innerHTML = '<img src="http://www.obviousdiversion.com/images/gallery/' + currentimage + '.jpg" id="randomimagesmall" alt="Random Picture" />';
	}
}