
// List the states in which certain programs are not available
var list1 = "AL, AR, CO, CT, DE, IA, KS, ME, MD, MA, MI, MN, MS, MT, NV, NJ, NM, ND, RI, SC, TN, TX, UT, WI, WY";
var list2 = "AL, AR, CO, CT, DE, ID, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, TN, TX, UT, VA, WA, WV, WI, WY";
	
	
function validate(){
	
	if (document.deltak.program.value=="0"){
		alert('Please choose a program');
		document.deltak.program.focus();
		return false;
	}
	
	if (document.deltak.firstname.value==""){
		alert('Please enter your First Name');
		document.deltak.firstname.focus();
		return false;
	}
	if (document.deltak.lastname.value==""){
		alert('Please enter your Last Name');
		document.deltak.lastname.focus();
		return false;
	}
		
	if (document.deltak.address.value==""){
		alert('Please type in your Address');
		document.deltak.address.focus();
		return false;
	}
	if (document.deltak.city.value==""){
		alert('Please tell us your City');
		document.deltak.city.focus();
		return false;
	}
	if (document.deltak.state.value=="0"){
		alert('Please select your State');
		document.deltak.state.focus();
		return false;
	}
	if (document.deltak.state.value=="XX"){
		alert('We apologize, but at this time we are only accepting US residents for admission.');
		document.deltak.state.focus();
		return false;
	}
	if (document.deltak.zip.value==""){
		alert('Please enter your Zip Code');
		document.deltak.zip.focus();
		return false;
	}
	
	if(document.deltak.zip.value.search(/^\d{5}([\-]\d{4})?$/)==-1)	{
		alert("The zip code you entered is not valid.\r\nPlease enter a 5 digit or a 10 digit zip code.");
		document.deltak.zip.focus();
		return false;
	}
	
	if (document.deltak.email.value==""){
		alert('Please enter your Email');
		document.deltak.email.focus();
		return false;
	}
	if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.deltak.email.value)){
	alert('Please enter a valid email address');
		document.deltak.email.focus();
		return false;
	}
		
	if (document.deltak.evephone.value==""){
		alert('Please enter a Home Phone');
		document.deltak.evephone.focus();
		return false;
	}
	if(document.deltak.evephone.value.search(/\d{3}\-\d{3}\-\d{4}/)==-1){
		alert("The home phone number you entered is not valid.\r\nPlease enter a phone number with the format xxx-xxx-xxxx.");
		document.deltak.evephone.focus();
		return false;
	}

	if (document.deltak.howhear.value=="0"){
		alert('Please tell us how you heard about us');
		document.deltak.howhear.focus();
		return false;
	}
	
	// Check whether the selected program is available in the visitor's state
	var state = document.deltak.state.value;
	
	if (document.deltak.program.value=="BA" && list1.indexOf(state) >= 0){
		alert("Currently, we are unable to accept students applying for an online associates degree in Business Administration from the following states: \n\nAlabama, Arkansas, Colorado, Connecticut, Delaware, Iowa, Kansas, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Montana, Nevada, New Jersey, New Mexico, North Dakota, Rhode Island, South Carolina, Tennessee, Texas, Utah, Wisconsin and Wyoming. \n\nWe apologize for this inconvienience and wish you the best in furthering your education.");
		document.deltak.program.focus();
		return false;
	}
	if (document.deltak.program.value=="CJ" && list1.indexOf(state) >= 0){
		alert("Currently, we are unable to accept students applying for an online associates degree in Criminal Justice from the following states: \n\nAlabama, Arkansas, Colorado, Connecticut, Delaware, Iowa, Kansas, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Montana, Nevada, New Jersey, New Mexico, North Dakota, Rhode Island, South Carolina, Tennessee, Texas, Utah, Wisconsin and Wyoming. \n\nWe apologize for this inconvienience and wish you the best in furthering your education.");
		document.deltak.program.focus();
		return false;
	}
	if (document.deltak.program.value=="HIT" && list2.indexOf(state) >= 0){
		alert("Currently, we are unable to accept students applying for an online associates degree in Health Information Technology from the following states: \n\nAlabama, Arkansas, Colorado, Connecticut, Delaware, Idaho, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, Tennessee, Texas, Utah, Virginia, Washington, West Virginia, Wisconsin and Wyoming. \n\nWe apologize for this inconvienience and wish you the best in furthering your education.");
		document.deltak.program.focus();
		return false;
	}
	

	return true;

}

		function autoMask(field, event, sMask) {
        

        var KeyTyped = String.fromCharCode(getKeyCode(event));
        var targ = getTarget(event);
        keyCount = targ.value.length;

	if(keyCount == sMask.length)
	{
		return false;
	}
      if ((sMask.charAt(keyCount+1) != '#') && (sMask.charAt(keyCount+1) != 'A' ) )
      {
         field.value = field.value + KeyTyped + sMask.charAt(keyCount+1);
         return false;
      }

        if (sMask.charAt(keyCount) == '*')
                return true;

        if (sMask.charAt(keyCount) == KeyTyped)
        {
                return true;
        }

        if ((sMask.charAt(keyCount) == '#') && isNumeric(KeyTyped))
           return true;

        if ((sMask.charAt(keyCount) == 'A') && isAlpha(KeyTyped))
         return true;

      if ((sMask.charAt(keyCount+1) == '?') )
      {
         field.value = field.value + KeyTyped + sMask.charAt(keyCount+1);
         return true;
      }
      if (KeyTyped.charCodeAt(0) < 32) return true;
    return false;
}
 function getTarget(e) {
  // IE5
   if (e.srcElement) {
        return e.srcElement;
   }
    if (e.target) {
        return e.target;
   }
 }

  function getKeyCode(e) {
 //IE5
 if (e.srcElement) {
        return e.keyCode
 }
  // NC5
  if (e.target) {
   return e.which
  }
 }

 function isNumeric(c)
{
        var sNumbers = "01234567890";
        if (sNumbers.indexOf(c) == -1)
                return false;
        else return true;

}

function isAlpha(c)
{
        var lCode = c.charCodeAt(0);
        if (lCode >= 65 && lCode <= 122 )
          {
                return true;
         }
        else
        return false;
}

function isPunct(c)
{
        var lCode = c.charCodeAt(0);
        if (lCode >= 32 && lCode <= 47 )
          {
                return true;
         }
        else
        return false;

}






//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor="lightyellow"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}


