var ptone = "cont";
var pttwo = "moj";
var ptthr = "k.c";
var ptfou = "to:";

function errorMsg()
{
	alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
}

function addEngine(name)
{
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
		window.sidebar.addSearchEngine(
			"http://www.mojeek.com/mozilla/mps/mps_" + name + ".src",
			"http://www.mojeek.com/mozilla/mps/mps_" + name + ".gif",
			name, "General");
	} else {
		errorMsg();
	}
}

function contUs()
{
	var m = ptone + "act" + "@" + pttwo + "ee";
	document.write("<a href=" + "mail" + ptfou + m + ptthr + "om" + ">" + m + ptthr + "om" + "</a>");
}

function valid_email(email)
{
	if (email == "")
		return false;

	if ((email.indexOf('@') == 0) || (email.indexOf('@') == -1) || (email.lastIndexOf('.') == -1) ||
	    (email.indexOf('@') == email.lastIndexOf('.')-1) || (email.indexOf('@') > email.lastIndexOf('.')) ||
	    (email.lastIndexOf('.') == email.length-1))
		return false;

	return true;
}

function verNewAccount()
{
	var email = document.forms.naform.email.value;

	if (valid_email(email) == false) {
		alert("Please enter a vaild e-mail address.");
		document.forms.naform.email.focus();
	} else if (document.forms.naform.code.value == "") {
		alert("Please enter the verification code.");
		document.forms.naform.code.focus();
	} else {
		document.forms.naform.submit();
	}
}

function verFeedback()
{
	var email = document.forms.fform.email.value;

	if (document.forms.fform.name.value == "") {
		alert("Please enter your name.");
		document.forms.fform.name.focus();
	} else if ((email != "") && (!valid_email(email))) {
		alert("Please enter a vaild e-mail address.");
		document.forms.fform.email.focus();
	} else {
		document.forms.fform.submit();
	}
}

function verForm()
{
	var email = document.forms.cform.email.value;

	if (document.forms.cform.name.value == "") {
		alert("Please enter your name.");
		document.forms.cform.name.focus();
	} else if (!valid_email(email)) {
		alert("Please enter a vaild e-mail address.");
		document.forms.cform.email.focus();
	} else if (document.forms.cform.inquiry.value == "") {
		alert("Please give details about your inquiry.");
		document.forms.cform.inquiry.focus();
	} else if (document.forms.cform.cap_code.value == "") {
		alert("Please enter the verification code.");
		document.forms.cform.cap_code.focus();
	} else {
		document.forms.cform.submit();
	}
}
