//function isValidEmail(str) {
//   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
//}
//function ValidateForm(form)
//{

//   if(isValidEmail(form.trialemail))
//   {
//      alert('You have not entered an account number')
//      form.trialemail.focus();
//      return false;
//   }

//return true;

//}


startList = function() {
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById("nav");
        if (navRoot) {
            for (i=0; i<navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName=="LI") {
                    node.onmouseover=function() {
                        this.className+=" over";
                        this.style.background = '#797977';
                    }
                    node.onmouseout=function() {
                        this.className=this.className.replace(" over", "");
                        this.style.background = "#BF171F";
                    }
                }
            }
        }
    }
}

window.onload=startList;
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var newwindow;
function screens(url)
{
	newwindow=window.open(url,'name','scrollbars=yes,height=550,width=690,left=350,top=250');
	if (window.focus) {newwindow.focus()}
}

function customwindow(url,height,width)
{
	var newcustomwindow;
	newcustomwindow=window.open(url, 'custom', 'scrollbars=yes,height=' + height + ',width=' + width + ',left=350,top=250');
	if (window.focus) {newcustomwindow.focus()}
}



function validateEmpty(fld) {
    var error = "";

    if (fld.value.length == 0) {
        fld.style.background = '#f5d3d4';
        error = "<li>A required field has not been filled in.</li>\n"
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validateUsername(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores

    if (fld.value == "") {
        fld.style.background = '#f5d3d4';
        error = "<li>You didn't enter a username.</li>\n";
    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
        fld.style.background = '#f5d3d4';
        error = "<li>The username is the wrong length.</li>\n";
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = '#f5d3d4';
        error = "<li>The username contains illegal characters.</li>\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers

    if (fld.value == "") {
        fld.style.background = '#f5d3d4';
        error = "<li>You didn't enter a password.</li>\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "<li>The password is the wrong length. </li>\n";
        fld.style.background = '#f5d3d4';
    } else if (illegalChars.test(fld.value)) {
        error = "<li>The password contains illegal characters.</li>\n";
        fld.style.background = '#f5d3d4';
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "<li>The password must contain at least one numeral.</li>\n";
        fld.style.background = 'Yellow';
    } 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 = '#f5d3d4';
        error = "<li>You didn't enter an email address.</li>\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = '#f5d3d4';
        error = "<li>Please enter a valid email address.</li>\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = '#f5d3d4';
        error = "<li>The email address contains illegal characters.</li>\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

   if (fld.value == "") {
        error = "<li>You didn't enter a phone number.</li>\n";
        fld.style.background = '#f5d3d4';
    } else if (isNaN(parseInt(stripped))) {
        error = "<li>The phone number contains illegal characters.</li>\n";
        fld.style.background = '#f5d3d4';
    }
    return error;
}

function validateZip(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');

   if (fld.value == "") {
        error = "<li>You didn't enter a postal code.</li>\n";
        fld.style.background = '#f5d3d4';
    }
	else if (isNaN(parseInt(stripped))) {
        error = "<li>The postal code contains illegal characters.</li>\n";
        fld.style.background = '#f5d3d4';
    }
    return error;
}


