<!--hide script from old browsers
//****************************************sfhover for IE6 dropdowns*******************************
sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//************************************************************************************************
//****************************************Whitepaper download form validation*********************
function validateWhitepaper(theForm) {
  var reason = "";
  reason += validateEmptyName(theForm.name);
  reason += validateEmptyCompany(theForm.company);
  reason += validateEmail(theForm.email);
  reason += validateEmptyPhone(theForm.phone);
  reason += validateEmptyEmployees(theForm.employees);
  
  if (reason != "") {
    alert("Some fields need correction:\n" + reason);
    if (reason.indexOf("your name") != -1) theForm.name.focus();
    else if (reason.indexOf("company") != -1) theForm.company.focus();
    else if (reason.indexOf("email") != -1) theForm.email.focus();
    else if (reason.indexOf("phone") != -1) theForm.phone.focus();
    else if (reason.indexOf("employees") != -1) theForm.employees.focus();
    return false;
  }
  return true;
}
//************************************************************************************************
//****************************************Contact form validation*********************************
function validateContact(theForm) {
var reason = "";
reason += validateEmptyName(theForm.contactname);
reason += validateEmail(theForm.email);
reason += validateEmptyComments(theForm.comments);
if (reason != "") {
alert("Some fields need correction:\n" + reason);
if (reason.indexOf("name") != -1){
theForm.contactname.focus();}
else if (reason.indexOf("email") != -1) {
theForm.email.focus();}
else if (reason.indexOf("comments") != -1){
theForm.comments.focus();}
return false;
}
return true;
}
//**************************************************************************************************
//****************************************Partner register form validation**************************
function validateRegister(theForm) {
var reason = "";
// reason += validateEmptyName(theForm.contactname);
// reason += validateEmail(theForm.email);
// reason += validateEmptyComments(theForm.comments);

reason += validateEmptyAdministrator(theForm.administrator);
reason += validateEmptyCompany(theForm.company);
reason += validateEmptyAddress(theForm.address);
reason += validateEmptyCity(theForm.city);
reason += validateEmail(theForm.email);
reason += validateEmptyPhone(theForm.phone);

if (reason != "") {
alert("Some fields need correction:\n" + reason);
// if (reason.indexOf("name") != -1){
// theForm.contactname.focus();}
// else if (reason.indexOf("email") != -1) {
// theForm.email.focus();}
// else if (reason.indexOf("comments") != -1){
// theForm.comments.focus();}

if (reason.indexOf("administrator's") != -1){
theForm.administrator.focus();}
else if (reason.indexOf("company's") != -1){
theForm.company.focus();}
else if (reason.indexOf("mailing") != -1){
theForm.address.focus();}
else if (reason.indexOf("city") != -1){
theForm.city.focus();}
else if (reason.indexOf("email") != -1) {
theForm.email.focus();}
else if (reason.indexOf("phone") != -1){
theForm.phone.focus();}

return false;
}
return true;
}
//**************************************************************************************************
//*****************************************Sign form validation********************************
function validateSignup(theForm) {
var reason = "";

reason += validateEmptyDomain(theForm.domains);
reason += validateEmptyMailboxes(theForm.mailboxes);
reason += validateEmptyAdministrator(theForm.administrator);
reason += validateEmptyCompany(theForm.company);
reason += validateEmptyAddress(theForm.address);
reason += validateEmptyCity(theForm.city);
reason += validateEmail(theForm.email);
reason += validateEmptyPhone(theForm.phone);
reason += validateEmptyItco(theForm.itco);

if (reason != "") {
alert("Some fields need correction:\n" + reason);
if (reason.indexOf("services") != -1){
theForm.checkEmail.focus();}
else if (reason.indexOf("domain") != -1){
theForm.domains.focus();}
else if (reason.indexOf("mailboxes") != -1){
theForm.mailboxes.focus();}
// else if (reason.indexOf("field") != -1){
// theForm.mailboxes.focus();}
else if (reason.indexOf("address(es)") != -1){
theForm.ipAddress.focus();}
else if (reason.indexOf("notification") != -1) {
theForm.emailNotify.focus();}
else if (reason.indexOf("administrator's") != -1){
theForm.administrator.focus();}
else if (reason.indexOf("company's") != -1){
theForm.company.focus();}
else if (reason.indexOf("mailing") != -1){
theForm.address.focus();}
else if (reason.indexOf("city") != -1){
theForm.city.focus();}
else if (reason.indexOf("email") != -1) {
theForm.email.focus();}
else if (reason.indexOf("phone") != -1){
theForm.phone.focus();}
else if (reason.indexOf("support") != -1){
theForm.itco.focus();}


// if (reason != "") {
// alert("Some fields need correction:\n" + reason);
// if (reason.indexOf("administrator's") != -1){
// theForm.administrator.focus();}
// else if (reason.indexOf("company's") != -1){
// theForm.company.focus();}
// else if (reason.indexOf("mailing") != -1){
// theForm.address.focus();}
// else if (reason.indexOf("city") != -1){
// theForm.city.focus();}
// else if (reason.indexOf("email") != -1) {
// theForm.email.focus();}
// else if (reason.indexOf("phone") != -1){
// theForm.phone.focus();}
// else if (reason.indexOf("support") != -1){
// theForm.itco.focus();}
// else if (reason.indexOf("domain") != -1){
// theForm.domainname.focus();}
// else if (reason.indexOf("mailboxes") != -1){
// theForm.users.focus();}
// else if (reason.indexOf("address(es)") != -1){
// theForm.ipAddress.focus();}
// else if (reason.indexOf("email") != -1) {
// theForm.emailNotify.focus();}
// else if (reason.indexOf("terms") != -1){
// theForm.subscribe.focus();}
return false;
}
return true;
}
//**************************************************************************************************
//**************************************Individual contact validate functions***********************
function validateEmptyName(fld) {
var error = "";
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your name.\n"
}
else {
fld.style.background = 'White';
}
return error;
}

function trim(s){
return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
var error="";
var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
if (fld.value == "") {
fld.style.background = '#D3D3D3';
error = "Please enter an email address.\n";
} else if (!emailFilter.test(tfld)) {              //test email for illegal characters
fld.style.background = '#D3D3D3';
error = "Please enter a valid email address.\n";
} else if (fld.value.match(illegalChars)) {
fld.style.background = '#D3D3D3';
error = "The email address contains illegal characters.\n";
} else {
fld.style.background = 'White';
}
return error;
}

function validateEmptyComments(fld) {
var error = "";
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your comments.\n"
} else {
fld.style.background = 'White';
}
return error;  
}
//**************************************************************************************************
//**************************************Individual signup validate functions************************
// function validateEmptyServices(fldEmail, fldBlacklist) {
// var error = "";	
// if (fldEmail.checked == false && fldBlacklist.checked == false) {
// fldEmail.style.background = '#D3D3D3';
// fldBlacklist.style.background = '#D3D3D3';
// error = "Please indicate which services you are interested in.\n"
// } 
// else {
// fldEmail.style.background = 'White';
// fldBlacklist.style.background = 'White';
// }
// return error; 
// }

function validateEmptyAdministrator(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter administrator's name.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyCompany(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your company's name.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyAddress(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your mailing address.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyCity(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your city.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyPhone(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your phone number.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyItco(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your IT support company.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyDomain(fld) {
var error = "";	
if (fld.value.length == 0) {
fld.style.background = '#D3D3D3';
error = "Please enter your domain name.\n"
} else {
fld.style.background = 'White';
}
return error; 
}

function validateEmptyMailboxes(fld) {
	var error = "";	
	if (fld.value.length == 0) {
		fld.style.background = '#D3D3D3';
		error = "Please enter number of mailboxes.\n"
	}
	else if (!IsNumeric(fld.value)) {
		fld.style.background = '#D3D3D3';
		error = "Please enter only numbers in mailboxes field.\n"
	}
	else {
		fld.style.background = 'White';
	}
	return error; 
}

function validateEmptyEmployees(fld) {
  var error = "";
  if (fld.value.length == 0) {
    fld.style.background = '#D3D3D3';
    error = "Please enter number of employees.\n"
  }
  else if (!IsNumeric(fld.value)) {
    fld.style.background = '#D3D3D3';
    error = "Please enter only numbers in employees field.\n"
  }
  else {
    fld.style.background = 'White';
  }
  return error; 
}

// function validateEmptyIP(fld) {
// var error = "";	
// if (fld.value.length == 0) {
// 	fld.style.background = '#D3D3D3';
// 	error = "Please enter IP address(es).\n"
// } 
// else {
// 	fld.style.background = 'White';
// }
// return error;
// }
// 
// function validateEmailNotify(fld) {
// var error="";
// var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
// var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
// var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
// if (fld.value == "") {
// fld.style.background = '#D3D3D3';
// error = "Please enter an email notification address.\n";
// } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
// fld.style.background = '#D3D3D3';
// error = "Please enter a valid email notification address.\n";
// } else if (fld.value.match(illegalChars)) {
// fld.style.background = '#D3D3D3';
// error = "The email notification address contains illegal characters.\n";
// } else {
// fld.style.background = 'White';
// }
// return error;
// }

function IsNumeric(sText) {
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	
	for (i = 0; i < sText.length && IsNumber == true; i++) { 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) {
		IsNumber = false;
		}
	}
	return IsNumber;
}

// end hiding script from old browsers-->
