<!--

// Form Validation by MDC 2004


function validate()
{

	resetAll();

	var p = document.dl.Program;
	var n = document.dl.Name;
	var c = document.dl.Company;
	var t = document.dl.Telephone;
	var e = document.dl.Email;


	var flag = 0;
	

	if (n.value == null || n.value == "" || n.value == " ")
	{
		showError("nameVal");
		flag = 1;		
	}
	if (checkSpaces(n.value) == false)
	{
		showError("nameVal");
		flag = 1;
	}
	if (checkSpaces(c.value) == false)
	{
		showError("companyVal");
		flag = 1;
	}
	if (checkSpaces(t.value) == false)
	{
		showError("telVal");
		flag = 1;
	}
	if (checkSpaces(e.value) == false)
	{
		showError("emailVal");
		flag = 1;
	}
	if (c.value == null || c.value == "" || c.value == " ")
	{
		showError("companyVal");
		flag = 1;
	}
	if (t.value == null || t.value == "" || t.value == " ")
	{
		showError("telVal");
		flag = 1;
	}
	if (checkTelephone(t.value) == false)
	{
		showError("telVal");
		flag = 1;
	}
	if (e.value == null || e.value == "")
	{

		showError("emailVal");
		flag = 1;
	}
	if (checkEmail(e.value) == false)
	{

		showError("emailVal");
		flag = 1;
	}
	
	if (flag == 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}


function checkSpaces(strValue)
{
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0)
   {
     return true;
   }
   return false;
}

function trimAll( strValue ) {
 var objRegExp = /^(\s*)$/;
    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
  return strValue;
}

function resetAll()
{

	if (document.getElementById)
	{
		  document.getElementById('nameVal').style.visibility = 'hidden';
		  document.getElementById('companyVal').style.visibility = 'hidden';
		  document.getElementById('telVal').style.visibility = 'hidden';
		  document.getElementById('emailVal').style.visibility = 'hidden';
		  document.getElementById('sourceVal').style.visibility = 'hidden';
	}
	else if (document.all)
	{
		  document.all['nameVal'].style.visibility = 'hidden';
		  document.all['companyVal'].style.visibility = 'hidden';
		  document.all['telVal'].style.visibility = 'hidden';
		  document.all['emailVal'].style.visibility = 'hidden';
		  document.all['sourceVal'].style.visibility = 'hidden';
		  
	}
	else if (document.layers)
	{
		  document.nameVal.visibility = 'hide';
		  document.companyVal.visibility = 'hide';
		  document.telVal.visibility = 'hide';
		  document.emailVal.visibility = 'hide';
		  document.sourceVal.visibility = 'hide';
	}

}

function showError(field)
{
	errorMsg = "";
	
	if (field == "nameVal" || field == "nameVal2")
	{
		errorMsg = '<P CLASS="red">* Invalid Name Entered.</P>'
	}
	else if (field == "companyVal" || field == "companyVal2")
	{
		errorMsg = '<P CLASS="red">* Invalid Company Entered.</P>'
	}
	else if (field == "telVal" || field == "telVal2")
	{
		errorMsg = '<P CLASS="red">* Invalid Telephone Entered.</P>'
	}
	else if (field == "emailVal" || field == "emailVal2")
	{
		errorMsg = '<P CLASS="red">* Invalid Email Entered.</P>'
	}
	else if (field == "sourceVal" || field == "sourceVal2")
	{
		errorMsg = '<P CLASS="red">* Invalid Source Entered.</P>'
	}

	if (document.getElementById)
	{
		  eval("document.getElementById('" + field + "')").innerHTML = errorMsg;
		  eval("document.getElementById('" + field + "')").style.visibility = 'visible';
	}
	else if (document.all)
	{
		  eval("document.all['" + field + "']").innerHTML = errorMsg;
		  eval("document.all['" + field + "']").style.visibility = 'visible';
	}
	else if (document.layers)
	{
		  with (eval("document.layers['" + field + "']").document)
		  {
				open();
				write(errorMsg);
				close();
		  }
		  eval("document." + field).visibility = 'show';
	}
}

function checkTelephone(number)
{

	var invalid = "!#$%^&*=/:;\"\'\\{}~`"
	
	for (var i = 0; i < number.length; i++)
	{
		for (var j = 0; j < invalid.length; j++)
		{
			if (number.indexOf(invalid.charAt(j)) != -1)
			{
				
				return false;
			}
		}
	
	}	
	return true;

}

function checkEmail(address) {

	var at = "@"
	var dot = "."
	var indexAt = address.indexOf(at)
	var length = address.length
	var indexDot = address.indexOf(dot)
	
	if (indexAt == -1)
	{		
		return false;
	}

	if (indexAt == -1 || indexAt == 0 || indexAt == length - 1)
	{
		return false;
	}
	if (indexDot == -1 || indexDot == 0 || indexDot == length - 1)
	{
		return false;
	}
	if (address.indexOf(at,(indexAt + 1)) != -1)
	{
		return false;
	}
	if (address.substring(indexAt - 1,indexAt) == dot || address.substring(indexAt + 1, indexAt + 2) == dot)
	{
		return false;
	}
	if (address.indexOf(dot,(indexAt + 2)) == -1)
	{
		return false;
	}		
	if (address.indexOf(" ") != -1){
		return false;
	}
	return true;			
}

// Mail-Blast Functions

function scanParams()
{
   // Browser-sniffing variables.
   var minNav3 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3);
   var minIE4 = (navigator.appName.indexOf("Microsoft") >= 0 && parseInt(navigator.appVersion) >= 4);
   // Baseline DOM required for this function
   var minDOM = minNav3 || minIE4;
   
   // Initialize array to be returned.
   var results = new Array();
   
   if (minDOM) 
   {
      // Unescape and strip away leading question mark.
      
      var input = unescape(location.search.substring(1));
      
      if (input) 
      {
         // Divide long string into array of name/value pairs.
         var srchArray = input.split("&&");
         var tempArray = new Array();
         for (i = 0; i < srchArray.length; i++)
         {
            // Divide each name/value pair temporarily into a two-entry array.
            tempArray = srchArray[i].split("=");
            // Use temp array values as index identifier and value.
            results[tempArray[0]] = tempArray[1];
         }
      }
   }
   return results;
}



//-->