var ie = false;
var select_html = '';
var education_level_priorities = new Array;
var program_data;
var last_state_group;
// Establish onload event.
old_onload = window.onload;
window.onload = function(){
// IE gets wordwrapped options in select boxes.
if (document.uniqueID && window.createPopup) {
ie = true;
}
if (typeof(old_onload) == 'function') {
old_onload();
}
if (typeof(form_name) != 'undefined') {
switch (form_name) {
case '2step':
load2StepForm();
break;
case '1step':
case '1stepWithSpec':
load1StepForm();
break;
case 'tec':
loadTecForm();
break;
}
}
}
function load2StepForm(){
if (form_step == 1) {
// Load education levels and education level priority table.
$.ajax({
url: service_url + '/cdm/clients/WAL0006/educationlevels',
type: 'get',
dataType: 'json',
timeout: 5000,
success: function(data){
var options = select_html;
var edu = data.body;
var url = "international.waldenu.edu";
var site = String(window.location.hostname);
for (var i = 0; i < edu.length; i++) {
if ( site != url || edu[i].EducationLevelCode != "HS" )
{
education_level_priorities[edu[i].EducationLevelCode] = edu[i].EducationLevelPriority;
options += '';
}
}
$('#education_level_code').html(options);
$('#education_level_code').attr('disabled', false);
}
});
// Load program data.
$.ajax({
url: service_url + '/cdm/campuses/' + campus_code + '/programs/nested',
type: 'get',
dataType: 'json',
timeout: 5000,
success: function(data){
program_data = data;
}
});
}
else {
// Select Foreign Country by default in the state drop down for international.waldenu.edu
if (document.location.href.indexOf('international.waldenu.edu') != -1)
{
// This will force the states drop down to populate
$('#country').val('USA');
$('#country').trigger('change');
$('#state').val('FC');
$('#state').trigger('change');
// Set the country drop down back to
document.getElementById('country').selectedIndex = 0;
}
// All microsites except for international.waldenu.edu should select USA by default in the country drop down
else {
$('#country').val('USA');
$('#country').trigger('change');
}
}
}
function load1StepForm(){
// Load program data.
$.ajax({
url: service_url + '/cdm/campuses/' + campus_code + '/programs/nested',
type: 'get',
dataType: 'json',
timeout: 5000,
success: function(data){
program_data = data;
loadPrograms();
}
});
}
function loadTecForm(){
if (form_step == 2) {
$('#country').val('USA');
$('#country').trigger('change');
}
}
function loadPrograms(s){
if (typeof(form_name) != 'undefined' && (form_name == '1step' || form_name == '1stepWithSpec')) {
var education_level_priority = 99;
}
else {
var education_level = s.options[s.selectedIndex].value;
var education_level_priority = education_level_priorities[education_level];
}
var options;
var cat = program_data.body;
for (var i = 0; i < cat.length; i++) {
var option = '';
var pro_count = 0;
if (typeof(cat[i].Programs) != 'undefined') {
var pro = cat[i].Programs;
for (var j = 0; j < pro.length; j++) {
var emp_count = 0;
var emp = pro[j].Emphases;
for (var k = 0; k < emp.length; k++) {
if (education_level_priority >= emp[k].EducationLevelRange['MinEducationLevelPriority']) {
emp_count++;
}
}
// Only show the program if there are specializations available.
if (emp_count > 0) {
pro_count++;
option += '';
/* Removed as it was causing encoding problems and multiple options for the same program in IE
if (ie) {
option += '' + '';
}
else {
option += '';
}
*/
}
}
}
// Only show the category if there are programs available.
if (pro_count > 0) {
if (ie) {
option = '' + '