var imagesURLroot = 'portfolio/';
var imagePath = '';




// setupSize - establish viewport size and determine which images to load.
function setupSize() {
	var vpHeight = document.viewport.getHeight();
	var i=0;
	var itHeight = 0;
	while ( vpHeight >= itHeight ) {
		itHeight = imageTypes[i].split('|');
		itHeight = itHeight[2];
		i++;
	}
	i = i-2;

	// special for iphone
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))){
		i=1;
	}

	imgPath = imageTypes[i].split('|');
	imgPath = imgPath[0];
	imgPath = imagesURLroot + imgPath;
	
	return imgPath;
}

function loadImage() {
	$('imageCase').style.backgroundImage="url(" +imagePath +"/" + eval("imgs" +curHash[0] +"[" +curHash[1] +"]") +")";
	$('imageCase').style.display="block";
	// $('imageCase').fade({duration:5});

	// check Nav button colors
	// previous button
	if (parseInt(curHash[1])==0) {
		$('bPrevious').style.color = "gray";
	} else {
		$('bPrevious').style.color = "black";
	}
	// next button
	if (parseInt(curHash[1])==(eval("imgs" +curHash[0]).length-1)) {
		$('bNext').style.color = "gray";
	} else {
		$('bNext').style.color = "black";
	}
}

function li(imageName) {
	document.location.href = "i.php?i=" + imagePath + "/" + imageName;
}

function n() { //next
	if (parseInt(curHash[1])+1<=(eval("imgs" +curHash[0]).length-1)) {
		curHash[1]++;
		document.location.href = "./img.php#" + curHash[0] +"," +curHash[1];
		loadImage();
	}
}

function p() { //previous
	if (parseInt(curHash[1])-1>=0) {
		curHash[1]--;
		document.location.href = "./img.php#" + curHash[0] +"," +curHash[1];
		loadImage();	
	}
}

function i() { //index
	document.location.href = "./#" + curHash[0] +"," +curHash[1];
}

function mbNext () { //next unless last image, then return to menu
	if (parseInt(curHash[1])+1<=(eval("imgs" +curHash[0]).length-1)) {
		n();
	} else {
		i();
	}
}