// JavaScript Document

function chkClick(e) {
	if (document.all) {
		if (event.button == 1 || event.button ==3) {
			alert("Please Right-Click, and select \"Save Target As\"");
		}
	}
	if (document.layers) {
		if (e.which == 1 || e.which ==3) {
			alert("Please Right-Click, and select \"Save Target As\"");
		}
	}
}

function visComment(id) {
	var divID = document.getElementById('div'+id);
	var txtID = document.getElementById('comment'+id);
	if(divID.style.visibility == "hidden") {
		divID.style.visibility = 'visible';
		divID.style.position = 'static';
		txtID.innerHTML = '<< Hide Comments';
	}
	else {
		divID.style.visibility = 'hidden';
		divID.style.position = 'absolute';
		txtID.innerHTML = 'View Comments >>';
	}
}

function chkComments(varFileID) { 
	if ( document.forms["addGuest"+varFileID].body.value == "" ) {
		alert("Right.  How about you actually post a comment to the guestbook?");
		return false; 
	}
	else {
		if ( document.forms["addGuest"+varFileID].email.value != "" ) {
			if (chkEmailComments(varFileID) == false) { return false; }
		}
		return true;
	}
}

function chkEmailComments(varFileID) {
	var Temp     = document.forms["addGuest"+varFileID].elements["email"]
	var AtSym    = Temp.value.indexOf('@')
	var Period   = Temp.value.lastIndexOf('.')
	var Space    = Temp.value.indexOf(' ')
	var Length   = Temp.value.length - 1   // Array is from 0 to length-1
	
	if ((AtSym < 1) ||                     // '@' cannot be in first position
			(Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
			(Period == Length ) ||             // Must be atleast one valid char after '.'
			(Space  != -1))                    // No empty spaces permitted
		 {  
				alert('Please enter a valid e-mail address!')
				Temp.focus()
				return false;
		 }
	else {
		return true;
	}
}