function SubmitContactForm(f){
	//-------------------------------------------------------
	jsValue = trim(f.fname.value);
	if (jsValue == ''||jsValue == null){
	alert ('Please enter your First Name.');
	f.fname.focus();
		return false;
	}
	
	jsValue = trim(f.lname.value);
	if (jsValue == ''||jsValue == null){
	alert ('Please enter your Last Name.');
	f.lname.focus();
		return false;
	}
	
	jsValue = trim(f.company.value);
	if (jsValue == ''||jsValue == null){
	alert ('Please enter your Company Name.');
	f.company.focus();
		return false;
	}
	
	jsValue = trim(f.phone.value);
	if (jsValue == ''||jsValue == null||jsValue.length<7){
	alert ('Please enter a comlete Phone Number.');
	f.company.focus();
		return false;
	}
	
	jsValue = trim(f.phone.value);
	if (jsValue == ''||jsValue == null||jsValue.length<7){
	alert ('Please enter a comlete Phone Number.');
	f.company.focus();
		return false;
	}
	
	//-------------------------------------------------------
	jsValue = trim(f.email.value);
	if (!isValidEmail(jsValue)){
		alert ("Please enter a valid e-mail addesss.");
		f.email.focus();
		return false;
	}
	
	return true;
} 



function trim ( inputStringTrim ) {
	fixedTrim = '';
	lastCh = ' ';
	for (x=0; x < inputStringTrim.length; x++) {
	ch = inputStringTrim.charAt(x);
	if ((ch != ' ') || (lastCh != ' ')) {
	fixedTrim += ch;
	}
	lastCh = ch;
	}
	if (fixedTrim.charAt(fixedTrim.length - 1) == ' ') {
	fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1);
	}
	return fixedTrim;
}

function isValidEmail(emailad){
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check=/@[\w\-]+\./;
  var checkend=/\.[a-zA-Z]{2,3}$/;

  if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
    {
      return false;
    } 
    else 
    {
      return true;
    } 
}

function isValidSSN(value) {
    var re = /^([0-6]\d{2}|7[0-6]\d|77[0-2])([ \-]?)(\d{2})\2(\d{4})$/;
    if (!re.test(value)) { return false; }
    var temp = value;
    if (value.indexOf("-") != -1) { temp = (value.split("-")).join(""); }
    if (value.indexOf(" ") != -1) { temp = (value.split(" ")).join(""); }
    if (temp.substring(0, 3) == "000") { return false; }
    if (temp.substring(3, 5) == "00") { return false; }
    if (temp.substring(5, 9) == "0000") { return false; }
    return true;
}

function hideSpan(e) {
	document.getElementById(e).style.display="none";
}


function showSpan(e) {
	document.getElementById(e).style.display="block";
}

function countLines(strtocount, cols) {
    var hard_lines = 1;
    var last = 0;
    while ( true ) {
        last = strtocount.indexOf("\n", last+1);
        hard_lines ++;
        if ( last == -1 ) break;
    }
    var soft_lines = Math.round(strtocount.length / (cols-1));
    var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
    if ( hard ) soft_lines = hard_lines;
    return soft_lines;
}


/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}
/***********************************************/

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   //customize strValidChars as needed
   var strValidChars = "0123456789"; 
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

String.prototype.isValidDateMMDDYYYY = function() {
  var IsoDateRe = new RegExp("^([0-9]{2})/([0-9]{2})/([0-9]{4})$");

  var matches = IsoDateRe.exec(this);
  if (!matches) return false;

  var composedDate = new Date(matches[3], (matches[1] - 1), matches[2]);

  return ((composedDate.getMonth() == (matches[1] - 1)) &&
          (composedDate.getDate() == matches[2]) &&
          (composedDate.getFullYear() == matches[3]));
}

String.prototype.isValidDateMMYYYY = function() {
  var IsoDateRe = new RegExp("^([0-9]{2})/([0-9]{2})/([0-9]{4})$");

  var matches = IsoDateRe.exec("01/"+this);
  if (!matches) return false;

  var composedDate = new Date(matches[3], (matches[2] - 1), matches[1]);

  return ((composedDate.getMonth() == (matches[2] - 1)) &&
          (composedDate.getDate() == matches[1]) &&
          (composedDate.getFullYear() == matches[3]));
}

String.prototype.isValidDate = function() {
  var IsoDateRe = new RegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$");

  var matches = IsoDateRe.exec(this);
  if (!matches) return false;

  var composedDate = new Date(matches[1], (matches[2] - 1), matches[3]);

  return ((composedDate.getMonth() == (matches[2] - 1)) &&
          (composedDate.getDate() == matches[3]) &&
          (composedDate.getFullYear() == matches[1]));

	//var a = "2007-02-28";
	//alert(a + (a.isValidDate() ? " is a valid date" : " is not a valid date")); 
}
