var ModalDialogWindow;var ModalDialogInterval;var ModalDialog=new Object;var ModalDialogVal=new Object;var ModalDialogDes=new Object;var destino=window.location.href;ModalDialog.value="";ModalDialog.eventhandler="";function jumpingBox(a){try{window.location.href=a}catch(b){window.location=a}}function ModalDialogMaintainFocus(){try{if(ModalDialogWindow.closed){window.clearInterval(ModalDialogInterval);eval(ModalDialog.eventhandler);return}ModalDialogWindow.focus()}catch(everything){}}function ModalDialogRemoveWatch(){ModalDialog.value="";ModalDialog.eventhandler=""}function ModalDialogShow(d,g,a,c,f,e){ModalDialogRemoveWatch();ModalDialog.eventhandler=c;var b="width=350,height=130,left=325,top=300,toolbar=0,";b+="location=0,status=0,menubar=0,scrollbars=1,resizable=0";ModalDialogWindow=window.open("","",b);ModalDialogWindow.opener=window;ModalDialogWindow.document.open();ModalDialogWindow.document.write("<html>");ModalDialogWindow.document.write("<head>");ModalDialogWindow.document.write("<title>"+d+"</title>");ModalDialogWindow.document.write("<script language=JavaScript>");ModalDialogWindow.document.write("function CloseForm(Response) ");ModalDialogWindow.document.write("{ ");ModalDialogWindow.document.write(" window.opener.ModalDialog.value = Response; ");ModalDialogWindow.document.write(" window.opener.OkCancelInputReturnMethod(window.opener.location); ");ModalDialogWindow.document.write(" window.close(); ");ModalDialogWindow.document.write("} ");ModalDialogWindow.document.write("<\/script>");ModalDialogWindow.document.write("</head>");ModalDialogWindow.document.write('<body onblur="window.focus();">');ModalDialogWindow.document.write('<table border=0 width="95%" align=center cellspacing=0 cellpadding=2>');ModalDialogWindow.document.write("<tr><td align=left>"+g+"</td></tr>");ModalDialogWindow.document.write("<tr><td align=left><br></td></tr>");ModalDialogWindow.document.write("<tr><td align=center>"+a+"</td></tr>");if(f!=null){ModalDialogWindow.document.write('<tr><td align=center><input type="text" name="nome" id="nome" value="insira o nome aqui"  /></td></tr>')}ModalDialogWindow.document.write("</table>");ModalDialogWindow.document.write("</body>");ModalDialogWindow.document.write("</html>");ModalDialogWindow.focus()}function OkCancelInput(d,b,c){var a="";a='<a href=javascript:CloseForm(document.getElementById("nome").value);>Ok</a>  ';a+='<a href=javascript:CloseForm("Cancel");>Cancel</a>  ';ModalDialogShow("Dialog",d,a,b,true,c)}function breakTheJar(c,a,b){try{document.cookie="quicklinkcookie="+c+b+"; path=/";document.cookie="quicklinkdescription="+a+b+"; path=/";return true}catch(d){return false}}function validateemail(){var a=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;str=document.getElementById("form_target_mail").value;if(str.match(a)){return true}else{alert("Escreva um endereço de email, válido.");return false}}function testInputAuthId(){forms=document.forms;valToReturn=true;for(var b=0;b<forms.length;b++){myForm=forms[b];for(var a=0;a<myForm.length;a++){myElement=myForm.elements[a];if(myElement.id.match("record_name")){if(myElement.value.length==0){alert("Seleccione a permissão a atribuir.");valToReturn=false}}if(myElement.id.match("_authorizable_id")){if(myElement.value.length==0){alert("Seleccione o respectivo Consultor / Agência.");valToReturn=false}}}}return valToReturn}function aftersucesso(b){document.getElementById("form_target_mail").value="";document.getElementById("form_message").value="";document.getElementById("form_target_name").value="";document.getElementById("form_source_name").value="";alert("Email Enviado.");var a="email_form"+b;document.getElementById(a).style.display="none"}function checkvalidations(a,b){var validation = [];validation[0] = checkpass(a);validation[1] = checkrole(b);validation[2]=(jQuery("#record_name").val().empty())?0:1;return (validation[0] + validation[1] + validation[2] == 3)}function checkpass(a){regex=/^(?=^.{8,}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]))^.*$/;if(!regex.test(document.getElementById("record[password]").value)){alert(a);}return regex.test(document.getElementById("record[password]").value)}function checkrole(b){var aridval = jQuery("[name$='[authorizable_id]']");var arnomval = jQuery("[id$='authorizable_id_']");var valtoret = 1;jQuery.each(aridval,function(index,value){if(value.value.empty()){valtoret=0;alert(b);}});return valtoret;}function CanPass(b){var a,c;if(b=="propertyd"){a=document.getElementById("distrito_select");c=document.getElementById("asset_search_reference_0");if(a.value.toString().match("Distritos")&&c.value.toString().replace(/^\s+|\s+$/,"").length==0){alert("Tem de escolher pelo menos um Distrito ou inserir uma referência , para poder pesquisar.");return false}}return true};