var selectedLetter=Element;function prepareLocationList(){list=$$("#locationsLettersList ul li.active a");list.each(function(s){Event.observe(s,"click",function(Event){var element=Event.element();if(element.innerHTML=="A-Z"){$$("li.locationItem").each(function(s){s.show()})}else{letter=element.innerHTML.substr(0,1).toUpperCase();$$("li.locationItem").each(function(s){s.hide()});$$("li.letter_"+letter).each(function(s){s.show()
})}if(selectedLetter!=element){selectedLetter.removeClassName("selectedLetterHP4")}selectedLetter=element;selectedLetter.addClassName("selectedLetterHP4")})});$("locationsList").show()}if($("i_nume")){Event.observe("i_nume","click",function(Event){var element=Event.element();if($("hpVersion")&&$F("hpVersion")==3){clickClear(element,"Nume")}else{clickClear(element,"Numele tau")}});Event.observe("i_nume","blur",function(Event){var element=Event.element();
if($("hpVersion")&&$F("hpVersion")==3){clickRecall(element,"Nume")}else{clickRecall(element,"Numele tau")}});Event.observe("i_nume","blur",function(Event){var element=Event.element();clickRecall(element,"Numele tau")})}if($("i_prenume")){Event.observe("i_prenume","click",function(Event){var element=Event.element();if($("hpVersion")&&$F("hpVersion")==3){clickClear(element,"Prenume")}else{clickClear(element,"Prenumele tau")
}});Event.observe("i_prenume","blur",function(Event){var element=Event.element();if($("hpVersion")&&$F("hpVersion")==3){clickRecall(element,"Prenume")}else{clickRecall(element,"Prenumele tau")}})}function clickClear(field,defaultText){if(field.value==defaultText){field.value=""}}function clickRecall(field,defaultText){if(field.value==""){field.value=defaultText}}function hideLocations(exceptFirstLetter){if($("locationsLettersList")){$$("li.locationItem").each(function(s){s.hide()
});if(exceptFirstLetter){var firstValidLetter=selectedLetter.innerHTML.substr(0,1).toUpperCase();$$("li.letter_"+firstValidLetter).each(function(s){s.show()})}}}function sendInvite(ev){var adId=ev.element().getAttribute("tabindex");var searcher=$("data_searcher_"+adId).getValue();var searchee=$("data_searchee_"+adId).getValue();$("searcher_name").innerHTML=searcher;$("security_code").value="Codul din imaginea de mai sus";
$("inviteAdId").setValue(adId);var el=$("mailOverlayerContent");el.show();Dialog.Confirm.show(el,{modal:true,closable:true,title:"Stii adresa de e-mail a lui "+searchee+"?",width:420,height:240,onSuccess:function(){},onFailure:function(){},onClose:function(){$("inviteEmail").value="";$("worning").hide();el.hide()}})}function sendMail(ev){new Ajax.Request("/user/register/send-invite-mail.ajax",{method:"post",parameters:{email:$("inviteEmail").value,adId:$("inviteAdId").value,security_code:$("security_code").value},asynchronous:false,onSuccess:function(transport){$("mail_error").hide();
$("captcha_error").hide();var response=transport.responseText.evalJSON();if(response.error){if(response.error=="email"){$("mail_error").show()}if(response.error=="captcha"){$("captcha_error").show()}}}});ev.stop()}function refreshCaptcha(e){var captcha=$("captchaImg");var captchaSrc=captcha.src;if(captchaSrc.indexOf("?")!=-1){captchaSrc=captchaSrc.replace(/\?cid=.+/,"")}captchaSrc+="?cid="+(new Date()).getTime();
captcha.src=captchaSrc}function clearOriginalText(){if($("security_code").value=="Codul din imaginea de mai sus"){$("security_code").value=""}}if($("search")){Event.observe("search","click",function(Event){var element=Event.element();if($("i_prenume").value=="Prenumele tau"&&$("i_nume").value=="Numele tau"){alert("Completati cel putin unul dintre cele doua campuri !");Event.stop()}})}document.observe("dom:loaded",function(){if($("contentAds")){$("contentAds").delegate("click",{".sendInvite":sendInvite});
$("changeCaptcha").observe("click",refreshCaptcha);$("security_code").observe("click",clearOriginalText)}if($("sendEmailButton")){$("sendEmailButton").observe("click",sendMail)}if($$("li.active")){selectedLetter=$$("li.active").last().down("a");if($$("li.locationItem").length>50){var exceptFirstLetter=true;hideLocations(exceptFirstLetter);selectedLetter=$("locationsLettersList").down("li.active a")
}selectedLetter.addClassName("selectedLetterHP4");prepareLocationList()}});
