function validateText(field, descField) {
	if (field.value == "") {
		alert ("Please complete the " + descField + " field.")
		field.focus();
		return (false);
	}
	return (true)
}

function submitonEnter(evt, frm){
	if (window.event) { //IE
		var charCode = event.keyCode;
	} else {
		var charCode = evt.which;
	}
	if(charCode == '13'){
		document.forms[frm].submit();
	}
}

function rowHighlight(objectThis, strClass) {
	objectThis.className=strClass
}

function validateUpload() {
	frm = document.forms['frmUpload'];
	if (!validateText(frm.InputTitle, 'Title')) return(false);
	if (!validateText(frm.userfile, 'Upload File')) return(false);
	frm.submit();
}

function chkDelete(tbl, id, ref) {
	if (confirm("Are you sure you want to delete this record?")) { 
		self.location.href = 'dbdeleterecord.php?tbl=' + tbl + '&id=' + id + '&ref=' + ref;
	}	
}

function switchImageGallery(strName,strTitle) {
	document.currentImage.src = strName;
	caption = document.getElementById("descImage");
	caption.innerHTML = strTitle;
}

function validateContact() {
	frm = document.forms['frmContact'];
	if (!validateText(frm.emailName, 'Name')) return(false);
	if (!validateText(frm.emailAddress, 'Email Address')) return(false);
	if (!validateText(frm.emailBody, 'Message')) return(false);	
	frm.submit();
}

function DisplayMail(Server, Login, Display){  
    if ((Display.length == 0) || (Display.indexOf('@')+1)) {  
    document.write('<a href=' + '"mai' + 'lto:' + Login + '@' + Server + '">' + Login + '@' + Server + '<\/a>'); }  
    else  {  
    document.write('<a href=' + '"mai' + 'lto:' + Login + '@' + Server + '">' + Display + '<\/a>'); }  
}

function validatePreviewPostcard() {
	if (document.forms['eCard'].to.value == ''){
		alert("Please enter a valid email address");
		return false;
	}
	document.getElementById("action_preview").click();
}
function validateSendPostcard() {
	if (document.forms['eCard'].to.value == ''){
		alert("Please enter a valid email address");
		return false;
	}
	document.getElementById("action_send").click();
}