/* *********************************************
FORM VALIDATION ::: CONTACT US
********************************************* */
function formValidator(){
	// Make quick references to our fields
	var firstname = document.getElementById('firstname');
	var lastname = document.getElementById('lastname');
	var industry = document.getElementById('industry');
	var comments = document.getElementById('comments');
	var email = document.getElementById('email');
	
	// Check each input in the order that it appears in the form!
	if(notEmpty(industry, "Please enter a valid Industry.")){
		if(notEmpty(industry, "Please enter a valid Industry.")){
			if(notEmpty(industry, "Please enter a valid Industry.")){
				if(notEmpty(industry, "Please enter a valid Industry.")){
					if(notEmpty(industry, "Please enter a valid Industry.")){

						if(notEmpty(industry, "Please enter a valid Industry.")){
							if(notEmpty(industry, "Please enter a valid Industry.")){
								if(notEmpty(industry, "Please enter a valid Industry.")){
									if(notEmpty(comments, "Please enter a valid Comment.")){
										return true;
									}
								}
							}
						}

					}
				}
			}
		}
	}

	return false;

}

/* *********************************************
FORM VALIDATION ::: SERVICE INQUIRY
********************************************* */
function formValidatorServiceInquiry(){
	// Make quick references to our fields
	var firstname = document.getElementById('firstname');
	var lastname = document.getElementById('lastname');
	var industry = document.getElementById('industry');
	var comments = document.getElementById('comments');
	var email = document.getElementById('email');
	var other = document.getElementById('other');

	// Check each input in the order that it appears in the form!
	if(notEmpty(industry, "Please enter a valid Industry.")){
		if(notEmpty(industry, "Please enter a valid Industry.")){
			if(notEmpty(industry, "Please enter a valid Industry.")){
				if(notEmpty(industry, "Please enter a valid Industry.")){
					if(notEmpty(industry, "Please enter a valid Industry.")){

						if(notEmpty(industry, "Please enter a valid Industry.")){
							if(notEmpty(industry, "Please enter a valid Industry.")){
								if(notEmpty(industry, "Please enter a valid Industry.")){



if(other.checked == true) {
	if(notEmpty(comments, "Please enter a valid Comment.")){
		return true;
	}
} else {
	return true;
}


//									if(notEmpty(comments, "Please enter a valid Comment.")){
//										return true;
//									}
								}
							}
						}

					}
				}
			}
		}
	}

	return false;

}


/* *********************************************
FORM VALIDATION
********************************************* */
function formValidator_bak(){
	// Make quick references to our fields
	var firstname = document.getElementById('firstname');
	var lastname = document.getElementById('lastname');
	var industry = document.getElementById('industry');
	var comments = document.getElementById('comments');
	var email = document.getElementById('email');
	
	// Check each input in the order that it appears in the form!
	if(notEmpty(industry, "Please enter a valid Industry.")){
		if(notEmpty(industry, "Please enter a valid Industry.")){
			if(notEmpty(industry, "Please enter a valid Industry.")){
				if(notEmpty(industry, "Please enter a valid Industry.")){
					if(notEmpty(industry, "Please enter a valid Industry.")){

						if(notEmpty(email, "Please enter a valid E-Mail Address.")){
							if(emailValidator(email, "Please enter a valid E-Mail Address.")){
								if(notEmpty(email, "Please enter a valid E-Mail Address.")){
									if(notEmpty(comments, "Please enter a valid Comment.")){
										return true;
									}
								}
							}
						}

					}
				}
			}
		}
	}

	return false;

}





/* *********************************************
CPE FORM VALIDATION
********************************************* */
function formValidatorCPE(){
	// Make quick references to our fields
	var name = document.getElementById('contactname');
	var company = document.getElementById('firmname');
	var address = document.getElementById('address');
	var city = document.getElementById('city');
	var state = document.getElementById('state');
	var zip = document.getElementById('zip');
	var email = document.getElementById('email');
	var phone = document.getElementById('phone');
	
	// Check each input in the order that it appears in the form!
	if(notEmpty(company, "Please enter a valid Firm Name.")){
		if(notEmpty(name, "Please enter a valid Contact Name.")){
			if(notEmpty(address, "Please enter a valid Address.")){
				if(notEmpty(city, "Please enter a valid City.")){
					if(notEmpty(state, "Please enter a valid State.")){
						if(notEmpty(zip, "Please enter a valid Zip/Postal Code.")){
							if(emailValidator(email, "Please enter a valid Email Address.")){
								if(notEmpty(phone, "Please enter a valid Phone Number.")){
									return true;
								}
							}
						}
					}
				}
			}
		}
	}

	return false;

}


/* *********************************************
SUBMIT RESUME VALIDATION
********************************************* */
function formValidatorSubmitResume(){
	// Make quick references to our fields
	var fullname = document.getElementById('fullname');
	var position = document.getElementById('position');
	var emailaddress = document.getElementById('emailaddress');

	var daytimephone = document.getElementById('daytimephone');
	var salaryrequirements = document.getElementById('salaryrequirements');

	
	// Check each input in the order that it appears in the form!
	if(notEmpty(fullname, "Please enter a valid Full Name.")){
		if(notEmpty(position, "Please enter a valid Position.")){
			if(emailValidator(emailaddress, "Please enter a valid Email Address.")){

				if(notEmpty(daytimephone, "Please enter a valid Day Time Number.")){
					if(notEmpty(salaryrequirements, "Please enter a valid Salary Requirements.")){

						return true;

					}
				}

			}
		}
	}
	return false;
}

/* *********************************************
SUBMIT RESUME VALIDATION
********************************************* */
function formValidatorSubmitFile(){
	// Make quick references to our fields
	var recipient = document.getElementById('recipient');

	// Check each input in the order that it appears in the form!
	if(notEmpty(recipient, "Please enter a valid Reciipient.")){
		if(notEmpty(recipient, "Please enter a valid Recipient.")){
			if(emailValidatorAlliantgroup(recipient, "Please enter a valid Recipient.")){


						return true;


			}
		}
	}
	return false;
}


function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}


// *****************************************************
// HIDE||SHOW DETAILS [div]
// *****************************************************
function ToggleSubDisplay(id, idLimit, objTarget) 
{
	var elemDiv;
	var elemTarget;
	elemTarget = document.getElementById(objTarget)
	
	// SHOW ELEMENTS	
	for(var i=1; i<= idLimit; i++) {
		elemDiv = id + i;

		var elemA = document.getElementById(elemDiv);

		if (elemA == elemTarget) {


				if(elemA.style.visibility == '') {
						elemA.style.display = 'none';
						elemA.style.visibility = 'hidden';
				} else {

					if(elemA.style.visibility == 'visible') {
						elemA.style.display = 'none';
						elemA.style.visibility = 'hidden';
					} else {
						elemA.style.display = 'block';
						elemA.style.visibility = 'visible';
					}

				}


			}
		}
}

function ToggleSubDisplayON(id, idLimit, objTarget) 
{
	var elemDiv;
	var elemTarget;
	elemTarget = document.getElementById(objTarget)
	
	// SHOW ELEMENTS	
	for(var i=1; i<= idLimit; i++) {
		elemDiv = id + i;

		var elemA = document.getElementById(elemDiv);

		if (elemA == elemTarget) {
			elemA.style.display = 'block';
			elemA.style.visibility = 'visible';
		}
	}
}

function ToggleSubDisplayOFF(id, idLimit, objTarget) 
{
	var elemDiv;
	var elemTarget;
	elemTarget = document.getElementById(objTarget)
	
	// SHOW ELEMENTS	
	for(var i=1; i<= idLimit; i++) {
		elemDiv = id + i;

		var elemA = document.getElementById(elemDiv);

		if (elemA == elemTarget) {
			elemA.style.display = 'none';
			elemA.style.visibility = 'hidden';
		}
	}
}


