// JavaScript Document
reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
function makeArray(){
    reqList = [];
    for(elmnts=0; elmnts<document.getElementById("subForm").length; elmnts++){
        var ids = document.getElementById("subForm")[elmnts].id;
        if(ids!==""){
			reqList.push(ids);
		}
    }
}
function checkMandatory(){
    makeArray();
    var error_msg = "";
    for(i=0; i< reqList.length; i++){
        var noSelect = reqList[i];
        if(document.getElementById(noSelect).selectedIndex==0 || document.getElementById(noSelect).value == ""){
			if(document.getElementById(noSelect).selectedIndex==0){
            	error_msg = "<p>Please make a selection</p>";
			}else{
            	error_msg = "<p>This is a required field</p>";
			}
            document.getElementById("req_"+noSelect).innerHTML = (error_msg);
            document.getElementById("req_"+noSelect).style.display = "block";
			if (navigator.appName == 'Microsoft Internet Explorer'){
				document.getElementById(noSelect).className = 'missing';
			}else{
            	document.getElementById(noSelect).setAttribute("class", "missing");
			}
        }else if(document.getElementById("aidpu-aidpu").value !== "" && reg.test(document.getElementById("aidpu-aidpu").value)==false){
            error_msg = "<p>This is not a valid email address</p>";
            document.getElementById("req_aidpu-aidpu").innerHTML = (error_msg);
            document.getElementById("req_aidpu-aidpu").style.display = "block";
			if (navigator.appName == 'Microsoft Internet Explorer'){
				document.getElementById("aidpu-aidpu").className = 'missing';
			}else{
            	document.getElementById("aidpu-aidpu").setAttribute("class", "missing");
			}
        }else{
            document.getElementById("req_"+noSelect).style.display = "none";
			if (navigator.appName == 'Microsoft Internet Explorer'){
				document.getElementById(noSelect).className = 'normal';
			}else{
            	document.getElementById(noSelect).setAttribute("class", "normal");
			}
        }
    }
    if (error_msg == ""){
        return true;
    }else{
        document.getElementById("aidpu-aidpu").focus();
        return false;
    }
}
function filled(){
    makeArray();
    for(j=0; j<reqList.length; j++){
        var passed = reqList[j];
        if(document.getElementById(passed).selectedIndex>0 || document.getElementById(passed).value !=="" && document.getElementById(passed).nodeName == "INPUT"){
            document.getElementById("accept_"+passed).src="http://www.trimbleextensions.com/images/filled.png";
            document.getElementById("req_"+passed).style.display = "none";
			if (navigator.appName == 'Microsoft Internet Explorer'){
				document.getElementById(passed).className = 'normal';
			}else{
            	document.getElementById(passed).setAttribute("class", "normal");
				}
        }else{
            document.getElementById("accept_"+passed).src="http://www.trimbleextensions.com/images/required.png";
        }   
    }
	if(document.getElementById("aidpu-aidpu").value !== "" && reg.test(document.getElementById("aidpu-aidpu").value)==false){
		document.getElementById("accept_aidpu-aidpu").src="http://www.trimbleextensions.com/images/required.png";
		if(navigator.appName == 'Microsoft Internet Explorer'){
			document.getElementById("aidpu-aidpu").className = 'missing';
		}else{
			document.getElementById("aidpu-aidpu").setAttribute("class", "missing");
		}
            document.getElementById("req_aidpu-aidpu").style.display = "block";
            document.getElementById("req_aidpu-aidpu").innerHTML = "<p>This is not a valid email address</p>";
	}
}
