function openImagePopup(id) {
	var width = 826;
	var height = 454;

	openPopup("full-image-view.php?id="+id,'popup',width,height);
}

function openRequestImagePopup(imagetitle,imagecode) {
	var width = 826;
	var height = 454;

	openPopup("request-image.php?imagetitle="+imagetitle+"&imagecode="+imagecode,'popup',width,height);
}

var parentWindow;
function openPopup(url,target,width,height) {
	var winl = (screen.width-width)/2;
	var wint = (screen.height-height)/2;
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;		

	parentWindow = window.open('', target, "dependent=yes,modal=yes,dialog=no,menubar=no,location=no,resizable=no,status=no,height="+height+",width="+width+",left="+winl+",top="+wint+"");
	parentWindow.location.href = url;
	if (parentWindow.opener == null) parentWindow.opener = self;
}

function validate() {
	var x;
	var required = document.getElementsByName("requiredfield");
	for (x=0;x<required.length;x++) {
		var name = required[x].id.split("_");
		var title = document.getElementsByName(name[1])[0].title;
		if(document.getElementsByName(name[1])[0].value == "") {
			alert(title + " is a required field.\nPlease make sure to enter " + title + ".");
			document.getElementsByName(name[1])[0].focus();
			return false;
		}
	}

	var numeric = document.getElementsByName("numericfield");
	for (x=0;x<numeric.length;x++) {
		var name = numeric[x].id.split("_");
		var title = document.getElementsByName(name[1])[0].title;
		if(isNaN(document.getElementsByName(name[1])[0].value) == true) {
			alert("Invalid " + title + ".\n Please enter numbers and a decimal point only.");
			document.getElementsByName(name[1])[0].focus();
			return false;
		}
	}

	return true;
}
