function setfilename(filename, thumbnail)  {
	var mytd = document.getElementById("importanttd")
	myinput = mytd.getElementsByTagName("input");
	if (myinput && myinput[0]){
		myinput[0].value = filename;
	}

	// This should be in te call back!
	var myTR = document.getElementById("photoinstructions");
	try {
		myTR.style.display="table-row";
	}
	catch (e) {
		myTR.style.display="block";
	}
	textarea = myTR.getElementsByTagName("textarea");
	if (textarea && textarea[0]){
		textarea[0].disabled = false;
	}
	
	var previewImage = document.getElementById("previewimage");
	previewImage.src = "/custom/upload/thumbnails/"+thumbnail;

	var previewImageTR = document.getElementById("previewimageTR");
	try {
		previewImageTR.style.display="table-row";
	}
	catch (e) {
		previewImageTR.style.display="block";
	}

	var myTR = document.getElementById("photodetails");
	myTR.style.display="none";
}

function checkPhoto(){
	var myPI = document.getElementById("photoinstructions");
	myinput = myPI.getElementsByTagName("textarea");
	if (myinput && myinput[0]){
		if (myinput[0].value==""){
			myinput[0].value="No special instructions";
		}		
		// now trim the result!!
		myinput[0].value=myinput[0].value.replace(/^\s*|\s*$/g, "");
	}	
	
	// Trim all the other product options
	try {
		var prodoptions = document.orderform.getElementsByTagName('input');
		for (var fi=0;fi<prodoptions.length;fi++){
			prodoptions[fi].value = prodoptions[fi].value.replace(/^\s*|\s*$/g, "");
		}
	}
	catch (e){
		
	}
	
	var mytd = document.getElementById("importanttd")
	myinput = mytd.getElementsByTagName("input");
	if (myinput && myinput[0]){
		if (myinput[0].value==""){
			alert("You have not uploaded an image - you cannot add this item to your cart before you do so");
			return false;
		}
		return true;
	}
	else {
		alert("sorry - there is a problem with the site please report this to the administrator");
		return false;
	}
	
}