function delay_this(action,time)
{if(typeof(window['mytimeout'])!="undefined"){clearTimeout(mytimeout);}
mytimeout=setTimeout(action,time);}
function new_image()
{ajax('/blocks/login/prism_login_script.php',"new_image","",function(){display_new_image();});}
function display_new_image()
{if(xmlHttp.readyState==4)
{document.getElementById("verify_hash").value=xmlHttp.responseText;var x=xmlHttp.responseText.split("|");document.getElementById("rand_picture").innerHTML='<input type="hidden" id="verify_hash" value="'+xmlHttp.responseText+'" /><img onclick="new_image();" src="'+WWW_ROOT+'/moodle/blocks/login/randomImage.php?rand='+x[1]+'">&nbsp;';}}
function forgot_submit()
{ajax('/blocks/login/prism_login_script.php',"reactivate_member","&email="+document.getElementById("email").value,function(){simple_display("forgot_div");});}
function signup_new_member(){get_site_content('home');ajax('/blocks/login/prism_login_script.php',"get_add_members_page","&args="+document.getElementById("verify_hash").value,function(){simple_display("prism_login_utility_window");});}
function reset_application(formname)
{var validator=$("#"+formname).validate();validator.resetForm();if(document.getElementById("states_list"))document.getElementById("states_list").innerHTML="";if(document.getElementById("aff_types_list"))document.getElementById("aff_types_list").innerHTML="";if(document.getElementById("counties_list"))document.getElementById("counties_list").innerHTML="";if(document.getElementById("corps_list"))document.getElementById("corps_list").innerHTML="";if(document.getElementById("ed_centers_list"))document.getElementById("ed_centers_list").innerHTML="";if(document.getElementById("colleges_list"))document.getElementById("colleges_list").innerHTML="";if(document.getElementById("school_list"))document.getElementById("school_list").innerHTML="";document.getElementById("first").focus();}
function submit_application(fullpage)
{document.getElementById("processing_image").innerHTML='<img src="'+WWW_ROOT+'/moodle/blocks/login/indicator.gif">';var first="&first="+document.getElementById("first").value;var last="&last="+document.getElementById("last").value;var username="&username="+document.getElementById("email").value;var pass="&password="+document.getElementById("pass1").value;var email="&email="+document.getElementById("email").value;var position="&position="+document.getElementById("position").value;var elem="&elem="+document.getElementById("elem").checked;var hs="&hs="+document.getElementById("hs").checked;var sixth="&sixth="+document.getElementById("sixth").checked;var seventh="&seventh="+document.getElementById("seventh").checked;var eighth="&eighth="+document.getElementById("eighth").checked;var math="&math="+document.getElementById("math").checked;var science="&science="+document.getElementById("science").checked;var technology="&technology="+document.getElementById("technology").checked;var lang="&lang="+document.getElementById("lang").checked;var social="&social="+document.getElementById("social").checked;var library="&library="+document.getElementById("library").checked;var country=(document.getElementById("country"))?"&country="+document.getElementById("country").value:"";var state=(document.getElementById("states"))?"&state="+document.getElementById("states").value:"";var aff_type=(document.getElementById("aff_types"))?"&aff_type="+document.getElementById("aff_types").value:"";var county=(document.getElementById("counties"))?"&county="+document.getElementById("counties").value:"";var ip=document.getElementById("ip").value;if(document.getElementById("states")&&document.getElementById("states").value=="IN"){if(document.getElementById("schools"))var affiliation="&affiliation="+document.getElementById("schools").value;else if(document.getElementById("corps"))var affiliation="&affiliation="+document.getElementById("corps").value;else if(document.getElementById("ed_centers"))var affiliation="&affiliation="+document.getElementById("ed_centers").value;else if(document.getElementById("colleges"))var affiliation="&affiliation="+document.getElementById("colleges").value;else var affiliation="&affiliation=";}
else var affiliation="&affiliation=";if(document.getElementById("aff_types")&&document.getElementById("aff_types").value==5){affiliation="&affiliation=DOE";}
if(document.getElementById("aff_types")&&document.getElementById("aff_types").value==6){affiliation="&affiliation=Home School";}
if(fullpage)ajax('/blocks/login/prism_login_script.php',"application_submit","&fullpage=true&ip="+ip+first+last+username+pass+email+position+elem+hs+sixth+seventh+eighth+math+science+technology+lang+social+library+country+state+aff_type+county+affiliation,function(){popup_results(true);});else ajax('/blocks/login/prism_login_script.php',"application_submit","&ip="+ip+first+last+username+pass+email+position+elem+hs+sixth+seventh+eighth+math+science+technology+lang+social+library+country+state+aff_type+county+affiliation,function(){popup_results();});}
function popup_results(fullpage)
{var results=xmlHttp.responseText.split("|");var success=results[0];if(fullpage)
{document.getElementById("new_user_div").innerHTML=results[2];}
else
{document.getElementById("TB_ajaxWindowTitle").innerHTML=results[1];document.getElementById("new_user_div").innerHTML=results[2];if(success=="true"){delay_this('auto_login_user()','10000');}}}
function auto_login_user()
{var username=document.getElementById("hiddenuser").value;var password=document.getElementById("hiddenpassword").value;document.getElementById("login_username").value=username;document.getElementById("login_password").value=password;document.getElementById("login").submit();}
function clear_lists_after(lastlist)
{if(lastlist=="schools")return;if(lastlist=="colleges")return;if(lastlist=="ed_centers")return;if(document.getElementById("ed_centers_list"))document.getElementById("ed_centers_list").innerHTML="";if(document.getElementById("corps_list"))document.getElementById("corps_list").innerHTML="";if(document.getElementById("schools_list"))document.getElementById("schools_list").innerHTML="";if(document.getElementById("colleges_list"))document.getElementById("colleges_list").innerHTML="";if(lastlist=="counties")return;if(document.getElementById("counties_list"))document.getElementById("counties_list").innerHTML="";if(lastlist=="aff_types")return;if(document.getElementById("aff_types_list"))document.getElementById("aff_types_list").innerHTML="";if(lastlist=="states")return;if(document.getElementById("states_list"))document.getElementById("states_list").innerHTML="";}
function get_next_list(lastlist){var nextlist="";if(document.getElementById(lastlist)&&document.getElementById(lastlist).value==""){clear_lists_after(lastlist);return;}
if(lastlist=="aff_types"&&(document.getElementById("aff_types").value==1||document.getElementById("aff_types").value==2||document.getElementById("aff_types").value==4)&&document.getElementById("counties")&&document.getElementById("counties").value!="")lastlist="counties";if(lastlist=="country"&&document.getElementById("country").value=="US")nextlist="states";else if(lastlist=="states")nextlist="aff_types";else if(lastlist=="aff_types"&&document.getElementById("states").value=="IN"&&(document.getElementById("aff_types").value!="3"&&document.getElementById("aff_types").value!="5"))nextlist="counties";else if(lastlist=="aff_types"&&document.getElementById("states").value=="IN"&&document.getElementById("aff_types").value=="3")nextlist="ed_centers";else if(lastlist=="counties"&&document.getElementById("states").value=="IN"&&document.getElementById("aff_types").value=="1")nextlist="schools";else if(lastlist=="counties"&&document.getElementById("states").value=="IN"&&document.getElementById("aff_types").value=="2")nextlist="corps";else if(lastlist=="counties"&&document.getElementById("states").value=="IN"&&document.getElementById("aff_types").value=="4")nextlist="colleges";var state=(document.getElementById("states"))?state="&state="+document.getElementById("states").value:state="";var aff_type=(document.getElementById("aff_types"))?aff_type="&aff_type="+document.getElementById("aff_types").value:aff_type="";var county=(document.getElementById("counties"))?county="&county="+document.getElementById("counties").value:county="";if(lastlist=="schools"||lastlist=="corps"||lastlist=="colleges"||lastlist=="ed_centers")return;clear_lists_after(lastlist);if(nextlist!="")
{ajax('/blocks/login/prism_login_script.php',"get_list","&list="+nextlist+state+aff_type+county,function(){simple_display(nextlist+"_list");});}}