// JavaScript Document


/*
function CheckRequired(theForm)
{
	if (theForm.Name == "")
	{
		alert("Please enter your name");
		theForm.Name.focus();
		return (false);
	}	
	return(true);
}
*/


function validate_client()
{
    if(document.forms["clientLogin"].myUsername.value=="" || document.forms["clientLogin"].myPassword.value==""){
        alert("A Username and Password are required"),"";
		return false;
        }
		else
		{
        return true;
        }
}



  
  
function validate_seo_newsletter(theForm){
    if(document.forms["SEONewsletter"].myEmail.value==""){
        alert("Please enter your e-mail address"),"";
        //theForm.myName.focus();
		return false;
        }
		else if (echeck(document.forms["SEONewsletter"].myEmail.value)==false){
		alert("Please enter a valid E-Mail address."),"";
		//theForm.myEmail.focus();
		return false;
		}
		else
		{
        return true;
        }
  }


function validate_seoevaluation(theForm){
    if(document.forms["seoEvaluation"].myName.value==""  || document.forms["seoEvaluation"].myEmail.value=="" || document.forms["seoEvaluation"].myPhone.value==""){
        alert("All fields are required for an SEO Evaluation."),"";
        //theForm.myName.focus();
		return false;
        }
		else if (echeck(document.forms["seoEvaluation"].myEmail.value)==false){
		alert("Please enter a valid E-Mail address."),"";
		//theForm.myEmail.focus();
		return false;
		}
		else
		{
        return true;
        }
  }
  

/*
function validate_client_login(theForm){
    if(document.forms[0].myUsername.value==""){
        alert("UserName and Password are required."),"";
        //theForm.myName.focus();
		return false;
        }
//		else if (echeck(document.forms[0].myEmail.value)==false){
//		alert("Please enter a valid E-Mail address."),"";
//		//theForm.myEmail.focus();
//		return false;
//		}
		else
		{
        return true;
        }
  }
*/


//CUSTOM MESSAGE BOX --------------->>>>>>
var ALERT_TITLE = "Missing Information!";
var ALERT_BUTTON_TEXT = "Ok";

if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	d = document;

	if(d.getElementById("modalContainer")) return;

	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	mObj.style.height = d.documentElement.scrollHeight + "px";
	
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
	alertObj.style.visiblity="visible";

	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	msg = alertObj.appendChild(d.createElement("p"));
	msg.innerHTML = txt;

	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	btn.focus();
	btn.onclick = function() { removeCustomAlert();return false; }

	//alertObj.style.display = "block";
	
}

function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}
//END CUSTOM MESSAGE BOX -------------------------------<<<<<<<<


/*
var testresults
function checkemail(){
var str=document.validation.emailcheck.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
alert("Please input a valid email address!")
testresults=false
}
return (testresults)
}
*/


//VALIDATE EMAIL ADDRESS------------------------>>>>>>>>>>>>>>>>
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}
//END VALIDATE EMAIL ADDRESS--------------<<<<<<<<<<<<<<




