function checkForm()
{
	var form = document.Entry;
	if (form.submit_form.value == "true")
	{
		alert("Form has been submitted. Please wait for Response from the server.");
		return false;
	}
	if(!checkSelect(form.elements["semester"],"a Year and Semester"))return false;
	if(!checkSelect(form.elements["program"],"a Degree Program"))return false;
	if(!checkSelect(form.elements["citizenship"],"a Country of Citizenship"))return false;
	if(!checkSelect(form.elements["dayofbirth"],"a Day of Birth"))return false;
	if(!checkSelect(form.elements["monthofbirth"],"a Month of Birth"))return false;
    if(!checkSelect(form.elements["yearofbirth"],"a Year of Birth"))return false;
	if(!checkSelect(form.elements["gender"],"a Gender"))return false;
	if(!checkSelect(form.elements["educationallevel"],"Level of Education"))return false;
    if(!checkSelect(form.elements["countryofbirth"],"a Country of Birth"))return false;
	if(!checkSelect(form.elements["heardaboutus"],"How Did You Know About Us"))return false;
    if(!checkEmpty(form.elements["firstname"],"First Name"))return false;
	if(form.firstname.value.length < 3)
	{
		alert("Your First Name must be more than 2 chars.");
		form.firstname.focus()
		return false;
	}
	var allowedinname="abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõö÷øùüúýþÿº¿³ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÝÞßª¯² ";
		for(i=0; i<form.firstname.value.length; i++)
		{
			charone =form.firstname.value.charAt(i);
			if((allowedinname.indexOf(charone) == "-1"))
			{ 
				alert("Your First Name must contain characters only.");
				form.firstname.focus()
				return false;	
			}
		}
	if(!checkEmpty(form.elements["lastname"],"Last Name"))return false;
	if(form.lastname.value.length < 3)
	{
		alert("Your Last Name must be more than 2 chars.");
		form.lastname.focus()
		return false;
	}
	for(i=0; i<form.lastname.value.length; i++)
		{
			charone =form.lastname.value.charAt(i);
			if((allowedinname.indexOf(charone) == "-1"))
			{ 
				alert("Your Last Name must contain characters only.");
				form.lastname.focus()
				return false;
			}
		}
	if(!checkEmpty(form.elements["email"],"Your Email"))return false;
	if (!emailCheck(form.email.value))  { 
		alert("Please enter valid E-mail Address");
		form.email.focus();
		return false;	
	}
	if(!checkEmpty(form.elements["address"],"a Street Address"))return false;
	var allowedchars="abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõö÷øùüúýþÿº¿³ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÝÞßª¯²#,. /-";
	var allowednumbers="0123456789";
	var totalallowed="abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõö÷øùüúýþÿº¿³ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÝÞßª¯²0123456789#,. /-";
	if(form.address.value.length < 5)
	{
		alert("Your Address must be at least 5 characters.");
		form.address.focus()
		return false;
	}
		for(i=0; i<form.address.value.length; i++)
			{
			charone =form.address.value.charAt(i);
			if((allowedchars.indexOf(charone) == "-1"))
			{ 
					var accept=1;
			}
			}
		for(i=0; i<form.address.value.length; i++)
			{
			charone =form.address.value.charAt(i);
			if((allowednumbers.indexOf(charone) == "-1"))
			{ 
					var accept2=2; 
			}
			}
		for(i=0; i<form.address.value.length; i++)
			{
			charone =form.address.value.charAt(i);
			if((totalallowed.indexOf(charone) == "-1"))
			{ 
				alert("Please enter Valid Address.");
				form.address.focus()
				return false;	
			}
			}
		if(accept != 1 || accept2 != 2)
		{
			alert("Your Address must contain characters and numbers.");
			form.address.focus()
			return false;
		}
	if(!checkEmpty(form.elements["city"],"City"))return false;
	if(form.city.value.length < 4)
	{
		alert("The City Name must be at least 4 characters.");
		form.address.focus()
		return false;
	}
	
	
    if(!checkEmpty(form.elements["zipcode"],"Your Zip/Postal Code"))return false;
	
	if(form.zipcode.value.length < 3)
	{
		alert("Your Zip/Postal Code must be at least 3 characters.");
		form.zipcode.focus()
		return false;
		}
	if(form.mobile.value == null || form.mobile.value.length == 0)
	{
		alert("Please provide your Mobile Phone Number.");
		form.mobile.focus()
		return false;
	}
	else
	{
		if (form.mobile.value.length	< 4)
		{
			alert("Your Mobile Phone number must be more than 4 digits.");
			form.mobile.focus();
			return false;
		}
		if (isInteger(form.mobile.value) == false){
			alert("No letters and brackets allowed in your Mobile Phone number.");
			form.mobile.focus();
			return false;			
       }
	}		
	form.cmd.value = "data";
	form.submit_form.value = "true";
	return true;
}

function isDigit(c){
	var findisDigit;
	if ((c >= "0") && (c <= "9"))
	{
		findisDigit = true;
	}else if((c == "-" ) ||(c == " " )){
		findisDigit= true;
	}else {
		findisDigit= false;	
	}
	return findisDigit ;

	/*
	if ((c >= "0") && (c <= "9"))
	{
		findisDigit = true;
	}else if((c.indexOf( "-" ) == -1) ||(c.indexOf( " " ) == -1)){
		findisDigit= true;
	}else {
		findisDigit= false;	
	}
	return findisDigit ;
	*/
	
   //return ((c >= "0") && (c <= "9") )
}
function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}


//----------------------------------------------

// trimming a value
function trim(value) {
  var tmpstr = ltrim(value);

  return rtrim(tmpstr);
}

// left trim
function ltrim(value) {

  while (1) {
    if (value.substring(0,1) != " ")
      break;
    value = value.substring(1, value.length);
  }

  return value;
}

// right trim
function rtrim(value) {

  while (1) {
    if (value.substring(value.length - 1, value.length) != " ")
      break;
    value = value.substring(0, value.length - 1);
  }

  return value;
}


// For checking select boxes
function checkSelect(theField,s)
{
	var fieldValue = trim(theField.value);
	if (fieldValue == "-1") return warnEmpty1(theField,s);
	else 
	return true;
}

function isEmpty(s)
{   
	s=trim(s);
	return ((s == null) || (s.length == 0))
}

function warnEmpty (theField, s)
{   
	theField.focus();
	alert("Please Enter " +s);
	return false;
}

function warnEmpty1 (theField, s)
{   
	theField.focus();
	alert("Please Select " +s);
	return false;
}

function checkEmpty (theField, s)
{
   if(isEmpty(theField.value)) return warnEmpty (theField, s);
   else return true;
}


function isWhitespace (s)

{   var i;

	var whitespace = " \t\n\r";
    // 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 emailCheck(emailStr)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	if (user.match(userPat)==null) {
		return false
	}
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				return false
			}
		}
		return true
	}
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		return false
	}
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
		domArr[domArr.length-1].length>3) {
		document.Entry.Email.focus();
		return false
	}
	if (len<2) {
	   return false
	}
	return true;
}

//Display program message
function checkRN()

{
 var rn = document.Entry.program.options[document.Entry.program.selectedIndex].value ;
 if ( rn == "SIM" ) {
  alert("Thank you for your interest in the Specialist in International Management Ukraine degree program at Wisconsin International University.\n\nIf you would like information on one of our other degree programs, please select another choice.  Thanks again \nfor your interest in Wisconsin International University and we hope we can help you reach your educational goals.");
  }
 if ( rn == "BBA" ) {
  alert("Thank you for your interest in the Bachelor of Business Administration degree program at Wisconsin International University.  All applicants to this program are expected to meet the following admission requirements:\n\n-1) A high school diploma or equivalent \n-2) A minimum score of 550 on the paper-based exam or 213 on the computer-based exam of the Test of English as a Foreign Language (TOEFL) for non-native speakers of English  \n-3) Submit certificate and record of high school transcripts  \n\nIf you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals.");
  }
 if ( rn == "BIM" ) {
  alert("Thank you for your interest in the Bachelor of International Management degree program at Wisconsin International University.  All applicants to this program are expected to meet the following admission requirements:\n\n-1) A high school diploma or equivalent \n-2) A minimum score of 550 on the paper-based exam or 213 on the computer-based exam of the Test of English as a Foreign Language (TOEFL) for non-native speakers of English  \n-3) Submit certificate and record of high school transcripts  \n\nIf you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals.");
  }

if (rn =="BBA/BIM"){
alert("Thank you for your interest in the Bachelor of International Management & Bachelor of Business Administration degree program at Wisconsin International University.  All applicants to this program are expected to meet the following admission requirements:\n\n-1) A high school diploma or equivalent \n-2) A minimum score of 550 on the paper-based exam or 213 on the computer-based exam of the Test of English as a Foreign Language (TOEFL) for non-native speakers of English  \n-3) Submit certificate and record of high school transcripts  \n\nIf you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals.")
}

if (rn=="MBA"){
alert("Thank you for your interest in the Master of Business Administration Education degree program at Wisconsin International University.  All applicants to this program are expected to meet the following admission requirements:  \n\n-1) Accredited bachelor's degree or equivalent \n-2) A minimum score of 550 on the paper-based exam or 213 on the computer-based exam of the Test of English (TOEFL) for non-native speakers of English \n-3) A cumulative undergraduate GPA of 2.5 or better \n-4) Current employment or access to an organizational environment.\n\n  If you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals. ");
}

 if ( rn == "MIM" ) {
  alert("Thank you for your interest in the Master of International Management program at Wisconsin International University.    All applicants to this program are expected to meet the following admission requirements:  \n\n-1) Accredited bachelor's degree or equivalent \n-2) A minimum score of 550 on the paper-based exam or 213 on the computer-based exam of the Test of English (TOEFL) for non-native speakers of English \n-3) A cumulative undergraduate GPA of 2.5 or better \n-4) Current employment or access to an organizational environment.\n\n  If you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals. ");
  }
 if ( rn == "Dr" ) {
  alert("Thank you for your interest in the Doctoral Programs at Wisconsin International University.  All applicants to this program are expected to meet the following admission requirements:\n\n  Doctoral Requirements Include:\n\n-   1\)\ A regionally or nationally accredited  master’s degree\n-   2\)\ A cumulative graduate GPA of 3.0 or higher\n-   3\)\ Three years of professional full-time employment, including supervisory experience, and currently employed\n-   4\)\ Three recommendation forms\n-   5\)\ A minimum score of 600 on the paper-based exam or 250 on the computer-based exam of the Test of English as a Foreign Language (TOEFL) for non-native speakers of English\n\nIf you would like information on one of our other degree programs, please select another choice.  Thanks again for your interest in Wisconsin International University and we hope we can help you reach your educational goals.");
  }

 return;

}
function setstateOptions(chosen) {
	//alert ("chosen"&chosen);
var selbox = document.Entry.ContactState;
selbox.options.length = 0;
if (chosen == "-1") {
selbox.options[selbox.options.length] = new Option('Please select a Country','-1');
}

if (chosen == "US") {
selbox.options[selbox.options.length] = new Option('Select One','-1');
selbox.options[selbox.options.length] = new Option('Alaska','AK');
selbox.options[selbox.options.length] = new Option('Alabama','AL');
selbox.options[selbox.options.length] = new Option('Arkansas','AR');
selbox.options[selbox.options.length] = new Option('Arizona','AZ');
selbox.options[selbox.options.length] = new Option('California','CA');
selbox.options[selbox.options.length] = new Option('Colorado','CO');
selbox.options[selbox.options.length] = new Option('Connecticut','CT');
selbox.options[selbox.options.length] = new Option('District of Columbia','DC');
selbox.options[selbox.options.length] = new Option('Delaware','DE');
selbox.options[selbox.options.length] = new Option('Florida','FL');
selbox.options[selbox.options.length] = new Option('Georgia','GA');
selbox.options[selbox.options.length] = new Option('Hawaii','HI');
selbox.options[selbox.options.length] = new Option('Iowa','IA');
selbox.options[selbox.options.length] = new Option('Idaho','ID');
selbox.options[selbox.options.length] = new Option('Illinois','IL');
selbox.options[selbox.options.length] = new Option('Indiana','IN');
selbox.options[selbox.options.length] = new Option('Kansas','KS');
selbox.options[selbox.options.length] = new Option('Kentucky','KY');
selbox.options[selbox.options.length] = new Option('Louisiana','LA');
selbox.options[selbox.options.length] = new Option('Massachusetts','MA');
selbox.options[selbox.options.length] = new Option('Maryland','MD');
selbox.options[selbox.options.length] = new Option('Maine','ME');
selbox.options[selbox.options.length] = new Option('Michigan','MI');
selbox.options[selbox.options.length] = new Option('Minnesota','MN');
selbox.options[selbox.options.length] = new Option('Missouri','MO');
selbox.options[selbox.options.length] = new Option('Mississippi','MS');
selbox.options[selbox.options.length] = new Option('New Hampshire','NH');
selbox.options[selbox.options.length] = new Option('New Jersey','NJ');
selbox.options[selbox.options.length] = new Option('New Mexico','NM');
selbox.options[selbox.options.length] = new Option('Nevada','NV');
selbox.options[selbox.options.length] = new Option('New York','NY');
selbox.options[selbox.options.length] = new Option('Ohio','OH');
selbox.options[selbox.options.length] = new Option('Oklahoma','OK');
selbox.options[selbox.options.length] = new Option('Ontario','ON');
selbox.options[selbox.options.length] = new Option('Oregon','OR');
selbox.options[selbox.options.length] = new Option('Pennsylvania','PA');
selbox.options[selbox.options.length] = new Option('Rhode Island','RI');
selbox.options[selbox.options.length] = new Option('Saskatchewan','SK');
selbox.options[selbox.options.length] = new Option('South Carolina','SC');
selbox.options[selbox.options.length] = new Option('South Dakota','SD');
selbox.options[selbox.options.length] = new Option('Tennessee','TN');
selbox.options[selbox.options.length] = new Option('Texas','TX');
selbox.options[selbox.options.length] = new Option('Utah','UT');
selbox.options[selbox.options.length] = new Option('Virginia','VA');
selbox.options[selbox.options.length] = new Option('Vermont','VT');
selbox.options[selbox.options.length] = new Option('Washington','WA');
selbox.options[selbox.options.length] = new Option('Wisconsin','WI');
selbox.options[selbox.options.length] = new Option('West Virginia','WV');
selbox.options[selbox.options.length] = new Option('Wyoming','WY');
}
//---------------------------

if (chosen == "CA") {
selbox.options[selbox.options.length] = new Option('Select One','-1');
selbox.options[selbox.options.length] = new Option('Alberta','AB');
selbox.options[selbox.options.length] = new Option('British Colombia','BC');
selbox.options[selbox.options.length] = new Option('Manitoba','MB');
selbox.options[selbox.options.length] = new Option('New Brunswick','NB');
selbox.options[selbox.options.length] = new Option('Newfoundland','NF');
selbox.options[selbox.options.length] = new Option('Nova Scotia','NS');
selbox.options[selbox.options.length] = new Option('Northwest Territories','NT');
selbox.options[selbox.options.length] = new Option('Nunavut','NU');
selbox.options[selbox.options.length] = new Option('Ontario','ON');
selbox.options[selbox.options.length] = new Option('Prince Edward Island','PE');
selbox.options[selbox.options.length] = new Option('Quebec','QC');
selbox.options[selbox.options.length] = new Option('Saskatchewan','SK');
selbox.options[selbox.options.length] = new Option('Yukon','YT');
}
//-------------------------

if (chosen != "PR" && chosen != "MP" && chosen != "GU" && chosen != "FM" && chosen != "AS" && chosen != "MX" && chosen != "US" && chosen != "-1") {
selbox.options[selbox.options.length] = new Option('Other','OO');
}
//---------------------------
}//END FUNCTION
