var curQ=0,lastQ=0;var errors=[],messages=[];window.formFamily="DegreesInfo";var noPopup=false,exitPopupWindow="";var formSubmitted=false;var ns4,dom;if(navigator.appName=="Netscape"){ns4=parseInt(navigator.appVersion)<5}dom=!ns4;function validateForm(a){return true}function initF(){formSubmitted=false;resetFields();initFirstPage()}function exitF(){if(noPopup==false&&window.document.form1&&window.document.form1.exPop&&window.document.form1.exPop.value=="true"){if(exitPopupWindow&&!exitPopupWindow.closed&&exitPopupWindow.location){}else{exitPopupWindow=window.open("/forms/goodbye.jsp","popup","menubar=0,resizable=1,scrollbars=1,width=10,height=10");if(exitPopupWindow!=null){exitPopupWindow.blur()}if(self.focus){self.focus()}}}}function displayNextQ(a){showNextQ(a);if(formSubmitted!=true){updateProgressBar()}}function displayPreviousQ(){showPreviousQ();updateProgressBar()}function resetFields(){if(errors&&errors.length>0){showErrorQuestions();return}}function showErrorQuestions(){var c=false;var b=false;for(var a=0;a<errors.length;a++){if(errors[a]=="EMAIL_01"){c=true}else{if(errors[a]=="ZIP_01"){b=true}}}showHideQ(null,0);var d=[];if(window.qListGroups){window.qListGroups.length=0}for(var a=0;a<errors.length;a++){if(window.qListGroups){d[d.length]=getDivByField(errors[a])}}if(window.qListGroups){window.qListGroups[0]=d}showHideQ(0,null)}function showHideQ(c,b){if(window.qListGroups){var d=window.qListGroups[b];if(d){for(var a=0;a<d.length;++a){hide(d[a])}}d=window.qListGroups[c];if(d){for(var a=0;a<d.length;++a){show(d[a])}}}}function show(a){showElement(a)}function showElement(b){var a=window.document.all?window.document.all[b]:dom?window.document.getElementById(b):window.document.layers[b];if(a){if(ns4){a.visibility="show"}else{a.style.display="block"}}}function hide(a){hideElement(a)}function hideElement(b){var a=window.document.all?window.document.all[b]:dom?window.document.getElementById(b):window.document.layers[b];if(a){if(ns4){a.visibility="hide"}else{a.style.display="none"}}}function getDivByField(b){if(b=="DDI_AGE_01"){return"div_DDI_AGE"}else{if(b=="DDI_GRADYEAR_01"){return"div_DDI_GRADYEAR"}else{if(b=="DDI_AOS_01"){return"div_DDI_AOS"}else{if(b=="EMAIL_01"){var a=document.getElementById("div_"+b);if(a!=undefined&&a!=null){return"div_"+b}return"div_ZIP_01"}else{return"div_"+b}}}}}function initFirstPage(){initializeGroups(window.qListGroups)}function initializeGroups(d){if(!d){return}var g="div_NEXT_BTN";for(var b=0;b<d.length;b++){var e=d[b];if(e.length>1){for(var a=0;a<e.length;a++){removeEvents(e[a])}e[e.length]=g}else{if(e.length==1){if(isNextBtnRequired(e[0])){e[e.length]=g}}}}var c=d[0];for(var b=0;b<c.length;b++){var f=document.getElementById(c[b]);if(f){f.className=f.className.replace(/hidden/,"visible")}}}function removeEvents(b){var a=getFieldsWithinDiv(b);for(var c=0;c<a.length;c++){a[c].onchange=null;a[c].onclick=null}}function isNextBtnRequired(a){var b=false;if(a=="div_DDI_AOS"||a=="div_EMAIL_01"||a=="div_ZIP_01"){b=true}return b}function getFieldsWithinDiv(b){var c=b;if(c.indexOf("_01")==-1){c=c+"_01"}if(c.indexOf("div_")==0){c=c.substring(4)}var a=document.getElementsByName(c);return a}function validateIsRequired(a){if(a.length<=0){return false}return true}function validate(a){if(a==window.document.form1.DDI_AOS_01){return validate_DDI_AOS_01()}else{if(a==window.document.form1.DDI_AGE_01){return validate_DDI_AGE_01()}else{if(a==window.document.form1.DDI_GRADYEAR_01){return validate_DDI_GRADYEAR_01()}else{if(a==window.document.form1.DDI_EDUCATION_01){return validate_DDI_EDUCATION_01()}else{if(a==window.document.form1.DDI_START_PERIOD_01){return validate_DDI_START_PERIOD_01()}else{if(a==window.document.form1.COUNTRY_01){return validate_DDI_COUNTRY_01()}else{if(a==window.document.form1.USCITIZEN_01){return validate_DDI_USCITIZEN_01()}else{if(a==window.document.form1.DDI_MILITARYBRANCH_01){return validate_DDI_MILITARYBRANCH_01()}else{if(a==window.document.form1.ZIP_01){return validate_ZIP_01(window.document.form1)}else{if(a==window.document.form1.EMAIL_01){return validate_EMAIL_01(window.document.form1)}else{if(a==window.document.form1.DDI_EARN_YEARLY_01){return validate_DDI_EARN_YEARLY_01()}}}}}}}}}}}return true}function validate_DDI_AOS_01(){var a=window.document.form1.DDI_AOS_01;var c=false;for(var b=0;b<a.length;b++){if(a[b].checked){c=true}}if(!c){if(window.document.form1.career_display_for_aos){alertError(window.document.form1.career_display_for_aos,"Please select a Career of Interest")}else{alertError(window.document.form1.DDI_AOS_01[0],"Please Select an Area of Study")}return false}return true}function validate_ZIP_01(b){var c=getFieldValueTF(b.ZIP_01);if(!validateIsRequired(c)){return alertError(b.ZIP_01,"Please enter a valid Zip Code.")}var a=getCountryValue(window.document.form1.COUNTRY_01);if(a=="USA"){if(!isUSZip(c)){return alertError(b.ZIP_01,"Please enter a valid Zip Code.")}}else{if(a=="CAN"){if(!isCANZip(c)){return alertError(b.ZIP_01,"Please enter a valid Zip Code.")}}}return true}function getCountryValue(a){if(window.formFamily&&window.formFamily=="DegreesInfo"){if(a.length&&a.length>1){return getFieldValueRB(a)}else{return getFieldValueTF(a)}}else{return getFieldValueLB(a)}}function isUSZip(a){if(validateMinLength(a,5)&&validateMaxLength(a,5)&&allDigits(a)){return true}else{return false}}function isCANZip(c){var a=stripAwayHyphAndSpaces(c);if(validateMinLength(a,6)&&validateMaxLength(a,6)){var b=a.toUpperCase();if("ABCEGHJKLMNPRSTVXY".indexOf(b.charAt(0))<0||"0123456789".indexOf(b.charAt(1))<0||"ABCDEFGHJKLMNPQRSTUVWXYZ".indexOf(b.charAt(2))<0||"0123456789".indexOf(b.charAt(3))<0||"ABCDEFGHJKLMNPQRSTUVWXYZ".indexOf(b.charAt(4))<0||"0123456789".indexOf(b.charAt(5))<0){return false}else{return true}}return false}function validate_DDI_EDUCATION_01(){var b=window.document.form1.DDI_EDUCATION_01;var a=getFieldValueLB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate your level of Education.")}return true}function validate_DDI_AGE_01(){var b=window.document.form1.DDI_AGE_01;var a=getFieldValueLB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate your age.")}return true}function validate_DDI_GRADYEAR_01(){var b=window.document.form1.DDI_GRADYEAR_01;var a=getFieldValueLB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate the year you graduated.")}if("9999"==a){formSubmitted=true;window.document.form1.submit()}return true}function validate_DDI_START_PERIOD_01(){var b=window.document.form1.DDI_START_PERIOD_01;var a=getFieldValueLB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate when you plan to enroll.")}return true}function validate_DDI_EARN_YEARLY_01(){field=window.document.form1.DDI_EARN_YEARLY_01;value=getFieldValueLB(field);if(!validateIsRequired(value)){return alertError(field,"Please select how much would you like to earn per year.")}return true}function validate_DDI_COUNTRY_01(){var b=window.document.form1.COUNTRY_01;var a=getFieldValueRB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate what Country you reside in.")}if(!("USA"==a)&&!("CAN"==a)){formSubmitted=true;window.document.form1.submit()}return true}function validate_DDI_MILITARYBRANCH_01(){var b=window.document.form1.DDI_MILITARYBRANCH_01;var a=getFieldValueLB(b);if(!validateIsRequired(a)){return alertError(b,"Please indicate Military status.")}return true}function validate_EMAIL_01(b){var a=getFieldValueTF(b.EMAIL_01);if(validateEmailAddress(a)==false){return alertError(b.EMAIL_01,"Please enter a valid Email Address.")}return true}function validateEmailAddress(c){var g=true;if(!validateIsRequired(c)){g=false}else{if(c==""){g=false}else{if(c.indexOf("@")==-1){g=false}else{if(c.indexOf("@")!=c.lastIndexOf("@")){g=false}else{if(c.indexOf(".")==-1){g=false}else{if(c.lastIndexOf(".")<c.indexOf("@")+3){g=false}else{if(c.indexOf("@")==0){g=false}else{if(c.indexOf("@")==c.length-1){g=false}else{if(c.indexOf("@.")!=-1||c.indexOf(".@")!=-1){g=false}else{if(c.lastIndexOf(".")==c.length-1){g=false}else{if(c.indexOf("..")!=-1){g=false}else{if(c.lastIndexOf(".")!=c.length-3&&c.lastIndexOf(".")!=c.length-4&&c.lastIndexOf(".")!=c.length-5){g=false}else{var h=c.substring(0,c.indexOf("@"));var e=c.substring(c.indexOf("@")+1,c.length);for(var d=0;d<h.length;d++){var f=h.charAt(d);var b="!\"#$%&'()*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";if(b.indexOf(f)==-1){g=false}}if(g!=false){for(var a=0;a<e.length;a++){var f=e.charAt(a);var b=".-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(b.indexOf(f)==-1){g=false}}}}}}}}}}}}}}}if(g==false){return false}return true}function validate_DDI_USCITIZEN_01(){var b=window.document.form1.USCITIZEN_01;var a=getFieldValueRB(b);if(!validateIsRequired(a)){return alertError(window.document.form1.USCITIZEN_01[0],"You must indicate whether you are a U.S. Citizen.")}return true}function validateMinLength(a,b){if(!a){return false}if(a.length<b){return false}return true}function validateMaxLength(a,b){if(!a){return true}if(a.length>b){return false}return true}function alertError(b,a){alert(a);if(b){if(b.focus){b.focus()}}return false}function getFieldValueLB(a){if(a==undefined||a==null){return null}if(a.value){return a.value}if(a.selectedIndex>=0){return a.options[a.selectedIndex].value}else{return""}}function getFieldValueRB(b){if(b==undefined||b==null){return null}if(b.value){return b.value}for(var a=0;a<b.length;a++){if(b[a].checked==true){return b[a].value}}return""}function getFieldValueTF(a){if(a==undefined||a==null){return null}return a.value}function stripAwayHyphAndSpaces(c){var d="";for(var a=0;a<c.length;a++){var b=c.charAt(a);if(b!=" "&&b!="-"){d=d+b}}return d}function allDigits(d){var f="0123456789";var e=true;for(var b=0;b<d.length;b++){var c=d.charAt(b);for(var a=0;a<f.length;a++){if(c==f.charAt(a)){break}}if(a==f.length){e=false;break}}return e}function showNextQ(d){var a=true;if(window.qListGroups){if(curQ<window.qListGroups.length){var c=window.qListGroups[curQ];if(c){for(var b=0;b<c.length;++b){if(!validateGroupElement(c[b])){return false}}if(curQ<window.qListGroups.length-1){lastQ=curQ;curQ=curQ+1;showHideQ(curQ,lastQ);a=false}}else{a=false}}}if(a){finalize();submitForm()}}function validateGroupElement(a){var b=getFieldsWithinDiv(a);if(b&&b.length>0){var c=window.document.form1[b[0].name];if(c&&!validate(c)){return false}}return true}function finalize(){var a=window.document.form1.DDI_EDUCATION_01;if(a!=undefined&&a!=null&&a.options[a.selectedIndex].value=="none"){a.options[a.selectedIndex].disabled=false}}function submitForm(){noPopup=true;formSubmitted=true;window.document.form1.submit()}function showPreviousQ(a){if(curQ==0){alert("Already at beginning of form");return}showHideQ(lastQ,curQ);curQ=lastQ;lastQ=lastQ-1;if(window.qListGroups[curQ].length==1){resetFieldValue()}}function resetFieldValue(){if(window.qListGroups){resetFieldQuestion(window.qListGroups[curQ])}}function resetFieldQuestion(a){if(a=="div_DDI_AGE"){window.document.form1.DDI_AGE_01.options[0].selected=true}else{if(a=="div_DDI_GRADYEAR"){window.document.form1.DDI_GRADYEAR_01.options[0].selected=true}else{if(a=="div_DDI_EDUCATION_01"){window.document.form1.DDI_EDUCATION_01.options[0].selected=true}else{if(a=="div_DDI_START_PERIOD_01"){window.document.form1.DDI_START_PERIOD_01.options[0].selected=true}else{if(a=="div_DDI_EARN_YEARLY_01"){window.document.form1.DDI_EARN_YEARLY_01.options[0].selected=true}else{if(a=="div_COUNTRY_01"){window.document.form1.COUNTRY_01[0].checked=false;window.document.form1.COUNTRY_01[1].checked=false;window.document.form1.COUNTRY_01[2].checked=false}else{if(a=="div_USCITIZEN_01"){window.document.form1.USCITIZEN_01[0].checked=false;window.document.form1.USCITIZEN_01[1].checked=false}else{if(a=="div_DDI_MILITARYBRANCH_01"){window.document.form1.DDI_MILITARYBRANCH_01.options[0].selected=true}}}}}}}}}function updateProgressBar(){if(curQ==0){hide("backbutton")}else{show("backbutton")}var a=window.document.getElementById("div_progress");if(window.qListGroups){a.style.width=Math.round(curQ/window.qListGroups.length*100)+"%"}}function adchemyBack(){displayPreviousQ()}function filterHighestEd(){var b=getFieldValueLB(window.document.form1.DDI_GRADYEAR_01);if(b=="9999"){formSubmitted=true;window.document.form1.submit()}var a=getFieldValueLB(window.document.form1.DDI_EDUCATION_01);if(a=="none"){formSubmitted=true;window.document.form1.submit()}return}function notUSAOrCanCountry(){formSubmitted=true;window.document.form1.submit();return true};