﻿
// contact email

function CLOMImail(Uname,LinkMsg,Lclass)  {
	var Uname, LinkMsg;
	var Udom = "clomi";
	var Utld = ".com";
	var esub = "From the Control Logic Website";
	if(!Uname)  {Uname = "info";  }
	if(!LinkMsg)  {LinkMsg = "send us an email";  }
	document.write("<a class= "+ "'" + Lclass + "'" + " href= " + '"' + "mailto:" + Uname + "&#64;" + Udom + Utld + "?subject=" + esub +'"' + ">" + LinkMsg + "<\/a>");

	}
	
//email validation

function validateEmail(y){      
   var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
   return emailPattern.test(y); 
 }

//Form validation

function checkIt(x)  {

	var valid = true;
	var msg = "";
	if(x.rname.value == "") { 
		valid = false;
		msg = "Please enter your name.";
		x.rname.focus();
		}
		
	if ((x.company.value == "") && (valid == true))  {
		valid = false;
		msg = "Please enter the name of your company.";
		x.company.focus();
		}
		
	if ((x.phone.value == "") && (valid == true))  {
		valid = false;
		msg = "Please enter your phone number.";
		x.phone.focus();
		}
		
	if ((x.email.value == "") && (valid == true))  {
		valid = false;
		msg = "Please enter your email address.";
		x.email.focus();
		}
		
	if((!validateEmail(x.email.value)) && (valid == true)) {
		valid = false;
		msg = "The email address you entered does not \nappear to be a valid one.";
		x.email.value = "";
		x.email.focus();
		}

	if(!valid)  {
		alert(msg);
		return false;
		}
			else  {
			return true;
			}
			
 }