 function MM_openBrWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
    return false;
}
function chooseExternalPhoto(photoid,photoKey)
{
	document.getElementById('CTForm_funcimageSearchForm').value = 'Distro.uploadDistroFile';
	document.getElementById('imageIdimageSearchForm').value = photoid;
	document.getElementById('printimageSearchForm').value = 'yes';
	var keyField = document.getElementById('imageKeyimageSearchForm')
	if( keyField )
	{
		keyField.value = photoKey;
	}
	document.getElementById('imageSearchForm').onsubmit = function() {};
	document.getElementById('imageSearchForm').submit();
}
function chooseExternalAlbum(albumid,albumKey)
{
	document.getElementById('albumIdentifierimageSearchForm').value = albumid;
	var keyField = document.getElementById('albumKeyimageSearchForm')
	if( keyField )
	{
		keyField.value = albumKey;
	}
	document.getElementById('imageSearchForm').onsubmit();
}
function chooseExternalPhotoPage(newpage)
{
	var page = document.getElementById('pageimageSearchForm');
	if( page.value != newpage )
	{
		page.value = newpage;
		page.form.onsubmit();
	}
}
function selectPreviousImage(imageID)
{
	var theForm = document.getElementById('EnterCodeForm');
	var productID = -1;
	for (var i=0;i<theForm.CBProduct_id.length;i++)
	{
		if (theForm.CBProduct_id[i].checked == true)
		{
			productID = theForm.CBProduct_id[i].value;
			break;
		}
	}
	if (productID < 1)
	{
		alert("Please select a product to continue");
		return;
	}
	var redir = "/customize-product.php?CBProduct_id="+productID+"&customizeId=&step=image&customizeFile="+imageID+"&quantity=1&cropStyle=";
	document.location.href = redir;
}
