var messages=(function(){var a={delStudent:"Are you sure you want to delete this student?",delNonStudent:"Are you sure you want to delete this user?",studentsOneRoleOnly:"Students may not have multiple roles.",trialUsersOneRoleOnly:"Trial user may not have other roles.",districtAdminOneRoleOnly:"District Admins may not have multiple roles.",emailMatchErr:"The email addresses must be the same.",blankPassword:"The password cannot be blank.",passwordSuccess:"Password successfully changed.",firstLastBlank:"The first name and last name must be entered.",profileSuccess:"Your changes have been saved.",noXl:'We cannot accept an Excel file.\nYou can use Excel\'s "file - save as" to create a CSV, comma delimited file.\n\nPlease refer to the "Instructions" tab in the template file for more information.',wrongFileType:'The file is not an acceptable type. Submit the upload file in a comma separated value (.csv) format.\n\nPlease refer to the "Instructions" tab in the template file for more information.',noUserType:"Please select a user type."};return{text:function(b){return a[b]},show:function(b){var c=a[b];if(c){alert(c)}},fText:function(b){var c=a[b];if(c&&arguments.length==c.argCount+1){return c.text.replace(/%(\d+)%/g,function(e,d){return arguments[d*1]})}},fShow:function(b){var c=a[b];if(c&&arguments.length==c.argCount+1){alert(c.text.replace(/%(\d+)%/g,function(e,d){return arguments[d*1]}))}}}})();var makeModalAjaxCtrl=(function(){var c=document.body.innerText?"innerText":"textContent";var b=/^[^_-]+[_-]/;var a;var h={};var e=window.location.href.replace(/^(.*NystromDigital\/).*$/,"$1");var g=/^[\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,4}$/;var f={editClassName:function(){var j;var n;var m;var k;return{setup:function(){j=this;k="addEditClass.html";this.formName=m="addEditClassName";this.theForm=document.forms[m];n=this.theForm;n.onsubmit=this.submit;n.close=this.close;n.showErrors=this.showErrors;n.showSuccess=this.showSuccess;this.getButtons()},submit:function(p){if(n.name.value.notEmpty()){document.body.style.cursor="wait";j.disableButtons();var o=$(n).serialize();$.post(k,o,j.callBack,"json")}else{n.showErrors([{key:"name",value:"Name cannot be blank"}])}j.stopDefault(p)},callBack:function(o){document.body.style.cursor="default";j.enableButtons();if(o[0].Status=="Success"){n.showSuccess()}else{n.showErrors(o[1])}},showSuccess:function(){var o=document.getElementById("nameOfclass");o[c]=n.name.value;tb_remove()}}},resetPassword:function(){var o;var n;var m;var j;var k;return{setup:function(){this.ctrlObj=j=this;k="resetUserPassword.html";this.formName=n="resetPassword";this.theForm=o=document.getElementById(n);o.onsubmit=this.submit;this.getButtons();this.getSuccessBlock()},submit:function(r){if(o.password.value.notEmpty()){document.body.style.cursor="wait";j.disableButtons();var p=$(o).serialize();jQuery.post(k,p,j.callback,"json")}else{alert(messages.text("blankPassword"))}j.stopDefault(r)},callback:function(p){document.body.style.cursor="default";j.enableButtons();if(p.length>1){this.setError(p[1][0].key,messages.text("blankPassword"))}else{j.showSuccess(messages.text("passwordSuccess"))}},closeForm:function(){this.clearErrors();m.innerHTML="";m.style.display="none";o.reset();tb_remove();o.style.visibility="visible"}}},addDistAdmin:function(){var n;var k;var j;var m;return{setup:function(){j=this;this.formName=k="addEditAdmin";this.theForm=n=document.getElementById(k);n.onsubmit=this.submit;n.onreset=this.close;m=this.getSuccessBlock();this.getButtons()},submit:function(r){var o=true;if(n.firstName.value.isEmpty()){o=false;j.setErrorMsg(n.firstName,"First name cannot be blank")}if(n.lastName.value.isEmpty()){o=false;j.setErrorMsg(n.lastName,"Last name cannot be blank")}if(!j.validEmail(n.userName.value)){o=false;if(n.userName.value.isEmpty()){j.setErrorMsg(n.userName,"Email address cannot be blank")}else{j.setErrorMsg(n.userName,"Email address is not valid")}}if(o){document.body.style.cursor="wait";j.disableButtons();n.email.value=n.userName.value;var p=$(n).serialize();jQuery.post("addUserJson.html",p,j.callBack,"json")}j.stopDefault(r)},callBack:function(o){j.enableButtons();if(o[0].Status=="Success"){j.showSuccess();window.location.reload()}else{if(o[1].length){j.showErrors(o[1])}else{alert("Could not add administrator due to a system error. Please try later.")}}document.body.style.cursor="default"},close:function(){j.clearErrors();tb_remove()},showSuccess:function(){m.style.display="block";n.style.display.none}}},addClass:function(){var p;var o;var n='<span class="deleteClass" id="id_%uid%_cid_%cid%">Delete Class</span><a href="viewClass.html?id=%cid%">%cname%</a>';var k;var m="addEditClass.html";var j;return{setup:function(){this.formName=o||"addClassForm";this.theForm=document.getElementById(this.formName);p=this.theForm;p.onsubmit=this.submit;p.close=function(){tb_remove()};k=this;this.getButtons()},disable:function(){this.disableButtons();document.body.style.cursor="wait"},enable:function(){this.enableButtons();document.body.style.cursor="default"},submit:function(s){if(p.name.value.notEmpty()){k.disable();var r=$(p).serialize();jQuery.post(m,r,k.callBack,"json")}else{k.setErrorMsg(p.name,"The name cannot be blank")}k.stopDefault(s)},callBack:function(s){if(s[0].Status=="Success"){var r={cname:p.name.value,uid:p.teacherId.value,cid:s[0].classId||"xxx"};if(r.cid!="xxx"){var q=document.createElement("li");q.innerHTML=n.replace(/%(\w+)%/g,function(w,v){return r[v]});var t=jQuery(".classesWrapper")[0];t.appendChild(q);p.close()}else{window.location.reload()}}else{var u=s[1];if(u&&u.length){k.showErrors(u)}else{alert("Your class was not added due to a system error. Please try later.");p.close()}}k.enable()}}},deleteClass:function(){var o=null;var n=null;var m=null;var p=null;var j;var k;return{confirmText:"Are you sure you want to delete this?",setup:function(q){j=this;q=q||".classesWrapper";o=jQuery(q)[0];o.onclick=this.submit;k="deleteTeachersClass.html"},submit:function(u){u=u||window.event;var r=u.target||u.srcElement;if(r.nodeName!="SPAN"){return}if(j.confirmAction()){document.body.style.cursor="wait";m=(r.parentNode);cid=j.extractId(m.id);p=j.extractId(m.parentNode.id);var s="cid="+cid+"&id="+p;jQuery.post(k,s,j.callBack,"json")}j.stopDefault(u)},callBack:function(r){document.body.style.cursor="default";if(r.Status=="Success"){m.parentNode.removeChild(m)}else{var s=r.errors;var q=s&&s.length;if(!q){alert("The class could not be removed due to a system error. Please try later.")}else{this.showErrors(s)}}}}},removeStudentFromClass:function(){var o="data_area";var m;var p;var j;var q;var n;var k;return{confirmText:"Are you sure you want to remove this student?",setup:function(){k=this;n="deleteClassStudent.html";m=document.getElementById(o);m.onclick=this.submit},submit:function(u){u=u||window.event;var r=u.target||u.srcElement;if(r.nodeName!="SPAN"){return}if(k.confirmAction()){document.body.style.cursor="wait";p=r.parentNode.parentNode;j=k.extractId(p.id);q=p.parentNode.getAttribute("cid");var s="id="+q+"&uid="+j;$.post(n,s,k.callback,"json")}k.stopDefault(u)},callback:function(r){document.body.style.cursor="default";if(r.Status=="Success"){var s={id:j,fname:p.getAttribute("fname"),lname:p.getAttribute("lname")};unassignedStudents.push(s);p.parentNode.deleteRow(p.sectionRowIndex);if(a){a.loadTables()}}else{alert("Could not remove student from class. Please try later.")}}}},studentPickList:function(){var t="<tr><td style='width: 20px;'><input name='userIds' value='%id%' type='checkbox' style='width: 18px;'></td><td>%lname%</td><td>%fname%</td></tr>";var m=null;var o=null;var p;var s={};var k;var r;var n;var u;var q;var j="assignStudentToClass.html";return{setup:function(){q=this;a=this;this.formName=u="pickListTable";this.theForm=n=document.getElementById(u);n.onsubmit=this.submit;k=document.getElementById("listdiv");r=document.getElementById("addStudentLink");r.onclick=this.openAddStudent;jQuery(".pickTabs").click(this.tab);p=jQuery(".pickTabs li");this.getButtons();this.getSuccessBlock();this.loadTables()},submit:function(z){var v=n.elements;var w=v.length;var y;s={length:0};while(w--){y=v[w];if(y.nodeName=="INPUT"&&y.checked){s[y.value]=true;s.length++}}if(s.length){document.body.style.cursor="wait";q.disableButtons();var x=$(n).serialize();jQuery.post(j,x,q.callBack,"json")}q.stopDefault(z)},callBack:function(v){if(v.Status=="Success"){q.showSuccess((s.length>1?"Students added":"Student added"));window.location.reload(true)}else{alert("Could not add students to class. Please try later.")}q.enableButtons();document.body.style.cursor="default"},tab:function(w){w=w||window.event;var v=w.target||w.srcElement;if(v.className=="empty"){return}if(m){m.className="";o.style.display="none"}v.className="selected";var x=v[c].trim().charAt(0);o=document.getElementById(x);if(o){o.style.display="";m=v}},loadTables:function(){unassignedStudents.sort(function(D,C){var H=D.lname.toUpperCase();var G=C.lname.toUpperCase();var F=D.fname.toUpperCase();var E=C.fname.toUpperCase();if(/^\d/.test(H)&&!(/^\d/.test(G))){return 1}if(/^\d/.test(G)&&!(/^\d/.test(H))){return -1}if(H<G){return -1}if(G<H){return 1}if(F<E){return -1}if(E<F){return 1}return 0});var z=['<table style="width: 100%;">'];var y,A,B="";for(var w=0,v=unassignedStudents.length;w<v;){A=unassignedStudents[w];y=A.lname.charAt(0).toUpperCase();B+=y+",";if(/^\d/.test(y)){y="0";B+="0"}else{B+=y+","}z.push("<tbody id="+y+' style="display: none;">');while(w<v&&((A.lname.charAt(0).toUpperCase()==y)||(y=="0"&&/^\d/.test(A.lname)))){z.push(t.replace(/%([a-zA-Z]+)%/g,function(D,C){return A[C]}));A=unassignedStudents[++w]}z.push("</tbody>")}k.innerHTML=z.join("\n");for(var w=0;w<27;w++){var x=p[w];if(B.indexOf(x[c].charAt(0))==-1){x.className="empty"}else{x.className=""}}o=document.getElementById(B.charAt(0));if(o){o.style.display="";m=p[B.charCodeAt(0)-65];m.className="selected"}},fixdata:function(){var w=unassignedStudents;var v=w.length;while(v--){if(w[v].id in s){w.splice(v,1)}}this.loadTables();s={}},openAddStudent:function(v){if(!h.Info){h.Info={target:"pickListTable",schoolName:dynData.schoolName,institutionId:dynData.institutionId,classId:dynData.classId}}makeModalAjaxCtrl("addStudent");return q.stopDefault(v)}}},addStudent:function(){var u;var z="Student Users may use either their email address as a username, or create a unique username in order to use Stratalogica.\n\nStudents without an email address as a username in the system will require a teacher's help to reset their passwords.\n\nClick OK to use the Email address?";var m="Student Users may use either their email address as a username, or create a unique username in order to use Stratalogica.\n\nStudents without an email address as a username in the system will require a teacher's help to reset their passwords.\n\nClick OK to use a user Name?";var D=['<p id="formSuccessNotification" style="display:none;">Your user has been added successfully! This window will now close</p>','<div class="TB_contentTop"><div></div></div>','<form id="newUser">','<input id="institutionId" name="institutionId" type="hidden" value="%institutionId%"/>','<input id="userType" name="userTypes" type="hidden" value="ROLE_STUDENT"/>','<input id="classId" name="classId" type="hidden" value="%classId%"/>','<div class="TB_fields">',"<h3>%schoolName%</h3>","<p>User Type:</p><h4>Student</h4>",'<div class="row"><div style="float: left;">','<p id="firstName_err" class="errorText">&nbsp;</p>','<label for="firstName">First Name:</label>','<input id="firstName" name="firstName" type="text" value=""/></div>','<div style="float: left;margin-left:20px;">','<p id="lastName_err" class="errorText">&nbsp;</p>','<label for="lastName">Last Name:</label>','<input id="lastName" name="lastName" type="text" value=""/>',"</div></div>",'<div id="studentUserName" class="row"><div style="float: left;">','<p id="email_err" class="errorText">&nbsp;</p>','<label for="email">Email:</label>','<input id="email" name="email" type="text" value=""/></div>','<div id="or" style="float: left;">or</div>','<div style="float: left;">','<p id="userName_err" class="errorText">&nbsp;</p>','<label for="userName">User Name:</label>','<input id="userName" name="userName" type="text" value=""/>',"</div></div>",'<div class="row"><div style="float: left;">','<p id="password_err" class="errorText">&nbsp;</p>','<label for="password">Password:</label>','<input id="password" name="password" type="text" value=""/>','</div><div style="float: left;margin-left:20px;">','<p id="graduationYear_err" class="errorText">&nbsp;</p>','<label for="graduationYear">Graduation Year:</label>','<input id="graduationYear" name="graduationYear" type="text" value=""/>',"</div></div></div>",'<div class="TB_contentBottom"><div></div></div>','<div class="TB_buttonRow" style="text-align: right;">','<button type="reset" class="graphical"><span>Cancel</span></button>','<button type="submit" class="graphical"><span>Add Student</span></button>',"</div>","</form>"];var n=null;var A;var q;var v;var C;var r;var E;var k;var w;var s;var j;var p;var t;var o;var y;var B;var x;return{setup:function(){u=this;k=$("#TB_ajaxContent");w=$("#TB_window");s=k.width();j=k.height();pickListWinWidth=w.width();t=w.css("margin-top");o=w.css("margin-left");y=h.Info.target;if(typeof y=="string"){y=document.getElementById(y)}q=y.parentNode;h.FormCtrl=this;this.open()},open:function(){v=document.createElement("div");v.innerHTML=D.join("\n").replace(/%(\w+)%/g,function(G,F){return h.Info[F]});k.width(450);k.height(325);w.width(470);w.css("margin-top",-235);w.css("margin-left",-225);A=q.replaceChild(v,y);this.formName=x="newUser";this.theForm=document.getElementById(x);B=this.theForm;B.onsubmit=this.submit;B.onreset=this.goBack;C=$("#TB_closeWindowButton");C.unbind("click");this.replaceTitle();C=$("#TB_closeWindowButton");C.click(function(){u.close()});document.getElementById("studentUserName").onkeypress=this.usernameNotice},replaceTitle:function(){E=document.getElementById("TB_title_right");r=E.innerHTML;E.innerHTML="<img id='TB_closeWindowButton' src='../images/admin/modal_closeButton.png' /> Add a New Student"},restoreTitle:function(){C.unbind("click");E.innerHTML=r;C=$("#TB_closeWindowButton");C.click(tb_remove)},goBack:function(){k.width(s);k.height(j);w.width(pickListWinWidth);w.css("margin-top",t);w.css("margin-left",o);q.replaceChild(A,v);u.restoreTitle();delete h.FormCtrl},close:function(){u.goBack();tb_remove()},submit:function(I){I=I||window.event;var H=I.target||I.srcElement;var F="";document.body.style.cursor="wait";if(!u.buttons||u.buttons.length==0){u.getButtons(document.getElementById("TB_ajaxContent"))}u.disableButtons();if(B.email.value.notEmpty()){F="&emailAsUsername=true"}var G=$(B).serialize()+F;$.post("addUserJson.html?id=",G,u.callBack,"json");if(I.preventDefault){I.preventDefault()}else{I.returnValue=false}return false},callBack:function(H){var I;document.body.style.cursor="default";u.enableButtons();if(H[0].Status!="Failed"){var G=document.getElementById("formSuccessNotification").style;B.style.display="none";G.display="block";window.location.reload()}else{var J=H[1];var F=J.length;while(F--){I=J[F].key;document.getElementById(I+"_err")[c]=J[F].value}}},usernameNotice:function(J){J=J||window.event;var H=J.target||J.srcElement;var I;if(H.value.notEmpty()){return}I=J.keyCode;if(J.charCode!=undefined){if(J.keyCode){return}I=J.charCode}if(I==9){return}if(I==32){if(J.preventDefault){J.preventDefault()}else{J.returnValue=false}return false}var G=B.userName;var F=B.email;switch(H.id){case"email":if(G.value.notEmpty()){if(confirm(z)){G.value=""}else{if(J.preventDefault){J.preventDefault()}else{J.returnValue=false}}}break;case"userName":if(F.value.notEmpty()){if(confirm(m)){F.value=""}else{if(J.preventDefault){J.preventDefault()}else{J.returnValue=false}}}break}}}},editClassLicense:function(){var w="removeLicenseBtn";var p=null;var v=null;var k=null;var o=null;var r=false;var m=[];var n=[];var s;var u;var t="deleteClassLicenses.html";var j="addClassLicenses.html";var q;return{setup:function(){ctrlObj=this;v=document.getElementById("removeLicenseInstance");v.onsubmit=this.removeLicense;k=document.getElementById("addLicenseInstances");k.onsubmit=this.addLicenses;o=document.getElementById("licenseDone");o.onclick=this.close;s=document.getElementById("addLicenseTbody");u=document.getElementById("removeLicenseTbody")},removeLicense:function(C){p=jQuery("#removeLicenseInstance input[type=checkbox]");var E,x;var z=0,y=p.length;var B,D,x;m=[];while(z<y){B=p[z++];if(B.checked){x=B.parentNode;D=x.parentNode;m.push({row:D,cell1:x.innerHTML,cell2:x.nextSibling.innerHTML})}}if(m.length){document.body.style.cursor="wait";var A=$(v).serialize();jQuery.post(t,A,ctrlObj.removeCallback,"json")}ctrlObj.stopDefault(C)},removeCallback:function(z){document.body.style.cursor="default";var A,x;if(z.Status=="Success"){r=true;var y=m.length;while(y--){A=u.removeChild(m[y].row);A.getElementsByTagName("input")[0].checked=false;s.appendChild(A)}}else{alert("Your request could not be processed. Please try again later.")}},addLicenses:function(C){p=jQuery("#addLicenseInstances input[type=checkbox]");var z=0,y=p.length;var B,D,x;n=[];while(z<y){B=p[z++];if(B.checked){x=B.parentNode;D=x.parentNode;n.push({row:D,cell1:x.innerHTML,cell2:x.nextSibling.innerHTML})}}if(n.length){document.body.style.cursor="wait";var A=$(k).serialize();jQuery.post(j,A,ctrlObj.addCallback,"json")}ctrlObj.stopDefault(C)},addCallback:function(z){var A,x;document.body.style.cursor="default";if(z.Status=="Success"){r=true;var y=n.length;while(y--){A=s.removeChild(n[y].row);A.getElementsByTagName("input")[0].checked=false;u.appendChild(A)}}else{alert("Your request could not be processed. Please try again later.")}},close:function(){if(r){document.body.style.cursor="wait";window.location.reload()}else{tb_remove()}}}},editProfile:function(){var n;var m;var k;var j;return{setup:function(){this.formName=m="editForm";this.theForm=document.getElementById(m);n=this.theForm;n.onsubmit=this.submit;k=document.getElementById("editFormNoticifation");j=this},submit:function(p){if(n.firstName.value.notEmpty()&&n.lastName.value.notEmpty()){document.body.style.cursor="wait";j.disableButtons();var o=$(n).serialize();$.post("updateUser.html",o,function(q){j.callBack(q)},"json");j.stopDefault(p)}else{if(n.firstName.value.isEmpty()){this.showErrors({key:"firstName",value:"The first name must be entered."})}if(n.lastName.value.isEmpty()){this.showErrors({key:"lastName",value:"The last name must be entered."})}}},callBack:function(o){if(o.length>1){j.showErrors(o[1])}else{j.clearErrors();j.showSuccess(messages.text("profileSuccess"))}n.parentNode.style.cursor="default";j.enableButtons()},showSuccess:function(s){var p=document.getElementById("userName");var r=document.getElementById("userTitle");var q=document.getElementsByTagName("h1")[0];var o=document.getElementById("phoneNbr");p[c]=n.firstName.value+" "+n.lastName.value;q[c]=n.firstName.value+" "+n.lastName.value;if(r&&n.title){r[c]=n.title.value}if(o&&n.phoneNbr){o[c]=n.phoneNbr.value}k[c]=s;k.style.display="block";n.style.visibility="hidden";setTimeout(function(){j.closeForm()},3500)},closeForm:function(){k.innerHTML="";k.style.display="none";n.style.visibility="visible";tb_remove()}}},editTypes:function(){var A;var v;var s;var C;var t;var x=[];var u={};var B;var z;var r;var w;var o;var m;var y;var q="ROLE_DEMO";var n=/ROLE_DISTRICT_ADMINISTRATOR|ROLE_STUDENT|ROLE_DEMO/;var D="ROLE_DEMO|ROLE_TEACHER|ROLE_ADMINISTRATOR|ROLE_DISTRICT_ADMINISTRATOR";var j;var k;var p;return{setup:function(){y=s=this;m=new RegExp(roleString);this.formName=v="editTypes";this.theForm=A=document.getElementById(v);document.getElementById("typesCancel").onclick=this.cancel;B=document.getElementById("districtAdminOption");z=document.getElementById("singleOptionRoles");r=document.getElementById("studentOption");t=A.elements;A.onsubmit=this.submit;if(m.test("ROLE_DISTRICT_ADMINISTRATOR")){k=this.schoolPickList();k.setup()}this.setCurRoles();p=this.setPreviousRoles()},setCurRoles:function(){var H="none";if(m.test(D)){if(getsDistrictAdmin){B.style.display="block";H="block"}else{B.style.display="none"}if(m.test(q)){r.style.display="block";H="block"}}z.style.display=H;currentFields=[];for(var F=0,E=t.length;F<E;F++){var G=t[F];if(G.nodeName=="INPUT"&&/userType/.test(G.name)){G.onchange=this.checkRules;if(m.test(G.value)){G.checked=true}x.push({key:G.value,field:G});x[G.value]=G}}},cancel:function(){var E=x.length;var F;do{F=x[--E];if(m.test(F.key)){F.field.checked=true}else{F.field.checked=false}}while(E);tb_remove()},submit:function(F){if(!s.buttons||s.buttons.length==0){s.getButtons(document.getElementById("TB_ajaxContent"))}s.disableButtons();var E=s.rollYourOwnSerialize();$.post("updateUserRoles.html",E,s.callBack,"json");s.stopDefault(F)},callBack:function(E){if(E[0].Status=="Success"){window.location.reload()}else{s.enableButtons();alert(E[1][0].value)}},isValid:function(){var E=inputs.length;do{if(inputs[--E].field.checked){return true}}while(E);return false},rollYourOwnSerialize:function(){var E="";for(i=0,l=x.length;i<l;i++){var F=x[i].field;if(F.checked){E+="userTypes="+encodeURIComponent(F.value)+"&"}}if(/DISTRICT_/.test(E)){E+="id="+A.uid.value+"&institutionId="+A.did.value}else{E+="id="+A.uid.value+"&institutionId="+A.sid.value}return E.replace(/DISTRICT_/,"")},setPreviousRoles:function(){var F=x;var E=F.length;var G="";do{if(F[--E].field.checked){G+=F[E].key}}while(E);return G},checkRules:function(H){var I=this.value;var E=x;if(this.checked&&G(I)){switch(I){case"ROLE_DISTRICT_ADMINISTRATOR":if(confirm(messages.text("districtAdminOneRoleOnly")+"\n\nChange to District Admin Role?")){F("ROLE_DISTRICT_ADMINISTRATOR")}else{this.checked=false}break;case"ROLE_STUDENT":if(confirm(messages.text("studentsOneRoleOnly")+"\n\nChange to Student Role?")){F("ROLE_STUDENT")}else{this.checked=false}break;case"ROLE_DEMO":if(confirm(messages.text("trialUsersOneRoleOnly")+"\n\nChange to Trial User Role?")){F("ROLE_DEMO")}else{this.checked=false}break;default:if(/ROLE_STUDENT/.test(p)){if(confirm(messages.text("studentsOneRoleOnly")+"\n\nOk to change role?")){x.ROLE_STUDENT.checked=false}else{F("ROLE_STUDENT")}}else{if(/ROLE_DEMO/.test(p)){if(confirm(messages.text("trialUsersOneRoleOnly")+"\n\nOk to change role?")){x.ROLE_DEMO.checked=false}else{F("ROLE_DEMO")}}else{if(/ROLE_DISTRICT_ADMINISTRATOR/.test(p)){if(confirm(messages.text("districtAdminOneRoleOnly")+"\n\nOk to change role?")){if(k){k.open(I)}else{x.ROLE_DISTRICT_ADMINISTRATOR.checked=false}}else{F("ROLE_DISTRICT_ADMINISTRATOR")}}}}}p=s.setPreviousRoles()}function G(K){if(n.test(K)){var J=new RegExp(K);return !J.test(p)}if(n.test(p)){return !n.test(K)}return false}function F(L){var J=E.length;if(n.test(L)){do{var K=E[--J];if(K.key!=L&&K.field.checked){K.field.checked=false}}while(J)}else{do{var K=E[--J];if(!/'ROLE_STUDENT'|'ROLE_DEMO'/.test(K.key)&&K.field.checked){K.field.checked=false}}while(J)}}},handleSchoolPick:function(E){if(E.id){x.ROLE_DISTRICT_ADMINISTRATOR.checked=false;A.sid.value=E.id}else{x[E.newfield].checked=false;x.ROLE_DISTRICT_ADMINISTRATOR.checked=true}p=s.setPreviousRoles()},schoolPickList:function(){var M="<tr><td style='width: 20px;'><input name='schoolIds' value='%id%' type='radio' style='width: 18px;'></td><td><strong>%name%</strong><br/>%address1% %address2% %city%, %state%</td></tr>";var H=null;var J=null;var K;var F;var I;var N;var E;var L;var O;var G;return{setup:function(){E=schoolList;N="schoolPickList";I=document.getElementById(N);I.onsubmit=this.submit;I.picklist=this;O=this;F=document.getElementById("schoolListDiv");L=document.getElementById("schoolPickListCont");document.getElementById("schl_closeWindowButton").onclick=this.cancel;document.getElementById("schl_cancel").onclick=this.cancel;jQuery(".pickTabs").click(this.tab);K=jQuery(".pickTabs li");this.loadTables()},submit:function(S){var P=I.getElementsByTagName("input");var Q=P.length;var R;var T=null;while(Q--){R=P[Q];if(R.checked){T=R.value;break}}s.stopDefault(S);if(T!==null){}this.picklist.save({id:T,newfield:G})},open:function(P){G=P;L.style.display="block"},cancel:function(){L.style.display="none";y.handleSchoolPick({id:false,newfield:G})},save:function(P){L.style.display="none";y.handleSchoolPick(P)},tab:function(Q){Q=Q||window.event;var P=Q.target||Q.srcElement;if(P.className=="empty"){return}if(H){H.className="";J.style.display="none"}P.className="selected";var R=P[c].charAt(0).trim();J=document.getElementById(R);J.style.display="";H=P},loadTables:function(){E.sort(function(X,W){var Y=X.name.toUpperCase();var Z=W.name.toUpperCase();if(Y<Z){return -1}if(Z<Y){return 1}return 0});var T=['<table style="width: 100%;">'];var S,U,V="";for(var Q=0,P=E.length;Q<P;){U=E[Q];S=U.name.charAt(0).toUpperCase();T.push("<tbody id="+S+' style="display: none;">');while(Q<P&&(U.lname.charAt(0).toUpperCase()==S)){T.push(M.replace(/%(\w+)%/g,function(X,W){if(W=="address1"){if(!U.address2){return U[W]+","}return U[W]+"<br>"}if(W=="address2"&&!U.address2){return""}if(W=="city"){return U[W]}return U[W]}));U=E[++Q]}T.push("</tbody>")}F.innerHTML=T.join("\n");for(var Q=0;Q<27;Q++){var R=K[Q];if(V.indexOf(R[c].charAt(0))==-1){R.className="empty"}else{R.className=""}}J=document.getElementById(V.charAt(0));J.style.display="";H=K[V.charCodeAt(0)-65];H.className="selected"}}}}},editTeacherLicenses:function(){var A;var y;var t="addLicenses";var C=null;var s=null;var z="removeLicenses";var r=null;var q="removeLicenseBtn";var v=null;var p=false;var k=[];var x;var E;var n;var o="deleteTeachersLicenses.html";var D="addTeachersLicenses.html";var u;var B;var j='<input type="text" value="0" style="width: 38px;"/><span class="spinnerUP"></span><span class="spinnerDN"></span>';var w='<button type="button" class="graphical"><span>Add</span></button>';var m='<input class="checkbox" type="checkbox" value="%licenseId%" name="instanceIds"/>';return{setup:function(){ctrlObj=this;C=document.getElementById(t);r=document.getElementById(z);document.getElementById(q).onclick=this.removeLicense;v=document.getElementById("licenseDone");v.onclick=this.close;E=document.getElementById("addLicenseTbody");E.onclick=this.addLicenses;n=document.getElementById("removeLicenseTbody")},removeLicense:function(J){s=jQuery("#removeLicenses input[type=checkbox]");var K,M;var I=0,H=s.length;var L,N,M,G;k=[];while(I<H){L=s[I++];if(L.checked){M=L.parentNode;N=M.parentNode;G="l_"+L.value;k.push({rowId:G,row:N})}}if(k.length){if(!ctrlObj.buttons||ctrlObj.buttons.length==0){ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}ctrlObj.disableButtons();var F=$(r).serialize();jQuery.post(o,F,ctrlObj.removeCallback,"json")}ctrlObj.stopDefault(J)},removeCallback:function(L){ctrlObj.enableButtons();var P,O;if(L.Status=="Success"){p=true;var I=E.rows;var J=I.length;var K={};var F,P,O,H;var G;while(J--){K[I[J].id]=I[J]}J=k.length;while(J--){F=k[J];n.removeChild(F.row)}var N=L.Data;J=N.length;var M;while(J--){M=N[J];H="l_"+M.licenseId;if(I[H]){ctrlObj.addFreeLicenses(I[H],M.unassignedCount)}else{P=E.insertRow(P);P.id=H;I[H]=P;O=P.insertCell(-1);O[c]=M.productCode;O=P.insertCell(-1);O.setAttribute("align","center");G=document.createElement("div");G.className="spinner";G.setAttribute("min","0");G.setAttribute("max",M.unassignedCount);G.setAttribute("showMax","true");G.style.width="78px";O.appendChild(G);G.innerHTML=j;O=P.insertCell(-1);O.setAttribute("style","padding-left: 8px;");O.innerHTML=w;new Spinner(G)}ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}}else{alert("Your request could not be processed. Please try again later.")}},addLicenses:function(L){L=L||window.event;var J=L.target||L.srcElement;while(J.nodeName!="TBODY"){if(J.nodeName=="BUTTON"){x=J.parentNode.parentNode;B=x.getElementsByTagName("input")[0];var M=B.value;var G=B.parentNode;var I=M.lastIndexOf("/");if(I>-1){M=M.substring(0,I)*1}var F=G.getAttribute("max");if(M>0){if(M==F){E.removeChild(x)}else{G.setVal(0)}if(!ctrlObj.buttons||ctrlObj.buttons.length==0){ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}ctrlObj.disableButtons();var H=ctrlObj.extractId(x.id);C.count.value=M;C.licenseId.value=H;var K=$(C).serialize();jQuery.post(D,K,ctrlObj.addCallback,"json")}else{alert("Please select a number of licenses greater than zero.")}break}J=J.parentNode}},addCallback:function(I){var G,J,F;ctrlObj.enableButtons();if(I.Status=="Success"){p=true;var K=I.Data;var H=K.length;while(H--){G=K[H];ctrlObj.removeFreeLicenses();J=n.insertRow(-1);F=J.insertCell(-1);F.setAttribute("align","center");F.innerHTML=m.replace(/%licenseId%/,G.instanceIds);F=J.insertCell(-1);F[c]=G.productCode;F=J.insertCell(-1);F[c]=G.endDate}}else{alert("Your request could not be processed. Please try again later.")}},addFreeLicenses:function(H,F){var G=H.getElementsByTagName("input")[0].parentNode;G.changeMax(F)},removeFreeLicenses:function(){B.value="0";var G=B.parentNode;var F=G.changeMax();G.changeMax(F-1)},close:function(){if(p){ctrlObj.disableButtons();window.location.reload()}else{tb_remove()}}}},editSchoolLicenses:function(){var A;var y;var t="addLicenses";var C=null;var s=null;var z="removeLicenses";var r=null;var q="removeLicenseBtn";var v=null;var p=false;var k=[];var x;var E;var n;var o="deleteLicenses.html";var D="addLicenses.html";var u;var B;var j='<input type="text" value="0" style="width: 38px;"/><span class="spinnerUP"></span><span class="spinnerDN"></span>';var w='<button type="button" class="graphical"><span>Add</span></button>';var m='<input class="checkbox" type="checkbox" value="%licenseId%" name="instanceIds"/>';return{setup:function(){ctrlObj=this;C=document.getElementById(t);r=document.getElementById(z);document.getElementById(q).onclick=this.removeLicense;v=document.getElementById("licenseDone");v.onclick=this.close;E=document.getElementById("addLicenseTbody");E.onclick=this.addLicenses;n=document.getElementById("removeLicenseTbody")},removeLicense:function(J){s=jQuery("#removeLicenses input[type=checkbox]");var K,M;var I=0,H=s.length;var L,N,M,G;k=[];while(I<H){L=s[I++];if(L.checked){M=L.parentNode;N=M.parentNode;G="l_"+L.value;k.push({rowId:G,row:N})}}if(k.length){if(!ctrlObj.buttons||ctrlObj.buttons.length==0){ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}ctrlObj.disableButtons();var F=$(r).serialize();jQuery.post(o,F,ctrlObj.removeCallback,"json")}ctrlObj.stopDefault(J)},removeCallback:function(L){ctrlObj.enableButtons();var P,O;if(L.Status=="Success"){p=true;var I=E.rows;var J=I.length;var K={};var F,H,P,O;var G;while(J--){K[I[J].id]=I[J]}J=k.length;while(J--){F=k[J];n.removeChild(F.row)}var N=L.Data;J=N.length;var M;while(J--){M=N[J];H="l_"+M.licenseId;if(I[H]){ctrlObj.addFreeLicenses(I[H],M.unassignedCount)}else{P=E.insertRow(P);P.id=H;I[H]=P;O=P.insertCell(-1);O[c]=M.productCode;O=P.insertCell(-1);O.setAttribute("align","center");G=document.createElement("div");G.className="spinner";G.setAttribute("min","0");G.setAttribute("max",M.unassignedCount);G.setAttribute("showMax","true");G.style.width="78px";O.appendChild(G);G.innerHTML=j;O=P.insertCell(-1);O.setAttribute("style","padding-left: 8px;");O.innerHTML=w;new Spinner(G)}ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}}else{alert("Your request could not be processed. Please try again later.")}},addLicenses:function(L){L=L||window.event;var J=L.target||L.srcElement;while(J.nodeName!="TBODY"){if(J.nodeName=="BUTTON"){x=J.parentNode.parentNode;B=x.getElementsByTagName("input")[0];var M=B.value;var G=B.parentNode;var I=M.lastIndexOf("/");if(I>-1){M=M.substring(0,I)*1}var F=G.getAttribute("max");if(M>0){if(M==F){E.removeChild(x)}else{G.setVal(0)}if(!ctrlObj.buttons||ctrlObj.buttons.length==0){ctrlObj.getButtons(document.getElementById("TB_ajaxContent"))}ctrlObj.disableButtons();var H=ctrlObj.extractId(x.id);C.count.value=M;C.licenseId.value=H;var K=$(C).serialize();jQuery.post(D,K,ctrlObj.addCallback,"json")}else{alert("Please select a number of licenses.\n\nIf only zero licenses can be selected, no more are availble.")}break}J=J.parentNode}},addCallback:function(I){var G,J,F;document.body.style.cursor="default";ctrlObj.enableButtons();if(I.Status=="Success"){p=true;var K=I.Data;var H=K.length;while(H--){G=K[H];ctrlObj.removeFreeLicenses();J=n.insertRow(-1);F=J.insertCell(-1);F.setAttribute("align","center");F.innerHTML=m.replace(/%licenseId%/,G.instanceIds);F=J.insertCell(-1);F[c]=G.productCode;F=J.insertCell(-1);F[c]=G.endDate}}else{alert("Your request could not be processed. Please try again later.")}},addFreeLicenses:function(H,F){var G=H.getElementsByTagName("input")[0].parentNode;G.changeMax(F)},removeFreeLicenses:function(){B.value="0";var G=B.parentNode;var F=G.changeMax();G.changeMax(F-1)},close:function(){if(p){ctrlObj.disableButtons();window.location.reload()}else{tb_remove()}}}},requestFull:function(){var n;var m;var j;var k;return{setup:function(){this.ctrlObj=j=this;this.formName=m="requestFull";this.theForm=n=document.requestFull;n.onsubmit=this.submit;k="getTheFullVersion.html";this.getButtons();this.getSuccessBlock()},submit:function(p){p=p||window.event;var o=$(n).serialize();$.post(k,o,j.callback,"json");j.stopDefault(p)},callback:function(o){document.body.style.cursor="default";if(o.Status=="Success"){j.showSuccess("Thank you for your continued interest in StrataLogica. Your Nystrom Sales Representative has been notified and will be in contact to assist you with your order.")}else{alert("Could not process request. Please try later.")}}}},sendFeedback:function(){var m;var k;var j;return{setup:function(){this.ctrlObj=j=this;this.formName=k="sendFeedback";this.theForm=m=document.sendFeedback;m.onsubmit=this.submit;url="submitFeedBack.html";this.getButtons();this.getSuccessBlock()},submit:function(o){o=o||window.event;j.clearErrors();if(m.feedback.value.notEmpty()){document.body.style.cursor="wait";j.disableButtons();var n=$(m).serialize();$.post(url,n,j.callback,"json")}else{j.setErrorMsg(m.feedback,"Please enter your comments.")}j.stopDefault(o)},callback:function(n){j.enableButtons();document.body.style.cursor="default";if(n.success||n.Status&&n.Status.toLowerCase()=="success"){j.showSuccess("Thank you for your interest and feedback.")}else{alert("Could not submit feedback. Please try later.")}}}},submitTestimonial:function(){var m;var k;var j;return{setup:function(){this.ctrlObj=j=this;this.formName=k="danielle";this.theForm=m=document.getElementById(k);this.getButtons();this.getSuccessBlock();m.onsubmit=function(n){j.clearErrors();n=n||window.event;if(m.firstName.value.isEmpty()||m.lastName.value.isEmpty()||m.fromEmail.value.isEmpty()||m.city.value.isEmpty()||m.state.value.isEmpty()||m.school.value.isEmpty()||m.position.value.isEmpty()||m.quote.value.isEmpty()){if(m.firstName.value.isEmpty()){j.setErrorMsg(m.firstName,"Please enter your First Name.")}if(m.lastName.value.isEmpty()){j.setErrorMsg(m.lastName,"Please enter your Last Name.")}if(m.fromEmail.value.isEmpty()){j.setErrorMsg(m.fromEmail,"Please enter your email address.")}if(m.city.value.isEmpty()){j.setErrorMsg(m.city,"Please enter your city.")}if(m.state.value.isEmpty()){j.setErrorMsg(m.state,"Please select your state.")}if(m.school.value.isEmpty()){j.setErrorMsg(m.school,"Please enter your school name.")}if(m.position.value.isEmpty()){j.setErrorMsg(m.position,"Please enter your position.")}if(m.quote.value.isEmpty()){j.setErrorMsg(m.quote,"Please enter a message.")}j.stopDefault(n)}else{document.body.style.cursor="wait";j.disableButtons()}};window.uploadCallBack=function(n){j.callBack(n)}},callBack:function(n){document.body.style.cursor="default";j.enableButtons();if(n.Status=="Success"){j.clearErrors();j.showSuccess("Thank you for your testimonial!")}else{j.showErrors(n.Errors)}}}},sendRecommendation:function(){var n;var m;var j;var k;return{setup:function(){this.ctrlObj=j=this;this.formName=m="sendRecommendation";this.theForm=n=document.sendRecommendation;n.onsubmit=this.submit;k=this.fixUrl("sendRecommendation.html");this.getButtons();this.getSuccessBlock()},submit:function(p){p=p||window.event;if(n.name.value.notEmpty()&&n.recommendation.value.notEmpty()&&n.recipients.value.notEmpty()&&n.sender.value.notEmpty()){n.recipients.value=n.recipients.value.remSpace();var o=$(n).serialize();$.post(k,o,j.callback,"json")}else{if(n.name.value.isEmpty()){j.setErrorMsg(n.name,"Please enter your name.")}if(n.recommendation.value.isEmpty()){j.setErrorMsg(n.recommendation,"Please enter a recommendation.")}if(n.recipients.value.isEmpty()){j.setErrorMsg(n.recipients,"Please enter a recipient.")}if(n.sender.value.isEmpty()){j.setErrorMsg(n.sender,"Please enter your email address.")}}j.stopDefault(p)},callback:function(o){document.body.style.cursor="default";if(o.Status=="Success"){j.showSuccess("Thank you for your recommendations")}else{j.showErrors(o.Errors)}}}}};function d(k){this.theForm;this.formName=null;this.ctrlObj=null;this.url=null;this.id=null;this.buttons=null;this.successNoticeArea=null;if(k in f){var m=f[k]();for(var j in m){this[j]=m[j]}}if(this.init){this.init()}this.setup()}d.prototype.setup=function(){};d.prototype.submit=function(j){};d.prototype.fixUrl=function(j){if(!/\/home\//.test(window.location.href)){j="home/"+j}return j};d.prototype.stopDefault=function(j){j=j||window.event;if(j.preventDefault){j.preventDefault()}else{j.returnValue=false}return false};d.prototype.callBack=function(j){};d.prototype.validEmail=function(j){return g.test(j)};d.prototype.confirmAction=function(j){j=j||"Are you sure you want to delete this?";return confirm(j)};d.prototype.extractId=function(j){return j.replace(b,"")};d.prototype.getSuccessBlock=function(){var j=this.theForm;var k=j.previousSibling;while(k.nodeName!="BODY"){while(k){j=k;if(k.nodeName=="P"&&k.className=="successNotice"){this.successNoticeArea=k;return k}k=k.previousSibling}k=j.parentNode}return null};d.prototype.showSuccess=function(k){if(this.successNoticeArea){this.successNoticeArea[c]=k;this.successNoticeArea.style.display="block";this.theForm.style.display="none";var j=this.ctrlObj;setTimeout(function(){j.close()},3500)}};d.prototype.hideSuccess=function(){if(this.successNoticeArea){this.successNoticeArea[c]="";this.successNoticeArea.style.display="none";this.theForm.style.display="block"}};d.prototype.showErrors=function(n){var k=n&&n.length;while(k--){var m=n[k].key;var j=this.theForm[m].previousSibling;while(j){if(j.nodeType==1&&j.className=="errorText"){j[c]=n[k].value;break}j=j.previousSibling}}};d.prototype.setErrorMsg=function(k,m){var j=k.previousSibling;while(j){if(j.nodeType==1&&j.className=="errorText"){break}j=j.previousSibling}if(j){j[c]=m}};d.prototype.close=function(){this.clearErrors();this.theForm.reset();this.hideSuccess();tb_remove()};d.prototype.disableButtons=function(){var k=this.buttons;var j=k&&k.length;while(j--){k[j].disabled=true}document.body.style.cursor="wait"};d.prototype.enableButtons=function(){var k=this.buttons;var j=k&&k.length;while(j--){k[j].disabled=false}document.body.style.cursor="default"};d.prototype.getButtons=function(j){j=j||this.theForm;this.buttons=j.getElementsByTagName("button")};d.prototype.clearErrors=function(){$("#"+this.formName+" .errorText").text("")};return function(){var j=arguments.length;while(j--){try{new d(arguments[j])}catch(k){}}}})();function setupForm(p){var d=document.getElementById("notStudent").style;var e=document.getElementById("studentInfo").style;var c=document.body.textContent?"textContent":"innerText";var m;var o="Student Users may use either their email address as a username, or create a unique username in order to use Stratalogica.\n\nStudents without an email address as a username in the system will require a teacher's help to reset their passwords.\n\nClick OK to use the Email address?";var g="Student Users may use either their email address as a username, or create a unique username in order to use Stratalogica.\n\nStudents without an email address as a username in the system will require a teacher's help to reset their passwords.\n\nClick OK to use a user Name?";if(!p){m=$("form")}else{m=document.getElementById(p)}newUserTypes.sort(function(r,q){if(r.text<q.text){return -1}if(r.text>q.text){return 1}return 0});var b=m.userTypes.options;for(var j=0;j<newUserTypes.length;j++){if(newUserTypes[j].value=="ROLE_DEMO"){continue}if(!getsDistrictAdmin&&newUserTypes[j].value=="ROLE_DISTRICT_ADMINISTRATOR"){continue}b[b.length]=new Option(newUserTypes[j].text,newUserTypes[j].value)}m.onsubmit=h;m.show=function(q){if(q){d.display="none";e.display="block"}else{d.display="block";e.display="none"}};document.getElementById("userTypes").onchange=function(v){var s=this.options;var u=[];var r=s.length;var t=false;do{if(s[--r].selected){u.push(s[r]);t=s[r].value=="ROLE_STUDENT"&&true||t}}while(r);if(t&&u.length>1){alert(messages.text("studentsOneRoleOnly"));q()}document.getElementById("userType_err")[c]="";m.show(t);function q(){var w=u.length;while(w--){if(u[w].value!="ROLE_STUDENT"){u[w].selected=false}}}};m.confirmEmail.onblur=n;m.email1.onblur=n;m.firstName.onblur=a;m.lastName.onblur=a;function a(){var q=document.getElementById(this.id+"_err");if(this.value.notEmpty()){q[c]=""}}function n(){var s=document.getElementById("confirmEmail_err");var r=m.confirmEmail.value;var q=m.email1.value;if(q.notEmpty()){document.getElementById(m.email1.id+"_err")[c]=""}if(r==q||r.isEmpty()){s[c]=""}}function f(){if(m.userTypes.value=="ROLE_STUDENT"){return true}var r=m.confirmEmail.value.trim();var q=m.email1.value.trim();var s=document.getElementById("confirmEmail_err");if(r!=q){s[c]=messages.text("emailMatchErr");return false}else{s[c]="";return true}}function k(){tb_remove();$("#newUser .errorText").text("");m.reset()}function h(v){v=v||window.event;var w=v.target||v.srcElement;var s=this.className.slice(9);var x=m.userTypes.value=="ROLE_STUDENT";var B=new RegExp(x?"(email)2":"(email)1");var t="";var y=m.getElementsByTagName("button");function u(D){var E;document.body.style.cursor="default";m.cursor="default";z(true);if(D[0].Status!="Failed"){A(D[0].newUserId);var C=document.getElementById("formSuccessNotification").style;m.style.display="none";C.display="block";setTimeout(function(){C.display="none";m.style.display="block";k()},3500)}else{var F=D[1];var q=F.length;while(q--){E=F[q].key;if(E=="email"){E=(m.userTypes.value=="ROLE_STUDENT"?"email2":"email1")}document.getElementById(E+"_err")[c]=F[q].value}}}function A(D){var E=m.userTypes.value=="ROLE_STUDENT";var F={title:m.title.value,email:(E?m.email2.value:m.email1.value),phoneNbr:m.phoneNbr.value,userid:D,userName:(!E?"":m.userName.value),lastname:m.lastName.value,firstname:m.firstName.value,graduationYear:m.graduationYear.value,types:[]};var q=m.userTypes.options;for(var C=0;C<q.length;C++){if(q[C].selected){F.types.push({value:q[C].text,key:q[C].value})}}tableCtrl.insertRecord(F)}if(x||f()){if(!x||!m.email2.value.isEmpty()){t="&emailAsUsername=true"}this.style.cursor="wait";document.body.style.cursor="wait";z(false);if(m.userTypes.value=="ROLE_DISTRICT_ADMINISTRATOR"){m.institutionId.value=s}var r=$(m).serialize();if(m.userTypes.value=="ROLE_DISTRICT_ADMINISTRATOR"){r=r.replace(/_DISTRICT/,"")}$.post("addUserJson.html",r.replace(B,"$1")+t,u,"json")}function z(C){for(var q=0;q<y.length;q++){y[q].disabled=!C}}if(v.preventDefault){v.preventDefault()}else{v.returnValue=false}return false}document.getElementById("studentUserName").onkeypress=function(v){v=v||window.event;var s=v.target||v.srcElement;var u;if(s.value.notEmpty()){return}u=v.keyCode;if(v.charCode!=undefined){if(v.keyCode){return}u=v.charCode}if(u==9){return}if(u==32){if(v.preventDefault){v.preventDefault()}else{v.returnValue=false}return false}var r=m.userName;var q=m.email2;switch(s.id){case"email2":if(r.value.notEmpty()){if(confirm(o)){r.value=""}else{if(v.preventDefault){v.preventDefault()}else{v.returnValue=false}}}break;case"userName":if(q.value.notEmpty()){if(confirm(g)){q.value=""}else{if(v.preventDefault){v.preventDefault()}else{v.returnValue=false}}}break}}}function handleDelete(d){d=d||window.event;var b=d.target||d.srcElement;while(b&&b.nodeName!="TBODY"){if(b.nodeName=="TD"){var f=b.parentNode;if(b.cellIndex+1==f.cells.length){var g;var c=f.cells[b.cellIndex-3];c=c.textContent||c.innerText;if(/Student/.test(c)){g=messages.text("delStudent")}else{g=messages.text("delNonStudent")}if(confirm(g)){var a=f.id.replace("r_","");deleteSchoolUser(a,"deleteInstitutionalUser.html",f.sectionRowIndex)}}break}b=b.parentNode}}var bulkUploadCtrl=(function(){var c=document.body.innerText?"innerText":"textContent";var f=null;var b=null;var h=null;var n=new RegExp(".(csv|txt)$","i");var o={ROLE_TEACHER:{upload:"uploadTeacherList.html",save:"saveTeacherList.html",header:['<table style="width:725px;"><thead><tr>','<th style="width: 25px;" class="first">Row</th>','<th style="width: 90px;">First Name</th>','<th style="width: 90px;">Last Name</th>','<th style="width: 131px;">Email</th>','<th style="width: 90px;">Title</th>','<th style="width: 84px;">Phone</th>','<th style="width: 141px;" class="last">Status</th>'].join(""),row:"<td>%index%</td><td>%firstName%</td><td>%lastName%</td><td>%email%</td><td>%title%</td><td>%phoneNbr%</td><td>%errors%</td>",badcount:'<td>%index%</td><td colspan="5">%rawLine%</td><td>%errors%</td>',allOK:'<td colspan="7">All records successfully loaded.</td>',saved:"%good% teachers were successfuly uploaded. %bad% teachers had errors at the following rows:",confirmTitle:"Upload Users Confirmation"},ROLE_STUDENT:{upload:"uploadStudentList.html",save:"saveStudentList.html",header:['<table style="width:725px;"><thead><tr>','<th style="width: 25px;" class="first" style="width: px;">Row</th>','<th style="width: 90px;">First Name</th>','<th style="width: 90px;">Last Name</th>','<th style="width: 160px;">User Name</th>','<th style="width: 80px;">Password</th>','<th style="width: 60px;">Grad Year</th>','<th style="width: 146px;" class="last">Status</th>'].join(""),row:"<td>%index%</td><td>%firstName%</td><td>%lastName%</td><td>%userName%</td><td>%password%</td><td>%graduationYear%</td><td>%errors%</td>",badcount:'<td>%index%</td><td colspan="5">%rawLine%</td><td>%errors%</td>',allOK:'<td colspan="7">All records successfully loaded.</td>',saved:"%good% Student Users were successfuly uploaded. %bad% Student Users had errors at the following rows:",confirmTitle:"Upload Users Confirmation"}};var k=/%(\w+)%/g;var d={all:"Cancel",errors:"Cancel and try again"};var g={all:"Proceed",errors:"Proceed with Errors"};var e={all:'Click "Proceed" if the information in <strong>all</strong> records is correct.',errors:"If you proceed, the rows with errors will not be entered into the  system. You may enter the corrected rows in a subsequent upload."};var p={all:"All records validated.",errors:"%n% records have errors."};var j=null;var a=false;var m;return{setupFileUploadForm:function(r){h=document.getElementById(r);var q=h.users;q.validate=this.checkFileType;q.onchange=q.validate;var s=h.bulkUserTypeX;s.validate=this.checkUserType;s.onchange=this.typeChange;h.onsubmit=function(t){if(this.users.value.replace(/^\s+|\s+$/g,"")==""||!this.users.validate()||!this.bulkUserTypeX.validate()){t=t||window.event;if(t.preventDefault){t.preventDefault()}else{t.returnValue=false}return false}return true};window.uploadCallBack=function(t){bulkUploadCtrl.callBack(t)}},typeChange:function(){var q=this.value;m=o[q];h.action=m&&m.upload||""},checkFileType:function(){if(!n.test(this.value)){if(/xls.?$/.test(this.value)){alert(messages.text("noXl"))}else{alert(messages.text("wrongFileType"))}return false}else{return true}},checkUserType:function(){if(!m){alert(messages.text("noUserType"));return false}return true},getTempNode:function(){return f},getContainer:function(){return b},clearNodes:function(){f=b=null;a=false},callBack:function(L){var r=document.getElementById("fileUploadForm");var A,M=0;var K=L.successCount||0;var v=m.save;var G=m.header+"</tr></thead><tbody>";var x='<tr class="%stripe%">'+m.row+"</tr>";var q='<tr class="%stripe%">'+m.badcount+"</tr>";var D='<tr class="goodRow"> '+m.allOK+"</tr>";var F=m.saved;var A,M=0;if(!a){var s=z(L.newUsers);var C=['<form id="finalUserSubmit" name="finalUserSubmit" method="get" action="'+v+'"',' onsubmit=""',' target="fileUpload">','<div class="TB_contentTop"><div></div></div><div class="TB_fields">','<p id="errorNote">',(M&&p.errors.replace(/%n%/,M)||p.all),'</p><p id="uploadStatus"></p>','<div id="tableDiv">',s,'</div><input type="hidden"  name="save" value="true">','</div><div class="TB_contentBottom"><div></div></div>','<p class="TB_buttonRow" style="text-align: right;">','<button name="cancel" type="button" class="graphical" onclick="modalFx.replaceStuff(event);">',"<span>"+(M&&d.errors||d.all)+"</span>","</button>",'<button name="update" type="submit" class="graphical" onclick="this.disabled = true;">',"<span>"+(M&&g.errors||g.all)+"</span>","</button></p></form>"];a=true;b=document.createElement("div");b.id="uploadResultsContainer";var t=r.parentNode;var w=document.getElementById("TB_window");f=t.replaceChild(b,r);t.style.width="745px";t.style.height="470px";w.style.width="765px";w.style.marginLeft="-353px";w.style.marginTop="-257px";b.innerHTML=C.join("\n");if(browser.isMSIE||browser.isSafari){var I=b.getElementsByTagName("form")[0];var J=I.elements;var E=J.length;while(E--){if(J[E].type=="submit"){J[E].onclick=function(){this.disabled=true;this.form.submit()};break}}}var H=$("#TB_closeWindowButton");H.unbind("click");H.click(modalFx.replaceStuff);H.attr({name:"cancel"})}else{a=false;var u=document.getElementById("tableDiv");u.innerHTML=z(L.newUsers);var y=jQuery("#finalUserSubmit .TB_buttonRow");y.html('<button style="float: right;" type="button" name="done" id="done" class="graphical" onclick="window.location.reload();"><span>Finished</span></button><a style="float:right; margin-right: 3ex;" href="/NystromDigital/admin/viewUserUploadErrors.html"  target="_blank" class="linkButton"><span>Export List</span></a>');document.getElementById("errorNote").style.display="none";document.getElementById("uploadStatus").innerHTML=F.replace(k,function(O,N){if(N=="good"){return K||A-M}if(N=="bad"){return M}});B("TB_title_right",m.confirmTitle)}function B(R,Q){var O=document.getElementById(R).childNodes;for(var N=0,P=O.length;N<P;N++){if(O[N].nodeType==3&&/\S/.test(O[N].nodeValue)){O[N].nodeValue=Q;break}}}function z(N){var U="";var R=[G];A=N.length;for(var Q=0,O=A;Q<O;Q++){var T=N[Q];var S=T.failureReason;if(S.length){U="errorRow";M++}else{U="goodRow"}if(S&&/In-correct number of items/.test(S[0])){R.push(q.replace(k,P))}else{R.push(x.replace(k,P))}}if(!A){R.push(D)}R.push("</tbody></table>");function P(W,V){if(V=="stripe"){return U}if(V=="index"){return(Q+1)+""}if(V=="errors"){var Z=S.length?S[0]:"Record OK";for(var X=1,Y=S.length;X<Y;X++){Z+="<br>"+S[X]}return Z}return T[V]||""}return R.join("\n")}}}})();function postResend(b,d){b=b||window.event;var a=b.target||b.srcElement;do{a=a.parentNode}while(a&&a.nodeName!="P");function c(e){document.body.style.cursor="default";if(e[0].Status=="Success"){alert("Activation Email sent");a.style.display="none"}else{alert("There was a system error.\nPlease try sending the activation email later.")}}document.body.style.cursor="wait";jQuery.post("resendActivationEmailJson.html","id="+d,c,"json")};