var ambitSearchController=function(){var H=null;
var O=null;
var P=null;
var E=null;
var G=null;
var K=null;
var A=null;
var J={};
var Q=false;
var B=true;
var N=null;
var F=function(){var T=Field.getValue(O);
var S=null;
if(R()){S=J[T]
}if(S==null){S=""
}P.value=S;
I(true)
};
var C=function(){var T=$F(O);
var S=P.value;
J[T]=S
};
var M=function(){var T=Field.getValue(P);
if(T==null||T==""){return false
}var U=$F(O);
var S=A[U];
if(S==null){return false
}if(typeof S=="string"){S=new RegExp(S);
A[U]=S
}return T.match(S)
};
var L=function(S,U){var T=U;
if(T){mobile.FormHelper.enableFieldAndLabel(E);
mobile.FormHelper.enableFieldAndLabel(G);
if(!B){E.down("option[value=100]").selected=true
}}else{if(!T){mobile.FormHelper.disableFieldAndLabel(E);
mobile.FormHelper.disableFieldAndLabel(G);
E.down('option[value=""]').selected=true;
if(!S){P.focus()
}}}B=T
};
var I=function(S){var T=M();
if(T){var U={ambitCountry:Field.getValue(O),zipcode:Field.getValue(P)};
new Ajax.Request(N,{method:"get",asynchronous:true,parameters:U,onSuccess:function(W){var X=W.responseText;
var V=false;
if(X!=null){V=(X=="true")
}L(S,V);
C()
}})
}else{L(S,false);
C()
}};
var D=function(S){var T=M();
if(T&&!B){mobile.FormHelper.enableFieldAndLabel(E);
mobile.FormHelper.enableFieldAndLabel(G);
E.down("option[value=100]").selected=true
}else{if(!T&&B){mobile.FormHelper.disableFieldAndLabel(E);
mobile.FormHelper.disableFieldAndLabel(G);
E.down('option[value=""]').selected=true;
if(!S){P.focus()
}}}B=T
};
var R=function(){var S=Field.getValue(O);
return S!=null&&A[S]!=null
};
return{init:function(Y,T,b,U,Z,S,a,X,V){H=Y;
O=$(T);
P=$(b);
E=$(U);
G=$(Z);
K=$(S);
A=a;
Q=O?(O.nodeName.toLowerCase()=="input"):true;
N=X;
if(V){if(Q){O.value=H
}else{if(!R()){for(var W=0;
W<O.options.length;
W++){if(O.options[W].value==H){O.options[W].selected=true;
break
}}}}}C();
if(A[Y]==null){Field.disable(P)
}I(true)
},onZipChange:function(){I(true)
},onZipFocusLost:function(){I(true)
},onCountryChange:function(){F()
},onCrossBorderChange:function(){if(G.checked){K.value=true
}else{K.value=false
}},onZipKeyUp:function(){var T=Field.getValue(P);
if(Q){if(O.value==""){if(T==null||T==""){O.value=""
}else{O.value=H
}}}else{if(!R()){for(var S=0;
S<O.options.length;
S++){if(O.options[S].value==H){O.options[S].selected=true;
break
}}return 
}}I(false)
}}
}();