function textBoxValidation( inputId )
{
	var input = document.getElementById( inputId );
	
	if( isEmpty( input.value ) )
	{
		input.style.backgroundColor="pink";
		return false;
	}
	else
	{
		input.style.backgroundColor="white";
		return true;
	}
}

function dropDownValidation( inputId )
{
	var input = document.getElementById( inputId );
		
	if( input.value == "-- Select --" )
	{
		input.style.backgroundColor="pink";
		return false;
	}
	else
	{
		input.style.backgroundColor="white";
		return true;
	}
}

//this is the function used to validate the contact form.
function validate(AdmissionForm)
{
	var isValid = true;	
	var emailval = document.getElementById( "EmailVal" );
	var cosmetologist = document.getElementById( "cosmetologist" );
	var manicurist = document.getElementById( "manicurist" );
	var aesthetician = document.getElementById( "aesthetician" );
	var option = document.getElementById( "other" );
	
	if( option.selected == true )
	{
		if( textBoxValidation( AdmissionForm.otherReference.id ) == false )
			isValid=false;
	}
		
	if( cosmetologist.checked == false && manicurist.checked == false && aesthetician.checked == false )
	{
		alert( "you must select which program you are interested in!");
		isValid = false;
	}
	
	if( dropDownValidation( AdmissionForm.hsgraduation.id ) == false )
	    isValid = false;
	    
	if( dropDownValidation( AdmissionForm.campus.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.contact.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.education.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.beginSchool.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.reference.id ) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.firstName.id ) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.lastName.id) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.phone.id) == false )
		isValid = false;	
		
	if( textBoxValidation( AdmissionForm.phone2.id) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.address1.id) == false )
		isValid = false;	
	
	if( textBoxValidation( AdmissionForm.email.id) == false )
		isValid = false;
	else if( isEmail( AdmissionForm.email.value ) == false)
	{
		emailval.style.display="block";
		isValid = false;
		AdmissionForm.email.style.backgroundColor="pink";
	}
	else if (isEmail( AdmissionForm.email.value ) == true )
		emailval.style.display="none";
			
	if( textBoxValidation( AdmissionForm.city.id) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.state.id) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.zip.id) == false )
		isValid = false;
				
    var validator = document.getElementById( "BlanketValidator" );
	var validator2 = document.getElementById( "BlanketValidator2" );
	
	if( isValid == false )
	{
		validator.style.display = "block";
		validator2.style.display = "block";
	}
	else
	{
		validator.style.display = "none";
		validator2.style.display = "none";
	}
	
	return isValid;
}


function validateDM(AdmissionForm)
{
	var isValid = true;	
	var emailval = document.getElementById( "EmailVal" );
	var cosmetologist = document.getElementById( "cosmetologist" );
	var manicurist = document.getElementById( "manicurist" );
	var aesthetician = document.getElementById( "aesthetician" );
	var option = document.getElementById( "other" );
	

		
	if( cosmetologist.checked == false && manicurist.checked == false && aesthetician.checked == false )
	{
		alert( "you must select which program you are interested in!");
		isValid = false;
	}
	
	if( dropDownValidation( AdmissionForm.hsgraduation.id ) == false )
	    isValid = false;
	    
	if( dropDownValidation( AdmissionForm.campus.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.contact.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.education.id ) == false )
		isValid = false;
	
	if( dropDownValidation( AdmissionForm.beginSchool.id ) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.firstName.id ) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.lastName.id) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.phone.id) == false )
		isValid = false;	
		
	if( textBoxValidation( AdmissionForm.phone2.id) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.address1.id) == false )
		isValid = false;	
	
	if( textBoxValidation( AdmissionForm.email.id) == false )
		isValid = false;
	else if( isEmail( AdmissionForm.email.value ) == false)
	{
		emailval.style.display="block";
		isValid = false;
		AdmissionForm.email.style.backgroundColor="pink";
	}
	else if (isEmail( AdmissionForm.email.value ) == true )
		emailval.style.display="none";
			
	if( textBoxValidation( AdmissionForm.city.id) == false )
		isValid = false;
			
	if( textBoxValidation( AdmissionForm.state.id) == false )
		isValid = false;
		
	if( textBoxValidation( AdmissionForm.zip.id) == false )
		isValid = false;
				
    var validator = document.getElementById( "BlanketValidator" );
	var validator2 = document.getElementById( "BlanketValidator2" );
	
	if( isValid == false )
	{
		validator.style.display = "block";
		validator2.style.display = "block";
	}
	else
	{
		validator.style.display = "none";
		validator2.style.display = "none";
	}
	
	return isValid;
}


function manageRadios( yesRadioId, noRadioId, textBoxId )
{
	var YesId = document.getElementById( yesRadioId );
	var NoId = document.getElementById( noRadioId );
	var textbox = document.getElementById( textBoxId );
		
    if( YesId.checked == true )
    {
        if( textBoxValidation( textbox.id ) == false )
			return false;
		else
		{
			makeMeWhiteAgain( textbox.id );
			return true;
		}
    }
    else if( NoId.checked == true )
    {
		textbox.style.backgroundColor="white";
		return true;		
	}
}

function makeMeWhiteAgain( inputId )
{
	var input = document.getElementById( inputId );
	
	if( !isEmpty( input.value ) )
		input.style.backgroundColor="white";
}



function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

function isEmail (s)
{   if (isEmpty(s)) 
     return false;   
 
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

function copyrightYear()
{
	var d = new Date();
	document.write(d.getFullYear());
}

