// JavaScript Document
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpname) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpname]) == null) nbArr = document[grpname] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpname];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpname] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
function viewPackage(item)
{
  if (document.getElementById(item).style.display == 'block')
  {
    document.getElementById(item).style.display = 'none';
    //document.getElementById(image).src = 'show.gif';
  }
  else
  {
    document.getElementById(item).style.display = 'block';
    //document.getElementById(image).src = 'hide.gif';
  }
}

function autoBlank(field){
	field.value = '';
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid e-mail address format")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid e-mail address format")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid e-mail address format")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid e-mail address format")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid e-mail address format")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid e-mail address format")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid e-mail address format")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.form1.email_address
	
		if(document.form1.student_name.value == "name"){
		alert("Please enter your name")
		return false
		}
		
		if(document.form1.student_name.value == ""){
		alert("Please enter your name")
		return false
		}
	
	if(document.form1.phone_number.value == "cell phone"){
		alert("Please enter your cell phone number")
		return false
		}
		
		if(document.form1.phone_number.value == ""){
		alert("Please enter your cell phone number")
		return false
		}
		
	if(document.form1.phone_number2.value == "home phone"){
		alert("Please enter your home phone number")
		return false
		}
		
		if(document.form1.phone_number2.value == ""){
		alert("Please enter your home phone number")
		return false
		}
	if (!document.form1.school_pref[0].checked && !document.form1.school_pref[1].checked && !document.form1.school_pref[2].checked && !document.form1.school_pref[3].checked && !document.form1.school_pref[4].checked){
		alert("Please select a school")
		return false
	}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 function ValidateForm2(){
	var emailID=document.form2.field8a
	
		if(document.form2.field1a.value == ""){
		alert("Please enter your first name")
		return false
		}
		
		if(document.form2.field2a.value == ""){
		alert("Please enter your last name")
		return false
		}
		
		if(document.form2.field7a.value == ""){
		alert("Please enter your cell phone number")
		return false
		}
		
		if(document.form2.field7xa.value == ""){
		alert("Please enter your home phone number")
		return false
		}
		
		if(document.form2.field11a.value == "--"){
		alert("Please choose a preferred location")
		return false
		}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 // For SalesForce Forms
 
 function ValidateFormSF(){
	var emailID=document.form1.email
	
		
		if(document.form1.first_name.value == ""){
		alert("Please enter your first name")
		return false
		}
		
		if(document.form1.last_name.value == ""){
		alert("Please enter your last name")
		return false
		}
		
		if(document.form1.elements['00N800000041MJZ'].value == ""){
		alert("Please enter your cell phone number")
		return false
		}
		
		if(document.form1.elements['00N800000041MJc'].value == ""){
		alert("Please enter your home phone number")
		return false
		}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 function ValidateFormSF2(){
	var emailID=document.form2.email
	
		
		if(document.form2.first_name.value == ""){
		alert("Please enter your first name")
		return false
		}
		
		if(document.form2.last_name.value == ""){
		alert("Please enter your last name")
		return false
		}
		
		if(document.form2.elements['00N800000041MJZ'].value == ""){
		alert("Please enter your cell phone number")
		return false
		}
		
		//if(document.form2.elements['00N800000041MJc'].value == ""){
		//alert("Please enter your home phone number")
		//return false
		//}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function schoolURL(school) {
	switch (school)
		{
		case "AISF":
			document.form1.retURL.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=south_florida";
			document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=south_florida";
			break;
		case "AIO":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=orlando";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=orlando";
		  break;
		case "AISP":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=st_petersburg";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=st_petersburg";
		  break;
		case "AIT":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=tallahassee";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/google-thank-you.php?school_pass=tallahassee";
		  break;
		default:
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/google-thank-you.php.php";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/google-thank-you.php.php";
	 }
	}
function schoolURL2(school) {
	switch (school)
		{
		case "AISF":
			document.form2.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=south_florida";
			document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=south_florida";
			break;
		case "AIO":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=orlando";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=orlando";
		  break;
		case "AISP":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=st_petersburg";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=st_petersburg";
		  break;
		case "AIT":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=tallahassee";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=tallahassee";
		  break;
		default:
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php";
	 }
	}
function schoolURL3(school) { // for the main Apply page
	switch (school)
		{
		case "AISF":
			document.form2.retURL.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=south_florida";
			document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=south_florida";
			break;
		case "AIO":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=orlando";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=orlando";
		  break;
		case "AISP":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=st_petersburg";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=st_petersburg";
		  break;
		case "AIT":
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=tallahassee";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thanks.php?school_pass=tallahassee";
		  break;
		default:
		  document.form2.retURL.value = "http://www.avedaflorida.com/ai/thanks.php";
		  document.form2.schoolcode.value = "http://www.avedaflorida.com/ai/thanks.php";
	 }
	}
function schoolURL4(school) {
	switch (school)
		{
		case "AISF":
			document.form1.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=south_florida";
			document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=south_florida";
			break;
		case "AIO":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=orlando";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=orlando";
		  break;
		case "AISP":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=st_petersburg";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=st_petersburg";
		  break;
		case "AIT":
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=tallahassee";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php?school_pass=tallahassee";
		  break;
		default:
		  document.form1.retURL.value = "http://www.avedaflorida.com/ai/thank-you.php";
		  document.form1.schoolcode.value = "http://www.avedaflorida.com/ai/thank-you.php";
	 }
	}
function getEvent(e){
    return e || window.event;
}


function formatPhoneOnEnter(field, evt) {
    var e = getEvent(evt);
    var key = e.keyCode;

    if (key == KEY_ENTER) {
        formatPhone(field);
    }

}

function formatPhone (field) {
    field.value = trim(field.value);

    var ov = field.value;
    var v = "";
    var x = -1;

    // is this phone number 'escaped' by a leading plus?
    if (0 < ov.length && '+' != ov.charAt(0)) { // format it
        // count number of digits
        var n = 0;
        if ('1' == ov.charAt(0)) {  // skip it
            ov = ov.substring(1, ov.length);
        }

        for (i = 0; i < ov.length; i++) {
            var ch = ov.charAt(i);

            // build up formatted number
            if (ch >= '0' && ch <= '9') {
                if (n == 0) v += "(";
                else if (n == 3) v += ") ";
                else if (n == 6) v += "-";
                v += ch;
                n++;
            }
            // check for extension type section;
            // are spaces, dots, dashes and parentheses the only valid non-digits in a phone number?
            if (! (ch >= '0' && ch <= '9') && ch != ' ' && ch != '-'
&& ch != '.' && ch != '(' && ch != ')') {
                x = i;
                break;
            }
        }
        // add the extension
        if (x >= 0) v += " " + ov.substring(x, ov.length);

        // if we recognize the number, then format it
        if (n == 10 && v.length <= 40) field.value = v;
    }
    return true;

} 

//-->