function checkForm(e) {

    var errorVal = "";
    document.getElementById("picname").setAttribute('src', 'img/errornone.jpg');
    document.getElementById("picemail").setAttribute('src', 'img/errornone.jpg');
    document.getElementById("picphone").setAttribute('src', 'img/errornone.jpg');
    errorVal = errorCheck();
    if (errorVal==false){
        if (e.srcElement) {	//IIE
            e.returnValue=false;
        }
    }else {
        getItUp();
    //return true;
    }
}
	
function errorCheck() {
    var errormess="";
    errormess = checkPhone();
    errormess += checkEmail();
    errormess += checkName();
    return errorReport(errormess);
}

//phone check
function checkPhone() {
    var returnVal="";
    var checkphone = document.getElementById("phone").value;
    checkphone += "";
    var phoneReg = new RegExp("[0-9]{10,}");
    //var phonedefault = "(303)395-5340";
    //
    //if( checkphone==phonedefault || checkphone.length<10 ) {
    if (!phoneReg.exec(checkphone)){
        document.getElementById("picphone").setAttribute('src', picerror);
        document.getElementById("phone").focus();
        returnVal = "- Enter a phone number of at least 10 digits.<br />";
    }
    return returnVal;
}
			
//email check
function checkEmail() {
    var returnVal="";
    var checkemail=document.getElementById("email").value;
    var emailreg = new RegExp("[a-zA-Z0-9]@[a-zA-Z0-9]");
    if (!emailreg.exec(checkemail)){
        document.getElementById("picemail").setAttribute('src', picerror);
        document.getElementById("email").focus();
        returnVal="- Make sure your email includes an '@'.<br />";
    }
    return returnVal;
}
			
//name check
function checkName() {
    var returnVal="";
    var checkname=document.getElementById("fullname").value;
    //var namereg = new RegExp("^[A-Z]\."); 	//old
    var namereg = new RegExp(".");	//only check for any information
    if(!namereg.exec(checkname)){
        document.getElementById("picname").setAttribute('src', picerror);
        document.getElementById("fullname").focus();
        returnVal="- Your name needs at least 1 character.<br />";
    }
    return returnVal;
}
		
	
//alert message
function errorReport(errormess) {
    if (errormess=="") {
        return true;
    } else {
        var finalmessage = "Please correct or fill in the marked fields so we can contact you.<br />";
        finalmessage += errormess;
        document.getElementById("errorreport").innerHTML=finalmessage;
        document.getElementById("errorreport").focus();
        return false;
    }
}
	

//Causes a clearing of the fields being focused on (initially)
function focusMe() {
//Not being used it is distractive to the user
//document.getElementById("phone").onfocus=clearPhone;
//document.getElementById("question").onfocus=clearObjective;
}
		
//clears the Phone Number	
//Not being used
function clearPhone() {
    document.getElementById("phone").value="";
}
		


//selects from drop down box via get/post variables
function selectType(type) {
    var conType;
    if (document.getElementById("type")) {
        conType  = document.getElementById("type");
        
        for(i=0;i<conType.length;i++) {
            if(conType.options[i].value == type) {
                conType.selectedIndex = i;
                colorchange=conType.style;
            //colorchange.backgroundColor="#f57f27";
            //colorchange.color="#fff";
            //return;
            }
        }
    }
    return;
}
		
//selects from drop down box via get/post variables
function selectTopic(topic) {
    var conTopic;
    if (document.getElementById("topic")){
        conTopic = document.getElementById("topic");
        for(i=0;i<conTopic.length;i++) {
            if(conTopic.options[i].value == topic) {
                conTopic.selectedIndex = i;
                colorchange=conTopic.style;
                //colorchange.backgroundColor="#f57f27";
                //colorchange.color="#fff";
                //return;
            }
        }
    }
    return;
}

//clears the Objective
//Not being used
function clearObjective() {
    if (document.getElementById("question")){

        currentText = document.getElementById("question").value;

        if(currentText.indexOf("Please describe") >= 0 ) {
            document.getElementById("question").value = "";
        } else {
            //do nothing, they edited it
        }
    }
}


//sets initial default text to the learning objective
function setLearningObjective(classname) {
    var defaulttext = "Please describe why you are looking for training.";

    if (document.getElementById("question")){
        currentText = document.getElementById("question").value;
        if(currentText.length == 0 || currentText.indexOf("Please describe why") >= 0 ) {
            document.getElementById("question").value = defaulttext;
        } else {
            //do nothing, they edited it
        }
    }
}


function checkObjective() {
    var defaulttext = "Please describe why you are looking for training.    ";
    if(document.getElementById("question").value.length == 0) {
        setLearningObjective(null);
    }

}