var currentPhoto = 1;

function nextPhoto(len) {
	if (currentPhoto + 1 <= len) {
		document.getElementById('largePhoto').src = "../bb_galleries/large/" + photos[currentPhoto + 1];
		document.getElementById('largeLink').rel = "../bb_galleries/" + photos[currentPhoto + 1];
		document.getElementById('currentPhoto').innerHTML = currentPhoto + 1;
		currentPhoto = currentPhoto + 1;
	}
}

function prevPhoto() {
	if (currentPhoto - 1 >= 1) {
		document.getElementById('largePhoto').src = "../bb_galleries/large/" + photos[currentPhoto - 1];
		document.getElementById('largeLink').rel = "../bb_galleries/" + photos[currentPhoto - 1];
		document.getElementById('currentPhoto').innerHTML = currentPhoto - 1;
		currentPhoto = currentPhoto - 1;
	}
}

function submitForm(id) {
	document.getElementById('productID').value = id;
	document.getElementById('productform').submit();
}

function addToWishlist() {
	document.getElementById('galleryform').submit();
}

function imageOn(id) {
	document.getElementById(id).src = 'images/' + id + '-on.gif';
}

function imageOff(id) {
	document.getElementById(id).src = 'images/' + id + '.gif';
}

function closeWindow(url) {
	try {
		window.opener.location = url;
		window.close();
	} catch (error) {
		window.location = url;
	}
}

function newWindow(url) {
	window.open(url);
}

function openWindow(url) {
	var leftValue = (screen.width - 640) / 2;
	var topValue = (screen.height - 354) / 2;
	var newWindow = window.open(url, "", "toolbar=0, scrollbars=1, resizable=0, width=640, height=354, left=" + leftValue + ", top=" + topValue + "");
}


var win = null;
function OpenNewWindow(mypage,w,h,myname){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=yes,toolbar=no'
	win=window.open(mypage,myname,settings)
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
