
﻿var _netver=2;var _prevdivId='';function switchLng(){window.location.href="menu_s.aspx";}
function adultClick(){switchTab(1);$("#optSP").attr("checked",true);displayDivBox(document.getElementById("optSP"));$.fn.colorbox.close();}
function cboOrgSelect(){var oCboOrgType=document.getElementById("cboOrgType");var ocboDioAdult=document.getElementById("cboDioAdult");var ocboAdventistState=document.getElementById("cboAdventistState");var ocboSchoolAtnType=document.getElementById("cboSchoolAtnType");var oDivCboDioAdult=document.getElementById("divCboDioAdult");var oImgOrgType=document.getElementById("imgOrgType");var oTrDiocese=$("#trDiocese");var oTrSchoolAtnType=$("#trSchoolAtnType");var oTrConfirm=$("#trConfirm");oTrSchoolAtnType.hide();oTrConfirm.hide();$("#trsdAdventist").hide();$("#trsdAdvLoc").hide();if(oCboOrgType.value=="0"){toggleImage("imgDiocese","b");toggleImage("imgOrgType","g");oTrDiocese.hide();}else{toggleImage("imgDiocese","g");toggleImage("imgOrgType","b");STVUtil.RemoveAllDropDownListItem(ocboDioAdult);STVUtil.RemoveAllDropDownListItem(ocboAdventistState);RemoveDropDownListItem(ocboSchoolAtnType,"91");RemoveDropDownListItem(ocboSchoolAtnType,"2");if(_refid==AttendeeType.YouthAdult){if(oCboOrgType.value=="ED"){oTrDiocese.show();for(var i=0;i<=(dioceses.adultEpiscopal.length-1);i++){STVUtil.AddDropDownListItem(dioceses.adultEpiscopal[i].name,dioceses.adultEpiscopal[i].id,ocboDioAdult);}}
else if(oCboOrgType.value=="CD"){oTrDiocese.show();for(var i=0;i<=(dioceses.adultCatholic.length-1);i++){STVUtil.AddDropDownListItem(dioceses.adultCatholic[i].name,dioceses.adultCatholic[i].id,ocboDioAdult);}}
else if(oCboOrgType.value=="OS"){oTrDiocese.hide();oTrSchoolAtnType.show()
$("#imgSchoolAtnType").show();document.getElementById("cboSchoolAtnType").selectedIndex=0;STVUtil.AddDropDownListItem("Parent","91",ocboSchoolAtnType);}
else if(oCboOrgType.value=="SDA"){oTrDiocese.hide();oTrSchoolAtnType.show();$("#imgSchoolAtnType").show();STVUtil.AddDropDownListItem("Parent","91",ocboSchoolAtnType);document.getElementById("cboSchoolAtnType").selectedIndex=0;}
else if(oCboOrgType.value=="CC"){STVUtil.AddDropDownListItem("Volunteer","2",ocboSchoolAtnType);oTrDiocese.hide();oTrSchoolAtnType.show();$("#imgSchoolAtnType").show();ocboSchoolAtnType.selectedIndex=0;}else if(oCboOrgType.value=="SHI"){oTrConfirm.show();}else if(oCboOrgType.value=="CCC"){oTrDiocese.hide();oTrConfirm.show();}}else if(_refid==AttendeeType.Youth||_refid==AttendeeType.PreTeen){if(oCboOrgType.value=="OS"){for(var i=0;i<=(dioceses.schoolDiocese.length-1);i++){STVUtil.AddDropDownListItem(dioceses.schoolDiocese[i].name,dioceses.schoolDiocese[i].id,ocboDioAdult);}
$("#trDiocese").show();$("#imgDiocese").show();$("#imgSchoolAtnType").hide();}
else if(oCboOrgType.value=="SDA"){STVUtil.AddDropDownListItem("Select State>>",0,ocboAdventistState);$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:'/Services/STVReport.asmx/AdvLocationTypeList',data:"{'MasterID':'1046'}",dataType:"json",success:function(result){result=(_netver<=2)?result:result.d;for(var ctr=0;ctr<result.length;ctr++){STVUtil.AddDropDownListItem(result[ctr].Title,result[ctr].Id,ocboAdventistState);}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Error Occured: "+errorThrown);}});$("#trsdAdventist").show();$("#imgAdv").show();oTrDiocese.hide();}else{oTrConfirm.show();toggleImage("imgOrgType","b");oTrDiocese.hide();}}}}
function schoolAtnTypeSelect(){var oCboOrgType=document.getElementById("cboOrgType");var ocboSchAtnType=document.getElementById("cboSchoolAtnType");var ocboDioAdult=document.getElementById("cboDioAdult");var ocboAdventistState=document.getElementById("cboAdventistState");$("#trsdAdvLoc").hide();STVUtil.RemoveAllDropDownListItem(ocboDioAdult);STVUtil.RemoveAllDropDownListItem(ocboAdventistState);if(oCboOrgType.value=="SDA"&&ocboSchAtnType.value!="0")
{STVUtil.AddDropDownListItem("Select State>>",0,ocboAdventistState);$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:'/Services/STVReport.asmx/AdvLocationTypeList',data:"{'MasterID':'1046'}",dataType:"json",success:function(result){result=(_netver<=2)?result:result.d;for(var ctr=0;ctr<result.length;ctr++){STVUtil.AddDropDownListItem(result[ctr].Title,result[ctr].Id,ocboAdventistState);}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Error Occured: "+errorThrown);}});$("#trsdAdventist").show();$("#imgAdv").show();$("#imgSchoolAtnType").hide();}else if(oCboOrgType.value=="CC"&&ocboSchAtnType.value!="0"){if(oCboOrgType.selectedIndex>0){toggleImage("imgDiocese","b");$("#imgSchoolAtnType").hide();$("#trConfirm").show();}else{toggleImage("imgDiocese","g");$("#imgSchoolAtnType").show();$("#trConfirm").hide();}}else{if(ocboSchAtnType.value==AttendeeType.Employee){for(var i=0;i<=(dioceses.employeeSchool.length-1);i++){STVUtil.AddDropDownListItem(dioceses.employeeSchool[i].name,dioceses.employeeSchool[i].id,ocboDioAdult);}
$("#trDiocese").show();$("#imgDiocese").show();$("#imgSchoolAtnType").hide();}else if(ocboSchAtnType.value==AttendeeType.Parent){for(var i=0;i<=(dioceses.parentSchool.length-1);i++){STVUtil.AddDropDownListItem(dioceses.parentSchool[i].name,dioceses.parentSchool[i].id,ocboDioAdult);}
$("#trDiocese").show();$("#imgDiocese").show();$("#imgSchoolAtnType").hide();}else{$("#trDiocese").hide();$("#imgDiocese").hide();$("#imgSchoolAtnType").show();$("#trConfirm").hide();$("#trsdAdventist").hide();}}}
function cboDioSelect(){var ocboDioAdult=document.getElementById("cboDioAdult");if(ocboDioAdult.selectedIndex>0){toggleImage("imgDiocese","b");$("#trConfirm").show();}else{toggleImage("imgDiocese","g");$("#trConfirm").hide();}}
function cboAdvSelect(){var ocboAdventistLoc=document.getElementById("cboAdventistLoc");var ocboAdventistState=document.getElementById("cboAdventistState");var locType;if(ocboAdventistState.selectedIndex>0){locType=ocboAdventistState.value;STVUtil.RemoveAllDropDownListItem(ocboAdventistLoc);STVUtil.AddDropDownListItem("Select School>>",0,ocboAdventistLoc);$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:'/Services/STVReport.asmx/AdvLocationList',data:"{'MasterID':'1046', 'LocType':'"+locType+"'}",dataType:"json",success:function(result){result=(_netver<=2)?result:result.d;for(var ctr=0;ctr<result.length;ctr++){STVUtil.AddDropDownListItem(result[ctr].Title,result[ctr].Id,ocboAdventistLoc);}},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Error Occured: "+errorThrown);}});$("#trsdAdvLoc").show();$("#imgAdvLoc").show();$("#imgAdv").hide();}else{$("#trsdAdvLoc").hide();$("#imgAdvLoc").hide();$("#imgAdv").show();}}
function cboAdvLocSelect(){var ocboAdventistLoc=document.getElementById("cboAdventistLoc");if(ocboAdventistLoc.selectedIndex>0){toggleImage("imgDiocese","b");$("#trConfirm").show();}else{toggleImage("imgDiocese","g");$("#trConfirm").hide();}}
function Confirm(){var oCboOrgType=document.getElementById("cboOrgType");var orgType=oCboOrgType.value;var ocboDioAdult=document.getElementById("cboDioAdult");var masterID=ocboDioAdult.value;var ocboAdventistState=document.getElementById("cboAdventistState");var locType=ocboAdventistState.value;var ocboAdventistLoc=document.getElementById("cboAdventistLoc");var locId=ocboAdventistLoc.value;var secType;var hasRegId=false;if(_refid==AttendeeType.YouthAdult){if(orgType=="OS"){var oCboSchoolAType=document.getElementById("cboSchoolAtnType");var aType=oCboSchoolAType.value;hasRegId=IsRegIdReq(masterID);gotoPage(hasRegId,"schoolregister.aspx?REFID="+aType+"&SID="+masterID);}else if(orgType=="SDA"){var oCboSchoolAType=document.getElementById("cboSchoolAtnType");var aType=oCboSchoolAType.value;secType="4";hasRegId=IsRegIdReq(1046);gotoPage(hasRegId,"schoolregister.aspx?REFID="+aType+"&SID=1046&ST="+secType+"&LocType="+locType+"&LocId="+locId);}else if(orgType=="SHI"){hasRegId=IsRegIdReq(1049);gotoPage(hasRegId,"schoolregister.aspx?REFID="+AttendeeType.Volunteer+"&SID=1049");}else if(orgType=="CCC"){hasRegId=IsRegIdReq(1056);gotoPage(hasRegId,"schoolregister.aspx?SID=1056");}else if(orgType=="CC"){var oCboSchoolAType=document.getElementById("cboSchoolAtnType");var aType=oCboSchoolAType.value;hasRegId=IsRegIdReq(1052);gotoPage(hasRegId,"schoolregister.aspx?REFID="+aType+"&SID=1052");}else{hasRegId=IsRegIdReq(masterID);gotoPage(hasRegId,"signup.aspx?REFID="+_refid+"&M="+masterID);}}else if(_refid==AttendeeType.Youth||_refid==AttendeeType.PreTeen){if(orgType=="OS"){hasRegId=IsRegIdReq(masterID);gotoPage(hasRegId,"schoolregister.aspx?REFID="+AttendeeType.Youth+"&SID="+masterID);}else if(orgType=="SDA"){secType="4";hasRegId=IsRegIdReq(1046);gotoPage(hasRegId,"schoolregister.aspx?REFID="+AttendeeType.Youth+"&SID=1046&ST="+secType+"&LocType="+locType+"&LocId="+locId);}else if(orgType=="CD"){secType="1"
gotoPage("false","TeenRegister.aspx?REFID="+_refid+"&ST="+secType);}else if(orgType=="ED"){secType="2";gotoPage("false","TeenRegister.aspx?REFID="+_refid+"&ST="+secType);}}}
function toggleImage(img,type){var src=(type=="g")?"images/home/triangle.jpg":"images/blank.gif";$("#"+img).attr("src",src);}
function gotoPage(regIdReq,page){if(regIdReq.toLowerCase()=="true"){var hdnToPage=document.getElementById("hdnToPage");hdnToPage.value=page;var frm=document.forms[0];frm.action="ValidateReg.aspx?SID=1056";frm.__VIEWSTATE.name="ignore";frm.submit();}else{if(_svr=="dev"){window.location.href=page;}else{window.location.href="https://www.shieldthevulnerable.org/"+page;}}}
function RemoveDropDownListItem(selectbox,pValue){var count;for(count=selectbox.options.length-1;count>=0;count--){if(selectbox.options[count].value==pValue){selectbox.remove(count);}}}
function IsRegIdReq(masterID){var hasRegId=false;$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:'/Services/Registration.asmx/IsRegIdReq',async:false,data:"{'MasterId':'"+masterID+"'}",success:function(result){hasRegId=result;},error:function(XMLHttpRequest,textStatus,errorThrown){alert("Error: "+errorThrown);hasRegId=false;}});return hasRegId;}
function showSection(divId){if(_prevdivId!=""&&_prevdivId!=divId&&$("#"+_prevdivId).is(":visible")){$("#"+_prevdivId).toggle(750);}
$("#"+divId).toggle(750);setTimeout(setLoginFocus,750);_prevdivId=divId;}
function setLoginFocus(){if($("#txtLogin").is(":visible")){document.getElementById("txtLogin").focus();}}