function NoHTML(sText)
{
   var InvalidChars = "><,;";
   var HTMLcheck =true;
   var Char;

 
   for (i = 0; i < sText.length && HTMLcheck == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (InvalidChars.indexOf(Char) != -1) //if items are found 
         {
         HTMLcheck = false;
         }
      }
   return HTMLcheck;
   
}

//Libary Function
function $(id) {
  return document.getElementById(id);
}

function populateKey()
{
$('key').value = getURL();	
}

function getURL()
{
test = location.href;

test= test.split("/");
str = "";
for(i=0;i<(test.length-1);i++)
{
	if(i == 0)
	str = test[i]+"/";
	else
	str = str + test[i] + "/";
}
return str;
}

function IsEmail(sText)
{

var whereisAT = sText.indexOf('@');

if(whereisAT == -1)
{
	return false;
}
   
var whereisDOT = sText.indexOf('.');  

if(whereisDOT == -1)
{
	return false;
}
   
   
   return true;
}


function checklogin(form)
{
		
		
		if(form.login.value == "")
	{
		alert("Login field is blank.");
		form.login.focus();
		return false;
	}
	else
	{
	var theTest = NoHTML(form.login.value);
	
		if(theTest == false)
		{
		alert("> and < are invalid characters.");
		return false;
		}	
	
	}
	
		if(form.password.value == "")
	{
		alert("Password field is blank.");
		form.password.focus();
		return false;
	}
	else
	{
	var theTest = NoHTML(form.password.value);
	
		if(theTest == false)
		{
		alert("> and < are invalid characters.");
		return false;
		}	
	
	}	
	
}

function checkfields(form)
{
	if(form.name.value == "")
	{
		alert("Name field is blank.");
		form.name.focus();
		return false;
	}
	else
	{
	var theTest = NoHTML(form.name.value);
	
		if(theTest == false)
		{
		alert("> and < are invalid characters.");
		form.name.focus();		
		return false;
		}	
	
	}
	
	//**********************
	
		if(form.email.value == "")
	{
		alert("Email field is blank.");
		form.email.focus();
		return false;
	}
	else
	{
	var theTest = NoHTML(form.email.value);
	
		if(theTest == false)
		{
		alert(">,<,:, and , are invalid characters.");
		form.email.focus();		
		return false;
		}

	var theTest = IsEmail(form.email.value);
	
		if(theTest == false)
		{
		alert("Invalid Email Detected");
		return false;
		}	

	}
	
		//**********************
	
		if(form.comments.value == "")
	{
		alert("Comments field is blank.");
		form.comments.focus();
		return false;
	}
	else
	{
	var theTest = NoHTML(form.comments.value);
	
		if(theTest == false)
		{
		form.comments.focus();			
		alert("> and < are invalid characters.");
		return false;
		}
		/*
		else
		{
		var comments = countComments(form);	
		
		if(comments == false)
		return false;
		}
		*/
	}
	
	
} //end function

/*
function countComments(form)
{
	var CommentVar = form.comments.value;
	var Count = 500 - CommentVar.length;
	form.countval.value = Count;
	
	if(Count < 0)
	{
	alert("Max comment characters reached, we do this so no malicious code can be run on our servers.\n If your request is lengthy, please call us at 702-367-3085.");
	return false;
	}
}

function countval(form)
{
	form.countval.value = 500;
	form.name.focus();
}
*/


