/* new for packshots */
function packshotClick(pic) {
	document.getElementById('packshot').style.display = 'block';

	hideLastPackshot();
		
	document.getElementById('fullscreen' + pic).style.display = 'block';
	document.getElementById('packshotlink' + pic).className = 'active';
	
	document.lastPackshot = pic;
}

/* new for packshots */
function hideLastPackshot() {
	var lastPS = document.lastPackshot;
	if (lastPS == null) lastPS = 'C';
	
	document.getElementById('fullscreen' + lastPS).style.display = 'none';
	document.getElementById('packshotlink' + lastPS).className = '';
}

function thumbnailClick(img) {
	if(document.getElementById('motion'))
		document.getElementById('motion').style.display = 'none';

	
	document.getElementById('still').style.display = 'block';
	
	hideLastThumbnail();
		
	if (img == 'C') {
		var next = 0;
	} else {
		var next = img + 1;
	}
	
	document.getElementById('fullsize' + img).style.display = 'block';
	document.getElementById('thumblink' + img).className = 'active';
	
	document.getElementById('prevLink').className = (img == 'C' ? 'previous disabled' : 'previous');
		
	var nextExists = (document.getElementById('fullsize' + next) != null);
	if (document.motionO) nextExists = true;
	
	document.getElementById('nextLink').className = (!nextExists ? 'next disabled' : 'next');
	
	document.lastThumb = img;
	
	/*document.getElementById('productinfo').style.display = (img == 'C' ? 'block' : 'none');*/
}

function hideLastThumbnail() {
	var last = document.lastThumb;
	if (last == null) last = 'C';
	
	if(last != 'M') {
		document.getElementById('fullsize' + last).style.display = 'none';
		document.getElementById('thumblink' + last).className = '';
	}

}

function prevThumb() {
	var last = document.lastThumb;


	if (last == 'M') {
		document.motionO.prev();
		return;
	}
	
	if (last == null) last = 'C';
	
	if (last == 'C') return;
	
	var img = last - 1;
	if (img < 0) img = 'C';
		
	thumbnailClick(img);
}

function nextThumb() {
	var last = document.lastThumb;
	
	if (last == 'M') {
		document.motionO.next();
		return;
	}
	
	if (last == null) last = 'C';
	
	if (last == 'C') {
		var img = 0;
	} else {
		var img = last + 1;
	}
	
	if (!document.getElementById('fullsize' + img)) {
		if (document.motionO) {
			document.motionO.showMovie(0);
		}
		return;
	}
	
	thumbnailClick(img);
}

function lastThumbNum() {
	for(var i = 40; i >= 0; i--) {
		if (document.getElementById('fullsize' + i))
			return i;
	}
	
	return 'C';
}