/* scripts.js */

// removes possible leading and following spaces
function trim(str)
{
	while(str.charAt(0) == ' ') str=str.substring(1, str.length);
	while(str.charAt(str.length-1) == ' ') str=str.substring(0, str.length-1);
	return str;
}

function go(nav)
{
	location = nav;
}

function forum_checkInput(form)
{
	if(trim(form.username.value) == "") {
		alert("I don't see your name");
		form.username.value="";
		form.username.focus();
		return false;
	}
	if(trim(form.message.value) == "") {
		alert("I don't see your message");
		form.message.value="";
		form.message.focus();
		return false;
	}
	return true;
}

function guestbook_checkInput(form)
{
	if(trim(form.username.value) == "") {
		alert("I don't see your name");
		form.username.value="";
		form.username.focus();
		return false;
	}
	if(trim(form.message.value) == "") {
		alert("I don't see your message");
		form.message.value="";
		form.message.focus();
		return false;
	}
	return true;
}

function contact_checkInput(form)
{
	if (trim(form.username.value) == "") {
		form.username.value="";
		alert("I don't see your name");
		return false;
	}
	if (trim(form.message.value) == "") {
		alert("I don't see your message");
		form.message.value="";
		return false;
	}
	/*if (trim(form.email.value) == "") {
		form.email.value="";
		if (!confirm("Leaving email empty means you don't want a response. Continue?")) {
			return false;
		}
	}*/
	return true;
}

function login_checkInput(form)
{
	if(trim(form.username.value) == "") {
		form.username.value="";
		alert("I don't see your username");
		return false;
	}
	if(trim(form.password.value) == "") {
		form.password.value="";
		alert("I don't see your password");
		return false;
	}
	return true;
}

/* Organizer */
function refresh()
{
	if(document.frmMenu.chkRefresh.checked) {
		location.reload();
	}
}

function navigate(there)
{
	switch(there.value) {
		case "Add": location="add.php"; break;
		case "Home": location="index.php"; break;
	}
}

function AmPm(name, pm)
{
	var f = document['frm'+name];
	if (pm.checked) {
		if (eval(f.hour.value) <= 12) {
			document['frm'+name].hour.value = eval(f.hour.value) + 12;
		}
	} else {
		if(eval(document['frm'+name].hour.value) >= 12) {
			document['frm'+name].hour.value = eval(f.hour.value) - 12;
		}
	}
}

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

if (document.getElementById){ //DynamicDrive.com change
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
					ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

