var txtSchoolsControlId,schoolCountryDropDownListId;var atxtSchoolsControlId,aschoolCountryDropDownListId;initSchoolAutoCompleteControl=function(B,A){txtSchoolsControlId=B;schoolCountryDropDownListId=A;$get("SelectedCountry").value=$get(schoolCountryDropDownListId).value};function initAutoCompleteSchoolFinder(J,I,F,C,D,L,A,G,E,B){var K=$create(MySpace.UI.AutoCompleteBehavior,{id:"accSearch",minimumPrefixLength:2,UseContextKey:true,contextKey:$get("SelectedCountry").value,completionListCssClass:"acNoScrollDiv",highlightedItemCssClass:"acSchoolNamehlightedItem",completionSetCount:10,completionListMaxHeight:10000,completionListWidth:240,completionInterval:500,completionListWrapperID:"mywrapper",completionListElementID:"mylist"},{itemSelected:function(N,M){var P=M.get_value();if(F.toString().toLowerCase()=="true"){window.location=P}else{if(P&&P.length){var O=P.toLowerCase().split("&");if(O[1].indexOf("schoolid",0)!=-1){$get(J).setAttribute("schoolid",O[1].split("=")[1])}}}}},null,$get(J));K.createCompletionItem=function(c){var P=document.createElement("div");var O=new Boolean(true);var V="";var b="";var a="";var R="";var M=0;if(c&&c.length){var Z=c.split("|");if(Z.length==1&&Z[0]=="NoResultFound"){P.innerHTML="<div class='acSchoolNoResult'>"+C+"</div>";O=true}else{var W=c.split("|");if(W.length=3){var Q=$get(J).value;var S=new RegExp(Q,"gi");var U="<span style='background-color:#C3D9FF;'>"+Q+"</span>";if(W[0]!=""){V=W[0]}var N=V;V=V.replace(S,U);if(W[1]!=""){M=W[1];R=String.format(D,M)}if(W[2]!=""){var Y=W[2].split(",");var b="";if(Y.henght==2){b=Y[0]}a=W[2]+", "+$get(I).value;b=b.replace(S,U);a=a.replace(S,U)}}P.innerHTML+="<a href="+R+"><span class='acSchoolName'>"+V+"</span><br><span class='acSchoolLocation'>"+a+"</span></a>"}}if(O){$get("cantFindSchool").display="block";var T=$get(I).value;if(L.indexOf(T)<0){if(T=="US"){$get("lnkCantFindSchool").href=A}else{$get("lnkCantFindSchool").href=G}}else{var X=E;if(X.indexOf("addSchool")>-1){X+="&countryCode="+T}$get("lnkCantFindSchool").href=X}}else{$get("cantFindSchool").display="none"}P._text=N;P._value=R;return P};K.getCompletionItems=function(M){var N=$get(I).value;if(N=="0"||N=="DD"){return}MySpace.Net.JsonpWebServiceProxy.invoke(B,{key:M,country:$get(I).value},H,null,null,M)};function H(M,N){K._update(N,M,false)}}function OnSelectedIndexChanged(A){if(A.options[A.selectedIndex].value=="DD"||A.options[A.selectedIndex].value=="0"){$get("divSchoolCountryDropDownListValidator").style.display="block";$get(txtSchoolsControlId).value="";return}else{$get("divSchoolCountryDropDownListValidator").style.display="none"}$get("divSchoolNameDropDownListValidator").style.display="none";$find("accSearch").set_contextKey(A.options[A.selectedIndex].value);$get(txtSchoolsControlId).value=""}function validatetxtSchools(){var A=$get(txtSchoolsControlId);var B=$get(schoolCountryDropDownListId).value;if(B=="DD"||B=="0"){$get("divSchoolCountryDropDownListValidator").style.display="block";return false}if((A)){if(A.value.trim()==""){$get("divSchoolNameDropDownListValidator").style.display="block";return false}else{$get("divSchoolNameDropDownListValidator").style.display="none";A.value=A.value.replace("'","%27")}}}function clearText(A){A.value="";A.focus();$get("divSchoolNameDropDownListValidator").style.display="none"}function ToTitleCase(E){if(E!=null){var A=E.split(" ");var D="";for(var B=0;B<A.length;B++){var C=A[B].substring(0,1);var F=A[B].substring(1);C=C.toUpperCase();D+=C+F+" "}return D.substring(0,D.length-1)}return E};