function doSubmitApplication()
{
   if(validateAll("enrollmentForm"))
   {
/*
      var seperatorCode = "\t";
      var ef = document.enrollmentForm;
    
      var dataTitle = "";
      var dataValue = "";
      var dataPile  = "";
      var temp = "";
      // var re = /\n/gi;
      for(var i=0; i < ef.length; i++)
      {
         temp = "";
   	   if(ef[i].id != "")
   	   {
            dataPile += ef[i].id + seperatorCode;
            temp = _getMonitorElementValue(ef[i]) + "";
            //temp = temp.replace(re, "\\n");
            dataPile += temp + seperatorCode;
            dataPile += "\n\n"
            if(ef[i].type == 'checkbox')
            {
               dataValue += getCheckbox(ef[i].form.name, ef[i].name).toString() + seperatorCode;
            }
   		   // if(ef[i].type == 'text')
            else
            {
               dataValue += ef[i].value + seperatorCode;
            }
   	    }
       }
      ef.CompleteContents.value = dataPile; // dataTitle + "\n" + dataValue;
*/
      var ef = document.enrollmentForm;
      ef.enrollAction.value = "nextDoSave";
      ef.submit();
   
      document.getElementById('StudentFirstNameLabel').style.color = "#FF0000";
   }
}

function getHelpMeSelectStateHTML( stateElementId )
{
   var html = "Click on a state and it will be entered the state abbreviation field for you.<br />";
   
   html += '<table cellpadding="3" cellspacing="0" border="1">';
   html += '<tr><td><b>Description</b></td><td><b>Abbreviation</b></td></tr>';
   for(var i=0; i<global_statesArray.length;i++)
   {
      html += '<tr><td><a href="javascript:window.opener.document.getElementById(\'' + stateElementId + '\').value=\'' + global_statesArray[i][0] + '\';window.close();">' + global_statesArray[i][1] + '</a></td><td>'
            + global_statesArray[i][0] + '</td></tr>';
   }
   html += '</table><br /><br />';
   return html;
}

var global_statesArray = new Array(
   ["AL", "ALABAMA"],
   ["AK", "ALASKA"],
   ["AS", "AMERICAN SAMOA"],
   ["AZ", "ARIZONA"],
   ["AR", "ARKANSAS"],
   ["CA", "CALIFORNIA"],
   ["CO", "COLORADO"],
   ["CT", "CONNECTICUT"],
   ["DE", "DELAWARE"],
   ["DC", "DISTRICT OF COLUMBIA"],
   ["FM", "FEDERATED STATES OF MICRONESIA"],
   ["FL", "FLORIDA"],
   ["GA", "GEORGIA"],
   ["GU", "GUAM"],
   ["HI", "HAWAII"],
   ["ID", "IDAHO"],
   ["IL", "ILLINOIS"],
   ["IN", "INDIANA"],
   ["IA", "IOWA"],
   ["KS", "KANSAS"],
   ["KY", "KENTUCKY"],
   ["LA", "LOUISIANA"],
   ["ME", "MAINE"],
   ["MH", "MARSHALL ISLANDS"],
   ["MD", "MARYLAND"],
   ["MA", "MASSACHUSETTS"],
   ["MI", "MICHIGAN"],
   ["MN", "MINNESOTA"],
   ["MS", "MISSISSIPPI"],
   ["MO", "MISSOURI"],
   ["MT", "MONTANA"],
   ["NE", "NEBRASKA"],
   ["NV", "NEVADA"],
   ["NH", "NEW HAMPSHIRE"],
   ["NJ", "NEW JERSEY"],
   ["NM", "NEW MEXICO"],
   ["NY", "NEW YORK"],
   ["NC", "NORTH CAROLINA"],
   ["ND", "NORTH DAKOTA"],
   ["MP", "NORTHERN MARIANA ISLANDS"],
   ["OH", "OHIO"],
   ["OK", "OKLAHOMA"],
   ["OR", "OREGON"],
   ["PW", "PALAU"],
   ["PA", "PENNSYLVANIA"],
   ["PR", "PUERTO RICO"],
   ["RI", "RHODE ISLAND"],
   ["SC", "SOUTH CAROLINA"],
   ["SD", "SOUTH DAKOTA"],
   ["TN", "TENNESSEE"],
   ["TX", "TEXAS"],
   ["UT", "UTAH"],
   ["VT", "VERMONT"],
   ["VI", "VIRGIN ISLANDS"],
   ["VA", "VIRGINIA"],
   ["WA", "WASHINGTON"],
   ["WV", "WEST VIRGINIA"],
   ["WI", "WISCONSIN"],
   ["WY", "WYOMING"]
);

/** Generate a popup window on the fly. Give it a title and content. */
function popUpContent(titleText,msgText,winWidth,winHeight,winName)
{
   var windowName = (winName != null) ? winName : 'popUpContentWin';
   if(winWidth  == null) { winWidth  = 'auto'};
   if(winHeight == null) { winHeight = 'auto'};
   popUpContentWin = window.open('blank.html',windowName,'resizable=yes,status=yes,scrollbars=yes,width=' + winWidth + ',height=' + winHeight );
   pucT = titleText;
   pucM = msgText;
   var popUpContentAction = '_popUpContentWriter(pucT,pucM)';
   setTimeout(popUpContentAction, 100);
}
function _popUpContentWriter(titleText,msgText)
{
   with( popUpContentWin.document )
   {
      open("text/html", "replace");
      writeln('<html>\n<head>\n<title>BlueSky Online Charter School - ' + titleText + '</title>');
      // writeln('<link REL="stylesheet" HREF="./some_stylesheet_here.css" TYPE="text/css">');
      writeln('</head>\n<body onload="self.focus()" onunload="opener.focus()" class="bodyBg">\n<form name="new_window_form">\n<div class="SectionTitle" id="ContentSectionTitleContainer">' + titleText + '</div>');
      writeln('<br style="font-size:3px;" />');
      writeln('<div class="tableDataHeader" style="padding:0px;"><img src="./healthecare/ui/images/spacer.gif" width="1" height="2" alt=""></div>');
      writeln('<br style="font-size:5px;" />');
      writeln('<div>' + msgText + '</div>');
      writeln('<div align="center" id="CloseWindowButtonContainer"><br style="font-size:5px;"><input type="button" onclick="javascript:window.close()" class="buttonLookAlike" value="Close this window" /></div>');
      writeln('</form>\n</body>\n</html>');
      close();
   }
}

function newWindow(href,windowName,windowStyle)
{
  //  Here is the list of features to choose from:
  // "height=100" (in pixels)
  // "location"   (shows addressbar)
  // "menubar"    (shows file menu)
  // "resizable"  (allow resizing of window)
  // "scrollbars" (show right and bottom scrollbars)
  // "status"     (show status bar)
  // "toolbar"    (show back, forward, stop, etc. buttons)
  // "width=100"  (in pixels)
  // ===================================
  // There should be no spaces:
  // "feature1,feature2,feature3,etc"
  // "height=377,location=no,menubar=no,resizable=yes,scrollbars=no,status=yes,toolbar=no,width=740"

  var undefined;

  if( windowName == undefined )
  {
    windowName = "newWindow";
  }

  if( windowStyle == undefined )
  {
    windowStyle = "status=yes,scrollbars=yes,toolbar=yes,resizable=yes,menubar=yes";
  }

  windowStyle = _verifyWindowSize( windowStyle );

  new_window = window.open(href,windowName,windowStyle);

  //"onerror" is required for external links where the windowName may be changed.
  //Non-matching window names in IE generate a javascript error.
  self.onerror = function() { return true; };
  new_window.focus();
  self.onerror = function() { return false; };
}

function plainWindow(href)
{
  newWindow(href,"plain");
}

var isNetscape = false;
var isIE       = true;

function _verifyWindowSize( windowStyle )
{
   //For now... only mess with size if no size (width) is specified.

   if( windowStyle.toUpperCase().match( "WIDTH" ) )
   {
      return windowStyle;
   }

   var newH;
   var newW;

   if (isNetscape)
   {
      newW = window.innerWidth ;
      newH = window.innerHeight;
   }
   else if (isIE)
   {
      newW = document.body.clientWidth ;
      newH = document.body.clientHeight;
   }
   else
   {
      newW = 800;
      newH = 600;
   }

   newW = Math.round( 0.9 * newW );
   newH = Math.round( 0.9 * newH );

   var windowSize = ",WIDTH=" +newW+ ",HEIGHT=" +newH;
   alert(windowStyle + windowSize);
   return windowStyle + windowSize;
}

/**
   limitFieldSize(this_element, charLimit_int, <alertUser_boolean optional (default=true)>)
   EXAMPLE: <textarea name="myField" onkeyup="limitFieldSize(this, 1000, true)"></textarea>
*/
function limitFieldSize( this_element, charLimit_int, alertUser_boolean )
{
   var alertUser = ( alertUser_boolean != null) ? alertUser_boolean : true;
   if( this_element.value.length > charLimit_int )
   {
      if( this_element.value.charAt(this_element.value.length - 1) == "\n"
       || this_element.value.charAt(this_element.value.length - 1) == "\r" )
      {
         this_element.value = this_element.value.substring(0, charLimit_int - 1);
      }
      else
      {
         this_element.value = this_element.value.substring(0, charLimit_int);
      }

      if( alertUser )
      {
         alert("This field does not accept more than " + charLimit_int + " characters." );
      }
   }
}
function displayRemainingCharCount(this_element,charLimit_int)
{
   var tempId = this_element.name + "CharCount";
   var newText = "Max: " + charLimit_int + " characters; " + (charLimit_int - this_element.value.length) + " remaining.";
   document.getElementById(tempId).innerHTML = newText;
}
