// JavaScript Document
// © http://www.designplace.org (unless function prefixed with MM (Dreamweaver generated code))
// Matt Millross
// Page created 26 October 2002
// Page last modified 03 Dec 2002 by Matt Millross


// function to check search form on each page for null input or numeric input.

function check(form){

q = document.forms[0].q.value

if (q == "" || q == null || q.charAt(0) == ' ' || !isNaN(q))
{
	alert("Invalid search term.\nSearch term must be great than 2 characters and not be numeric")
	return false;
}
return true
}

// Dreamweaver generated "jump menu" code

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
// end of dreamweaver generated code


//checks resource addition form on links.php for invalid entry
function isEmpty(strName, strURL, strTitle){

strName = document.forms[1].name.value
//strEmail = document.forms[0].email.value
strURL = document.forms[1].url.value
strTitle = document.forms[1].title.value

//name field
if (strName == "" || strName == null || !isNaN(strName) || strName.charAt(0) == ' ')
	{
	alert("\"Name\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}

//url field	
if (strURL == "" || strURL == null || strURL.charAt(0) == ' ')
	{
	alert("\"URL\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}

//title field	
if (strTitle == "" || strTitle == null || strTitle.charAt(0) == ' ')
	{
	alert("\"Link title\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}
return true;
}


//checks partner request form on partners.php for invalid entry
function isEmpty2(strName2, strURL2, strRURL, strDetail){

strName2 = document.forms[1].name.value
//strEmail = document.forms[0].email.value
strURL2 = document.forms[1].url.value
strRURL = document.forms[1].r_url.value

//name field
if (strName2 == "" || strName2 == null || !isNaN(strName2) || strName2.charAt(0) == ' ')
	{
	alert("\"Name\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}

//url field	
if (strURL2 == "" || strURL2 == null || strURL2.charAt(0) == ' ')
	{
	alert("\"URL\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}

//title field	
if (strRURL == "" || strRURL == null || strRURL.charAt(0) == ' ')
	{
	alert("\"Reciprocal link\" is a mandatory field.\nPlease amend and retry.")
	return false;
	}
return true;
}


function isValidEmail(email){

mailChars=/^[^@]+@[^@]+.[a-z]{2,}$/i;
emailString=document.forms[1].email.value;

	// search email text for regular exp matches
	if (emailString.search(mailChars)==-1) {
		alert('A valid e-mail address is required.\nPlease amend and retry');
	return false;
	}	
return true;
}

//check textarea length
function isValidLength(theText){
theText = document.forms[1].detail.value
if (theText.Length > 500)
	{
	alert("Detail field has a maximum length of 500 characters.\nYour input is " + theText.Length + " characters in length.")
	return false;
	}
if (theText.Length < 1)
	{
	alert("Please input details about your site and your management of partners links.")
	return false;
	}
return true
}

function checkLinkForm(form){
if (isEmpty(form.name)){
	//if (isEmpty(form.email)){
		if (isEmpty(form.url)){
			if (isEmpty(form.title)){
				if (isValidEmail(form.email)){ 
				return true; 
				} 
			} 
		} 
	//} 
}
return false;
}



function checkPartnerForm(form){
if (isEmpty2(form.name)){
	if (isValidEmail(form.email)){
		if (isEmpty2(form.url)){
			if (isEmpty2(form.r_url)){
				if (isValidLength(form.detail)) {
					return true;
				}
			}
		}
	}
}
return false;
}