function showMessage() {
	if (document.getElementById) {
		document.getElementById('uploadstatus').style.backgroundColor = '#fc0';
		document.getElementById('uploadstatus2').style.backgroundColor = '#fc0';
		var newText = document.createTextNode("Your photo is now uploading - please wait until this page tells you that the process has finished!");
		var newText2 = document.createTextNode("Your photo is now uploading - please wait until this page tells you that the process has finished!");
		var gubbins = document.getElementById("uploadstatus");
		var stuff = document.getElementById("uploadstatus2");
		gubbins.appendChild(newText);
		stuff.appendChild(newText2);
	}
	return true;
}

function hideButton() {
	if (document.all||document.getElementById) {
		document.forms[0].sendfile.disabled=true;
	}
}

function changeStatusbar() {
	window.status = 'Uploading photo, please wait';
}

function showUploading() {
	hideButton();
	showMessage();
	changeStatusbar();
}

function showStatus(message){
  var blurb;
  blurb = "window.status='"+message+"'";
  setTimeout(blurb,0);
  return true;
}

function clearStatus(){
  setTimeout("window.status=''",0);
  return true;
}

function showUpdateInProgress() {
	if (document.all||document.getElementById) {
		document.forms[0].Update.disabled=true;
	}
	document.forms[0].Update.value="P l e a s e   w a i t..";
	window.status = 'Uploading file and updating, please wait..';
}

function goLocation(thisFormSelect) {
	var thisSelection;
  	thisSelection = thisFormSelect.options[thisFormSelect.selectedIndex].value;
  	if (thisSelection != "") {
    location = thisSelection;
	}
}

function isEmpty(string) {
	var whitespace = " \t\n\r";
	var n

	if ((string == null) || (string.length == 0)) {
		return true;
	}
    for (i = 0; i < string.length; i++) {
		n = string.charAt(i);
		if (whitespace.indexOf(n) == -1) {
			return false;
		}
    }
    // All characters are whitespace.
    return true;
}

function tooLong(string, max) {
	if (string.length > max) {
		return true;
	}
}

function stripChars (string, accept) {
// string to clean, acceptable characters
	var i;
	var newchar;
	var returnString = "";

	for (i = 0; i < string.length; i++) {
		newchar = string.charAt(i);
		if (accept.indexOf(newchar) != -1) returnString += newchar;
	}
	return returnString;
}

function showError(ourform, where, warning) {
	ourform.elements[where].focus();
	alert(warning);
}

function editimage() {
	ourform = document.forms[0];

	if (isEmpty(ourform.caption.value)) {
 		showError(ourform, "caption", "Please make sure you enter the name of the image");
		return false;
	}

	if (isEmpty(ourform.image_url.value)) {
		if(!confirm("No image is specified for this product\n- are you sure you wish to continue?")) {
			ourform.elements['image_url'].focus();
			return false;
		}
	}
		return true;
}