blnOver = false;

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmpty(fld,keyp) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else {
        fld.style.backgroundPosition = "0 -52px";
    }
    return true;  
}

function validatePhoneMand(fld,keyp) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');      
    
    if (fld.value.length == 0) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else if (isNaN(parseInt(stripped))) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else if ((stripped.length < 6) || (stripped.length > 20)) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else {
        fld.style.backgroundPosition = "0 -52px";
    }
    return true;
}

function validatePhone(fld,keyp) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');   
    
    if (fld.value == "") {
        fld.style.backgroundPosition = "0 0";
        return false;
    } else if (isNaN(parseInt(stripped))) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else if ((stripped.length < 6) || (stripped.length > 20)) {
        fld.style.backgroundPosition = "0 -26px";
        return false;
    } else {
        fld.style.backgroundPosition = "0 -52px";
    }
    return true;
}

function validateEmail(fld,keyp) {
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value=="" && keyp==false) {
        fld.value="Enter your email address:";
        fld.style.backgroundPosition = "0 0";
        document.getElementById('tt-error').innerHTML = "";
        return false;
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.backgroundPosition = "0 -26px";
        document.getElementById('tt-error').innerHTML = "The email address you have entered does not appear to be valid.";
        return false;
    } else if (fld.value.match(illegalChars)) {
        fld.style.backgroundPosition = "0 -26px";
        document.getElementById('tt-error').innerHTML = "Your email address contains invalid characters.";
        return false;
    } else {
        fld.style.backgroundPosition = "0 -52px";
        document.getElementById('tt-error').innerHTML = "";
    }
    
    return true;
}

function HideContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	if(d.length < 1) { return; }
	document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
	if(d.length < 1) { return; }
	if(document.getElementById(d).style.display == "none" || document.getElementById(d).style.display == "") {
		document.getElementById('dropdownaboutus').style.display = "none";
		document.getElementById('dropdownoursoftware').style.display = "none";
		document.getElementById('dropdownnewsevents').style.display = "none";
		document.getElementById('dropdowncontactus').style.display = "none";
		document.getElementById('dropdownclientlogin').style.display = "none";
		document.getElementById(d).style.display = "block";
	} else { 
		document.getElementById(d).style.display = "none";
	}
}

