function OrgInterface(){}OrgInterface.post_org_select_callbacks=new Array();OrgInterface.post_org_reg_callbacks=new Array();OrgInterface.post_org_cookie_set_callbacks=new Array();OrgInterface.current_org_id=null;OrgInterface.allow_pending=false;OrgInterface.use_case="standard";OrgInterface.set_allow_pending=function(A){OrgInterface.allow_pending=A};OrgInterface.register_post_registration_callback=function(A){OrgInterface.post_org_reg_callbacks.push(A)};OrgInterface.register_post_org_cookie_set_callback=function(A){OrgInterface.post_org_cookie_set_callbacks.push(A)};OrgInterface.register_post_org_select_callback=function(A){OrgInterface.post_org_select_callbacks.push(A)};OrgInterface.find_orgs=function(){var B="oi_find_org_form";OrgInterface._cleanup(B);var A=document.getElementById(B);var E=A.oi_org_postal.value;var D=A.oi_org_type.value;if(D=="NULL"){D=""}var H=A.oi_org_country.value;if(H=="NULL"){H=""}if(!E||!H){OrgInterface._show_error(B,"In order to find your organization, we need both your zip/postal code and country information.")}else{OrgInterface._showloader(B);var G=makeParamString({org_postal:E,org_country:H,org_type:D,allow_pending:OrgInterface.allow_pending});var C=org_support_find;var F=new Ajax.Request(C,{method:"post",parameters:G,onSuccess:OrgInterface._handle_find_orgs,onFailure:OrgInterface._handle_find_orgs_failure})}return false};OrgInterface._handle_find_orgs=function(response){OrgInterface._hideloader("oi_find_org_form");var resp_obj=eval("("+response.responseText+")");OrgInterface._reset_org_list();if(resp_obj.error){OrgInterface._handle_find_orgs_failure()}else{if(resp_obj.error){var error_msg="";if(resp_obj.error=="server_error"){error_msg="There was a server error. Please try again later."}else{error_msg="There was a problem with your form submission. Please re-enter your data and try again."}OrgInterface._show_error("oi_find_org_form",error_msg)}else{if(resp_obj.length==0){OrgInterface._show_error("oi_org_select_form","No organizations were found matching your criteria.");swap_content("oi_select_org","oi_find_org")}else{OrgInterface._reset_org_choice_section();var select_field=document.getElementById("oi_org_select");for(var i=0;i<resp_obj.length;i++){var option_data=resp_obj[i];var new_option=new Option(option_data.text,option_data.value);select_field.options[i]=new_option}swap_content("oi_select_org","oi_find_org")}}}};OrgInterface._reset_org_list=function(){hideElement("oi_org_select_form_error");var A=document.getElementById("oi_org_select");A.options.length=0};OrgInterface._handle_find_orgs_failure=function(A){OrgInterface._show_error("oi_find_org_form","There was a server or network error. Please try again.")};OrgInterface._showloader=function(A){var B=A+"_loader";showElement(B,"inline")};OrgInterface._hideloader=function(A){var B=A+"_loader";hideElement(B)};OrgInterface._cleanup=function(A){OrgInterface._hide_error(A);OrgInterface._hideloader(A)};OrgInterface._hide_error=function(A){var B=A+"_error";hideElement(B)};OrgInterface._show_error=function(B,C){var D=B+"_error";var A=document.getElementById(D);if(A){A.innerHTML=C;showElement(D)}else{alert(C)}};OrgInterface.select_org=function(){var B="oi_org_select_form";OrgInterface._hide_error(B);var G=document.getElementById("oi_org_select");if(G.selectedIndex==-1){OrgInterface._show_error(B,"Please select an organization from the list below.")}else{var A=G.value;var E=A.split(":");var F=E[0];var D=E[1];for(var C=0;C<OrgInterface.post_org_select_callbacks.length;C++){OrgInterface.post_org_select_callbacks[C](F)}}return false};OrgInterface.set_org_cookie=function(B){var D=makeParamString({org_id:B});var A=org_support_set_cookie;OrgInterface.current_org_id=B;var C=new Ajax.Request(A,{method:"post",parameters:D,onSuccess:OrgInterface._handle_org_cookie_set,onFailure:OrgInterface._handle_org_cookie_set_failure})};OrgInterface._handle_org_cookie_set=function(){for(var A=0;A<OrgInterface.post_org_cookie_set_callbacks.length;A++){OrgInterface.post_org_cookie_set_callbacks[A]()}};OrgInterface._handle_org_cookie_set_failure=function(){};OrgInterface._set_have_org_data_section=function(C,A,B){OrgInterface.current_org_id=C;var D=document.getElementById("oi_existing_org_text");D.innerHTML=A;if(B){swap_content("oi_cookie_set",B)}else{showElement("oi_cookie_set")}};OrgInterface._reset_org_choice_section=function(){var A=document.getElementById("oi_org_select");A.options.length=0;hideElement("oi_more_org_info");showElement("oi_more_org_info_text")};OrgInterface._get_org_missing_org_reg_fields=function(){var D={oi_org_name:"Name of School or Organization",oi_org_type_reg:"Type of School/Organization",oi_org_addr1:"Street Address",oi_org_city_reg:"City",oi_org_postal_reg:"Zip/Postal Code",oi_org_phone_reg:"Phone",oi_org_country_reg:"Country"};var F={oi_org_type_reg:["NULL"],oi_org_country_reg:["NULL"]};var H=FormHelper.get_missing_fields(D,F);var B=H.missing_field_labels;var G=document.getElementById("oi_org_country_reg");var E=G.value;if(E=="US"||E=="CA"){var A=document.getElementById("oi_org_state_reg");var C=A.value;if(C=="NULL"||C=="UNDEF"){B.push("State or Province")}}return B};OrgInterface.register_org=function(){var I="oi_org_reg_form";OrgInterface._cleanup(I);var L=OrgInterface._get_org_missing_org_reg_fields();if(L.length>0){var H="Please fill in the following field(s): "+L.join(", ")+" and re-submit.";OrgInterface._show_error(I,H)}else{OrgInterface._showloader(I);var F=["oi_org_name","oi_org_type_reg","oi_org_addr1","oi_org_addr2","oi_org_city_reg","oi_org_state_reg","oi_org_postal_reg","oi_org_country_reg","oi_org_phone_reg","oi_org_public_private"];var G={};for(var C=0;C<F.length;C++){var K=F[C];var D=document.getElementById(K);var J=D.value;G[K]=J}OrgInterface._showloader(I);var E=G;var A=reg_new_org;var B=new Ajax.Request(A,{method:"post",parameters:E,onSuccess:OrgInterface._handle_org_reg,onFailure:OrgInterface._handle_org_reg_failure})}return false};OrgInterface._handle_org_reg=function(response){var form_id="oi_org_reg_form";OrgInterface._hideloader(form_id);var resp_obj=eval("("+response.responseText+")");if(resp_obj.error){OrgInterface._show_error(form_id,resp_obj.error);OrgInterface._handle_find_orgs_failure(response)}else{var org_id=resp_obj.org_id;var org_name=resp_obj.org_name;var form=document.getElementById(form_id);form.reset();for(var i=0;i<OrgInterface.post_org_reg_callbacks.length;i++){OrgInterface.post_org_reg_callbacks[i](org_id)}}};OrgInterface._handle_org_reg_failure=function(A){OrgInterface._show_error("oi_org_reg_form","There was a server or network error. Please try again.")};OrgInterface._setup=function(){var F=document.getElementById("oi_find_org_form");F.onsubmit=OrgInterface.find_orgs;var D=document.getElementById("oi_org_select_form");D.onsubmit=OrgInterface.select_org;var B=document.getElementById("oi_more_org_info_text");B.onclick=function(){swap_content("oi_more_org_info","oi_more_org_info_text");return false};var C=document.getElementById("oi_more_info_do_find_again");C.onclick=function(){swap_content("oi_find_org","oi_select_org");return false};var H=document.getElementById("oi_reg_org_link");H.onclick=function(){swap_content("register_org","oi_select_org");return false};var I=document.getElementById("oi_org_reg_form");I.onsubmit=OrgInterface.register_org;var G=document.getElementById("oi_reg_org_cancel");G.onclick=function(){swap_content("oi_select_org","register_org");return false};var A=get_org_id();if(A){OrgInterface.current_org_id=A}var E=document.getElementById("oi_org_type_reg");E.onchange=OrgInterface.show_hide_pub_priv};OrgInterface._show_current_org=function(){hideElement("register_org");hideElement("oi_select_org");hideElement("oi_find_org");var A=get_org_name();if(A){OrgInterface._set_have_org_data_section(get_org_id(),A)}else{showElement("oi_find_org")}};OrgInterface._handle_use_case=function(){if(OrgInterface.use_case=="standard"){OrgInterface._show_current_org()}else{if(OrgInterface.use_case=="change_org"){showElement("oi_find_org")}else{if(OrgInterface.use_case=="profile"){OrgInterface._show_current_org()}}}};OrgInterface.show_hide_pub_priv=function(){var A=$F("oi_org_type_reg");if(A.substring(0,3)=="k12"){showElement("oi_org_pub_priv_container")}else{hideElement("oi_org_pub_priv_container")}};OrgInterface.init=function(){OrgInterface._setup();OrgInterface._handle_use_case()};Event.observe(document,"dom:loaded",OrgInterface.init);