
dojo.declare("VsAjaxManagerImpl",null,{_isAjaxActive:false,constructor:function(){if(!djConfig.ioPublish)console.warn("djConfig.ioPublish options must be TRUE to avoid problem with the actionToDoAfterLogging!");var auxThis=this;dojo.subscribe("/dojo/io/start",function(){auxThis._isAjaxActive=true;});dojo.subscribe("/dojo/io/stop",function(){auxThis._isAjaxActive=false;});},isAjaxActive:function(){return this._isAjaxActive;},addOnAjaxFinish:function(action){if(this._isAjaxActive){var handle=dojo.subscribe("/dojo/io/stop",function(){dojo.unsubscribe(handle);action();});}
else{action();}}});var VsAjaxManager=new VsAjaxManagerImpl();var VsUtil={popup:undefined,byId:function(domOrId){if(typeof domOrId=='string'){return dojo.byId(domOrId);}
return domOrId;},connectAndStop:function(domOrId,method,func){var elem=this.byId(domOrId);if(!elem||!method||!func){console.warn(ekLang._("Waring, aborting connectAndStop() called with id="+domOrId+"; method="+method+"; func="+func));return;}
if(typeof func!='function'){console.warn(ekLang._("Waring, aborting connectAndStop() func parameter must be a function!!"));return;}
dojo.connect(elem,method,function(e){dojo.stopEvent(e);return func(e);});},onClick:function(domOrId,func,hover){var elem=this.byId(domOrId);if(!elem||!func){console.warn(ekLang._("Waring, aborting onClick() called with id="+domOrId+"; func="+func));return;}
if(hover){dojo.connect(elem,"onmouseover",function(e){elem.style.pointer="wait";});dojo.connect(elem,"onmouseout",function(e){elem.style.pointer="";});}
dojo.connect(elem,"onclick",function(e){dojo.stopEvent(e);eval(func);});},onMouseDown:function(domOrId,startFunc,stopFunc){var elem=this.byId(domOrId);if(!elem||!startFunc||!stopFunc){console.warn(ekLang._("Waring, aborting onMouseDown() called with id="+domOrId+"; startFunc="+startFunc+"; stopFunc="+stopFunc));return;}
dojo.connect(elem,"onmousedown",function(e){if(((!dojo.isIE||dojo.isIE>=9)&&e.button==0)||(dojo.isIE&&e.button&1)){dojo.stopEvent(e);eval(startFunc);}});dojo.connect(elem,"onmouseup",function(e){if(((!dojo.isIE||dojo.isIE>=9)&&e.button==0)||(dojo.isIE&&e.button&1)){dojo.stopEvent(e);eval(stopFunc);}});dojo.connect(elem,"onmouseover",function(e){dojo.stopEvent(e);elem.style.cursor='pointer';eval(stopFunc);});dojo.connect(elem,"onmouseout",function(e){dojo.stopEvent(e);elem.style.cursor='';eval(stopFunc);});},onOverButton:function(domOrId){var elem=this.byId(domOrId);if(elem){var y=elem.offsetHeight
dojo.connect(elem,'onmouseover',function(){y=this.offsetHeight;this.style.cursor='pointer';this.style.backgroundPosition='0px '+(-y)+'px';});dojo.connect(elem,'onmouseout',function(){this.style.cursor='';this.style.backgroundPosition='0px 0px';});dojo.connect(elem,'onmousedown',function(e){if((!dojo.isIE&&e.button==0)||(dojo.isIE&&e.button&1)){y=this.offsetHeight;this.style.backgroundPosition='1px '+(1-y)+'px';this.blur();};});dojo.connect(elem,'onmouseup',function(e){if((!dojo.isIE&&e.button==0)||(dojo.isIE&&e.button&1)){y=this.offsetHeight;this.style.backgroundPosition='0px '+(-y)+'px';this.blur();};});}},showBusyPointer:function(elements){for(var i=0;i<elements.length;i++){if(elements[i]){elements[i].style.cursor='wait';}}},resetPointer:function(elements){for(var i=0;i<elements.length;i++){if(elements[i]){elements[i].style.cursor='pointer';}}},setInputTextDefaultMessage:function(fieldName,onFocusText,formJson){var input=dojo.byId(fieldName);var isPassword=input.getAttribute('type')=='password';if(isPassword&&dojo.isIE){return;}
dojo.connect(input,'onfocus',function(){if(onFocusText==input.value){input.value="";dojo.removeClass(input,'widgetHelpMessage');}
if(isPassword){input.setAttribute('type','password');}});dojo.connect(input,'onblur',function(){if(input.value==''){if(isPassword){input.setAttribute('type','text');}
input.value=onFocusText;dojo.addClass(input,'widgetHelpMessage');}});if(input.value==''||input.value==onFocusText){if(isPassword){input.setAttribute('type','text');}
input.value=onFocusText;dojo.addClass(input,'widgetHelpMessage');}
if(formJson){dojo.connect(formJson,'onPreValidate',function(){if(input.value==onFocusText){input.value='';dojo.removeClass(input,'widgetHelpMessage');}});dojo.connect(formJson,'onError',function(){if(input.value==''){if(isPassword){input.setAttribute('type','text');}
input.value=onFocusText;dojo.addClass(input,'widgetHelpMessage');}});}else{dojo.connect(input.form,'onsubmit',function(){if(input.value==onFocusText){input.value='';dojo.removeClass(input,'widgetHelpMessage');}});}},safeCall:function(f){if(typeof(f)=='function')
return f();return undefined;},reverseString:function(s){return s.split("").reverse().join("");},windowOpenReverse:function(reversedUrl){window.open(VsUtil.reverseString(reversedUrl));},windowLocationReverse:function(reversedUrl){window.location=VsUtil.reverseString(reversedUrl);},popupOpen:function(url,w,h,t,l){t=t?t:(screen.height-h)/2;l=l?l:(screen.width-w)/2;if(this.popup){this.popup.close();}
return this.popup=window.open(url,null,'top='+t+',left='+l+',height='+h+',width='+w+',status=no, directories=no, toolbar=no, location=no, menubar=no,scrollbars=no, resizable=no');},popupOpenReverse:function(reversedUrl,w,h,t,l){t=t?t:(screen.height-h)/2;l=l?l:(screen.width-w)/2;if(this.popup){this.popup.close();}
this.popup=window.open(VsUtil.reverseString(reversedUrl),null,'top='+t+',left='+l+',height='+h+',width='+w+',status=no, directories=no, toolbar=no, location=no, menubar=no,scrollbars=no, resizable=no');},emailRegex:new RegExp(/^[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/),telephoneRegex:new RegExp(/^\+?[\d ]+[/\-]?[\d]+$/m),checkEmailForm:function(form){try{var sError="Attenzione\n";var oNome=form.nome;if(!oNome){return false;}
var oEmail=form.email;if(!oEmail){return false;}
var oTelefono=form.telefono;if(!oTelefono){return false;}
var oPrivacy=form.privacy;if(!oPrivacy){return false;}
if(oNome.value==""||oNome.value==VsLang._("Nome")){sError+="\n - Il campo NOME deve essere obbligatoriamente compilato\n";}
if((oEmail.value==""||oEmail.value==VsLang._("Email"))&&(oTelefono.value==""||oTelefono.value==VsLang._("Telefono"))){sError+="\n - Almeno uno tra i campi email / telefono deve essere obbligatoriamente compilato\n";}
if(oTelefono.value!=""&&oTelefono.value!=VsLang._("Telefono")&&!this.telephoneRegex.test(oTelefono.value)){sError+="\n - Inserire un telefono valido o lasciare il campo vuoto.\n";}
if(oEmail.value!=""&&oEmail.value!=VsLang._("Email")&&!this.emailRegex.test(oEmail.value)){sError+="\n - Inserire un email in formato valido\n";}
if(oPrivacy.checked!=true){sError+="\n - Deve essere acconsentito il trattamento dei dati personali\n";}
if(sError!="Attenzione\n"){alert(sError);return false;}
if(oEmail.value==VsLang._("Email")){oEmail.value="";}
if(oTelefono.value==VsLang._("Telefono")){oTelefono.value="";}
return true;}catch(e){return false;}},checkErrorReportingForm:function(form){try{var sError="Attenzione\n";var oNome=form.nome;var oEmail=form.email;var oDescription=form.richieste;var oPrivacy=form.privacy;if(oEmail.value==""){sError+="\n - Il campo EMAIL deve essere obbligatoriamente compilato\n";}
if(oEmail.value!=""&&!this.emailRegex.test(oEmail.value)){sError+="\n - Inserire un email in formato valido\n";}
if(oDescription.value==""){sError+="\n - Il campo 'Descrivi l'errore' deve essere obbligatoriamente compilato\n";}
if(oPrivacy.checked!=true){sError+="\n - Deve essere acconsentito il trattamento dei dati personali\n";}
if(sError!="Attenzione\n"){alert(sError);return false;}
return true;}catch(e){return false;}},changeInputTextColor:function(oObj,sText,bOnFocus,sColor){if(!oObj){return(false);}
if(oObj.value==''||oObj.value==sText){if(bOnFocus){oObj.value="";}else{oObj.value=sText;}}else{sColor=oObj.style.color;}
oObj.style.color=sColor;return(true);},showHide:function(domOrId,triggerer,showText,hideText,useInline){var node=this.byId(domOrId);if(!node){return console.log("VsUtil.showHide: element "+domOrId+" not found!");}
if(node.style.display=='none'){if(useInline){node.style.display='inline';}else{node.style.display='block';}
triggerer.innerHTML=hideText;}else{node.style.display='none'
triggerer.innerHTML=showText;}
return false;},showHideTypologyInline:function(domOrId,domOrId2){var node=this.byId(domOrId);var node2=this.byId(domOrId2);if((!node)&&(!node2)){return console.log("VsUtil.showHide: element "+domOrId+" not found!");}
if(node.style.display=='none'){node.style.display='inline';node2.style.display='none';}else{node.style.display='none';node2.style.display='inline';}
return false;},getRadioValue:function(form,name){var radioObj=form[name];if(!radioObj)
return"";var radioLength=radioObj.length;if(radioLength==undefined){if(radioObj.checked){return radioObj.value;}else{return"";}}
for(var i=0;i<radioLength;i++){if(radioObj[i].checked){return radioObj[i].value;}}
return"";},reloadCaptcha:function(captchaImgId){if(dojo.byId(captchaImgId)){dojo.byId(captchaImgId).src='/vimages/default/captcha/'+parseInt(10000*Math.random())+'.png';}
if(dojo.byId('captcha')){dojo.byId('captcha').value='';}},uniqueId:0,getUniqueId:function(){return this.uniqueId++;}};dojo.declare("VsScrollerImpl",null,{date:null,startTime:null,steps:null,scrollTimeOut:0,started:false,constructor:function()
{var auxThis=this;dojo.connect(document,'onmousewheel',function(){auxThis.stop();});},scrollTo:function(id,duration,elementIdToFocus)
{if(elementIdToFocus==undefined)elementIdToFocus=null;var obj=dojo.byId(id);var objtop=0;var objleft=0;while(obj.offsetParent){objleft+=obj.offsetLeft;objtop+=obj.offsetTop;obj=obj.offsetParent;}
this.steps=duration/20;var dims=this.getPageSize();if(dims[1]-objtop<dims[3])
objtop=dims[1]-dims[3];if(dims[0]-objleft<dims[2])
objleft=dims[0]-dims[2];var scr=this.getScrollXY();this.date=new Date();this.startTime=this.date.getTime();this.started=true;this.myScrollBy(scr[0],scr[1],objleft,objtop,0,elementIdToFocus);},stop:function(){this.started=false;},getPageSize:function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){windowWidth=self.innerWidth;windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}
return[pageWidth,pageHeight,windowWidth,windowHeight];},getScrollXY:function(){var scrOfX=0,scrOfY=0;if(typeof(window.pageYOffset)=='number'){scrOfY=window.pageYOffset;scrOfX=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){scrOfY=document.body.scrollTop;scrOfX=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){scrOfY=document.documentElement.scrollTop;scrOfX=document.documentElement.scrollLeft;}
return[scrOfX,scrOfY];},myScrollBy:function(sx,sy,ex,ey,idToActivate){var scroll,nx,ny;var auxThis=this;scroll=this.getScrollXY();nx=scroll[0];ny=scroll[1];sx+=30.7*(ex-nx)/(this.steps*Math.log(Math.abs(ex-nx+1)));sy+=30.7*(ey-ny)/(this.steps*Math.log(Math.abs(ey-ny+1)));if(sx-nx!=0||sy-ny!=0){window.scrollBy(sx-nx,sy-ny);}
if(this.scrollTimeOut){clearTimeout(this.scrollTimeOut);}
var date2=new Date();if(this.started&&((date2.getTime()-this.startTime)<(this.steps*40)&&(Math.abs(sx-ex)>1||Math.abs(sy-ey)>1))){this.scrollTimeOut=setTimeout(function(){auxThis.myScrollBy(sx,sy,ex,ey,idToActivate)},20);}else{this.started=false;if(idToActivate!=null){dojo.byId(idToActivate).focus&&dojo.byId(idToActivate).focus();}}}});var VsScroller=new VsScrollerImpl();dojo.declare("VsAjaxManagerImpl",null,{_isAjaxActive:false,constructor:function(){if(!djConfig.ioPublish)console.warn("djConfig.ioPublish options must be TRUE to avoid problem with the actionToDoAfterLogging!");var auxThis=this;dojo.subscribe("/dojo/io/start",function(){auxThis._isAjaxActive=true;});dojo.subscribe("/dojo/io/stop",function(){auxThis._isAjaxActive=false;});},isAjaxActive:function(){return this._isAjaxActive;},addOnAjaxFinish:function(action){if(this._isAjaxActive){var handle=dojo.subscribe("/dojo/io/stop",function(){dojo.unsubscribe(handle);action();});}
else{action();}}});var VsAjaxManager=new VsAjaxManagerImpl();dojo.addOnLoad(function(){dojo.addClass(dojo.body(),"tundra")
dojo.require("dojo.rpc.JsonService");dojo.require("dojo._base.xhr");dojo.require("dijit.Tooltip");dojo.require("dojo._base.json");});function VsFormJson(formId,executeOnSubmit,formName){this.formName=formName?formName:formId;this.errors=new Array();this.formId=formId;this.formElement=dojo.byId(formId);if(this.formElement==undefined){console.warn("VSFormJson.js: Missing form element, id: "+formId);return;}
if(executeOnSubmit!=undefined&&typeof(executeOnSubmit)!='function'){console.warn("VSFormJson: Warning - executeOnSubmit is NOT a function!");}else{this.executeOnSubmit=executeOnSubmit;}
this.foundErrors=null;this.scrollMark=false;this.scrollMarkDuration=500;var auxThis=this;for(var child=0;child<this.formElement.elements.length;child++){var elem=this.formElement[child];var type;if(elem&&elem.getAttribute('type')){type=elem.getAttribute('type');}
if(type!='submit'){dojo.connect(elem,'onchange',function(){var id=this.id||this.name;auxThis.clearError(id);},elem);dojo.connect(elem,'onkeydown',function(){var id=this.id||this.name;auxThis.clearError(id);},elem);}else{VsUtil.onOverButton(elem);}}
dojo.connect(this.formElement,'onsubmit',function(e){dojo.stopEvent(e);e.preventDefault();auxThis.validate();});this.validateRpcDef={"serviceType":"JSON-RPC","serviceURL":"/json/validate.php","methods":[{"name":"validate","parameters":[{"name":"formId"},{"name":"formValue"}]}]};this.errors["isEmpty"]=ekLang._('Required field');this.errors["emailAddressInvalidHostname"]=this.errors["emailAddressInvalid"]=this.errors["emailAddressDotAtom"]=this.errors["emailAddressQuotedString"]=this.errors["emailAddressInvalidLocalPart"]=this.errors["emailAddressInvalidFormat"]=ekLang._('A valid email address is required');this.errors["wrongEmailOrPassword"]=ekLang._('Wrong email or password');this.errors["insertCurrentPassword"]=ekLang._('Please insert current password too');this.errors["privacyUnchecked"]=ekLang._('You have to agree to our privacy policy in order to continue');this.errors["userAlreadyExist"]=ekLang._('This email adress is already in use');this.errors["notMatch"]=ekLang._('The fields must match');this.errors["stringLengthTooShort"]=ekLang._('The inserted value is too short');this.errors["stringLengthTooShort_firstName"]=ekLang._('Min Length 2 chars');this.errors["stringLengthTooShort_lastName"]=ekLang._('Min Length 2 chars');this.errors["notActiveUser"]=ekLang._('The user is not active');this.errors["userNotExist"]=ekLang._('The user not exists');this.errors["wrongCategoryType"]=ekLang._('You have to select a type');this.errors["notGreaterThan"]=ekLang._('You have to choose a valid value');this.errors["notGreaterThan_locality"]=ekLang._('You have to choose a valid value locality');this.errors["regexNotMatch"]=ekLang._('You have to insert a valid value');this.errors["stringLengthTooLong"]=ekLang._('The string is too long');this.errors["notDigits"]=ekLang._('Only Digits allowed');this.errors["notFloat"]=ekLang._('Only Currency allowed');this.errors["notGreaterThan_price"]=ekLang._('Minimum Price: 10 Euro');this.errors["minimumPriceNotGiven"]=ekLang._('Minimum Price: 10 Euro');this.errors["minimumPrice2NotGiven"]=ekLang._('Minimum Price: 1000 Euro');this.errors["notInArrayKeys"]=ekLang._('You have to choose a value');this.errors["notInArrayKeys_category"]=ekLang._('You have to choose a valid value category');this.errors["notInArrayKeys_contract"]=ekLang._('You have to choose a valid value contract');this.errors["notInArray_type"]=ekLang._('You have to choose a valid value type');this.errors["isEmpty_area"]=ekLang._('Required field area');this.errors["isEmpty_price"]=ekLang._('Required field price');this.errors["isEmpty_cap"]=ekLang._('Required field cap');this.errors["wrongCategoryType_type"]=ekLang._('You have to choose a valid value type');this.errors["notChooseCategoryType"]=ekLang._('You have to choose a valid value type');this.errors["nonMatching"]=ekLang._('These fields must match');this.errors["newPasswordTooShort"]=ekLang._('Min Length: 6 chars');this.errors["wrongCurrentPassword"]=ekLang._('Current password is wrong');this.errors["notInArray"]=ekLang._('You have to choose a value');this.errors["allEmpty"]=ekLang._('Required field');this.errors["wrongFieldValue"]=ekLang._('Wrong Field value');this.errors['uriInvalid']=ekLang._('uriInvalid');this.clearError=function(id){var obj=dojo.byId(this.formId+"_"+id);if(!obj)
obj=dojo.byId(id);if(obj){dojo.removeClass(obj,"errorField");}
obj=dojo.byId("Error_"+this.formId+"_"+id);if(!obj)
obj=dojo.byId("Error_"+id);if(obj){obj.innerHTML="&#160;";obj.style.visibility="hidden";}};this.markError=function(fieldName){var errorMessage=this.res[fieldName][0];var obj=dojo.byId(this.formId+"_"+fieldName);if(!obj)
obj=dojo.byId(fieldName);if(obj){dojo.addClass(obj,"errorField");}
obj=dojo.byId('Error_'+this.formId+"_"+fieldName);if(!obj){obj=dojo.byId('Error_'+fieldName);}
if(obj){if(this.errors[errorMessage]==undefined){this.errors[errorMessage]=VsLang._(errorMessage);}
obj.innerHTML=this.errors[errorMessage];obj.style.visibility="visible";}};this.validateGenericForm=function(){var bool=true;for(var fieldName in this.res){if(this.res[fieldName][0]!=undefined)
{this.markError(fieldName);this.foundErrors.push(fieldName);bool=false;}else{this.clearError(fieldName,false);}}
return bool;};this.validate=function(){this.onPreValidate();var rpcDef=this.validateRpcDef;if(dojo.byId("Locality")&&(dojo.byId("Locality").value.trim()=="")){dojo.byId("idLocality").value="-1";}
this.foundErrors=new Array();var jsonRPC=new dojo.rpc.JsonService(rpcDef);jsonRPC.timeout=20000;var deferred=jsonRPC.validate(this.formName,dojo.formToJson(dojo.byId(this.formId)));deferred.addCallback(this,this.validateCallback);};this.validateCallback=function(res){this.onResponse();this.res=res;if(this.validateGenericForm()){this.onValid();if(typeof(this.executeOnSubmit)=='function'){this.executeOnSubmit(res);}else{if(dojo.byId(this.formId).action==''){console.warn("Submitting a form with an empty action!");}
dojo.byId(this.formId).submit();}}
else{this.onError();if(this.scrollMark){var sObjToGo=this.foundErrors.shift();if(dojo.byId('Error_'+this.formId+"_"+sObjToGo)==null){VsScroller.scrollTo("Error_"+sObjToGo,this.scrollMarkDuration,sObjToGo);}
else{VsScroller.scrollTo('Error_'+this.formId+"_"+sObjToGo,this.scrollMarkDuration,sObjToGo);}}}};this.onPreValidate=function(){}
this.onValid=function(){}
this.onResponse=function(){}
this.onError=function(){}}
function goBackFromBox(id){if(parent.VsUserDialog){parent.VsUserDialog.doAction(id);}else if(VsUserDialog){VsUserDialog.doAction(id);}}
dojo.require('dijit.Dialog');dojo.require('dijit.form.Button');var clickObject={};var VsUserDialog={dialogData:new Object(),actionToDoAfterLogging:null,reload:null,currentDialog:null,currentId:null,initedDialog:new Object(),closable:true,iFrame:null,init:function(id,container,_closable,_draggable,reload,action){if(_draggable==undefined)
_draggable=true;if(reload==undefined)
reload=true;if(this.currentDialog&&this.destroyable){this.currentDialog.destroy();}
if(container==undefined){var elem=dojo.byId('dialogContainer');if(!elem){console.error('VsUserDialog: missing dialog container.');return;}
var containerDiv=document.createElement('div');var contentDiv=document.createElement('iframe');this.iFrame=contentDiv;containerDiv.setAttribute('id','userDialog');contentDiv.setAttribute('id','userDialog_content');contentDiv.setAttribute('scrolling','no');if(dojo.isIE){contentDiv.setAttribute('frameBorder','no');}else{contentDiv.setAttribute('frameborder','no');}
containerDiv.appendChild(contentDiv);elem.appendChild(containerDiv);this.destroyable=true;this.initedDialog[id]=this.currentDialog=new dijit.Dialog({draggable:_draggable,closable:_closable,onKeyPress:this.onKeyPress,onCancel:this.onCancel,layoutAlign:'none'},'userDialog');}else
{var containerDiv=dojo.byId(container);var contentDiv=containerDiv.firstChild;while(contentDiv&&contentDiv.nodeName.toLowerCase()=='#text'){contentDiv=contentDiv.nextSibling;}
if(!contentDiv){this.destroyable=true;contentDiv=document.createElement('div');contentDiv.setAttribute('id',id);containerDiv.appendChild(contentDiv);if(!this.initedDialog[id]){this.initedDialog[id]=new dijit.Dialog({draggable:_draggable,closable:_closable,onKeyPress:this.onKeyPress,onCancel:this.onCancel,layoutAlign:'none'},'userDialog');}}else{this.destroyable=false;if(!this.initedDialog[id]){this.initedDialog[id]=new dijit.Dialog({draggable:_draggable,closable:_closable,onKeyPress:this.onKeyPress,onCancel:this.onCancel,layoutAlign:'none'},containerDiv);}}}
this.initedDialog[id].startup();this.currentId=id;this.currentDialog=this.initedDialog[id];this.closable=_closable;this.reload=reload;if(action){this.actionToDoAfterLogging=dojo.connect(this.currentDialog,'doAction("'+id+'")',action);}else{this.actionToDoAfterLogging=function(){this.doAction(id)}}},resizeIt:function(oIframe){try{var oDoc=oIframe.contentWindow||oIframe.contentDocument;if(oDoc){if(oDoc.document){oDoc=oDoc.document;}
var totalContent=dojo.coords(oIframe.parentNode.parentNode);var w;var h;var innerContent=oDoc.getElementById("userDialogContent");if(innerContent){w=parseInt(innerContent.offsetWidth);h=parseInt(innerContent.offsetHeight);}else{w=parseInt(oIframe.offsetWidth);h=parseInt(oIframe.offsetHeight);}
var auxThis=this;this.setPosition(totalContent.w,totalContent.h);if(this.animateOnShow){innerContent.style.visibility='hidden';dojo.animateProperty({node:oIframe,duration:1000,easing:function(n){auxThis.currentDialog._size();auxThis.currentDialog._position();return dojo.fx.easing.quintInOut(n);},onEnd:function(){auxThis.currentDialog.attr('title',auxThis.title);auxThis.currentDialog._size();auxThis.currentDialog._position();innerContent.style.visibility='visible';},properties:{width:{end:w},height:{end:h}}}).play();}else{oIframe.style.width=w+'px';oIframe.style.height=h+'px';auxThis.currentDialog._size();auxThis.currentDialog._position();}}}catch(error){}},setPosition:function(w,h){if(this.relativeNode){var viewPort=dijit.getViewport();relNodeCoords=dojo.coords(this.relativeNode);relNodeCoords.x+=relNodeCoords.w;if(relNodeCoords.x+w+5>viewPort.w){relNodeCoords.x=viewPort.w-w-5;}
if(relNodeCoords.x<5){relNodeCoords.x=5;}
if(relNodeCoords.y+h+5>viewPort.h){relNodeCoords.y=viewPort.h-h-5;}
if(relNodeCoords.y<5){relNodeCoords.y=5;}
this.currentDialog._relativePosition={x:relNodeCoords.x,y:relNodeCoords.y};this.currentDialog._position();}},show:function(id,config){var w,h,page,title,container,reload,closable,draggable,left;this.currentId=id;if(typeof this.dialogData[id].preCreate=='function'){this.dialogData[id].preCreate(this);}
if(config){this.relativeNode=config.relativeNode,w=config.width;h=config.height;page=config.page;reload=config.reload;closable=config.closable;draggable=config.draggable;container=config.container;title=config.title;this.animateOnShow=config.animateOnShow;}
if(id in this.dialogData){if(!this.relativeNode)this.relativeNode=this.dialogData[id].relativeNode;if(!w)w=this.dialogData[id].width;if(!h)h=this.dialogData[id].height;if(!title)title=this.dialogData[id].title;if(!page)page=this.dialogData[id].page;if(!reload)reload=this.dialogData[id].reload;if(!this.animateOnShow)this.animateOnShow=this.dialogData[id].animateOnShow;}
if(closable==undefined)
closable=true;if(draggable==undefined)
draggable=false;if(reload==undefined)
reload=false;if(w==undefined||h==undefined||(page==undefined&&container==undefined)||title==undefined){console.warn("Error in dialog creation!\nw:"+w+" h:"+h+"\npage:"+page+"\ntitle:"+title+"\nContainer:"+container);return;}
this.init(id,container,closable,draggable,reload);this.setPosition(w,h);if(dojo.byId('bannerHP')!=null){dojo.byId('bannerHP').style.visibility='hidden';}
if(dojo.byId('banner')!=null){dojo.byId('banner').style.visibility='hidden';}
if(dojo.byId('bannerLeaderboard')!=null){dojo.byId('bannerLeaderboard').style.visibility='hidden';}
if(h==0&&container){h=parseInt(dojo.byId(container).innerHeight);}
if(w==0&&container){w=parseInt(dojo.byId(container).offsetWidth);}
this.title=title;if(this.animateOnShow){this.currentDialog.attr("title",'Caricamento...');}else{this.currentDialog.attr("title",title);}
if(container==undefined){if(dojo.isIE&&dojo.byId('userDialog')){dojo.byId('userDialog').style.width=w+'px';}
var obj=dojo.byId('userDialog_content');if(obj){if(w==0||w==undefined){sw="0px";}else{sw=w+'px';}
if(h==0||h==undefined){sh="0px";}else{sh=h+'px';}
var auxThis=this;if(obj.addEventListener){obj.addEventListener('load',function(){auxThis.resizeIt(obj);},false);}else if(obj.attachEvent){obj.attachEvent('onload',function(){auxThis.resizeIt(obj);});}
obj.style.width=sw;obj.style.height=sh;obj.src='';obj.src=page;}}else{if(typeof w=='number')this.currentDialog.style.width=w+'px';if(typeof h=='number')this.currentDialog.style.height=h+'px';}
dojo.connect(this.currentDialog,'onclose',VsUserDialog.close);dojo.connect(this.currentDialog,'onkeypress',this.onKeyPress);this.currentDialog.show();if(closable){var ud=this;if(dojo.byId('dijit_DialogUnderlay_0')){dojo.byId('dijit_DialogUnderlay_0').onclick=function(evt){ud.close(true);};}else if(dojo.byId('userDialog_underlay')){dojo.byId('userDialog_underlay').onclick=function(evt){ud.close(true);};}}
if(dojo.byId('userDialog')){var elem=dojo.byId('userDialog').firstChild;while(elem.nodeName.toLowerCase()!='div'){elem=elem.nextSibling;}
elem=elem.firstChild;do{if(elem.nodeName.toLowerCase()=='span'&&elem.getAttribute('class')=='dijitDialogCloseIcon'){elem.style.display=closable?'block':'none';}}while(elem=elem.nextSibling);}},showAndDoAction:function(id,config,actionFunc){var actionHandler=dojo.connect(this,"doAction",function(){actionFunc();});var cancelHandler=null;cancelHandler=dojo.connect(this,"onCancel",function(){dojo.disconnect(actionHandler);dojo.disconnect(cancelHandler);});cancelHandler=dojo.connect(this,"close",function(canceled){if(!canceled){dojo.disconnect(actionHandler);dojo.disconnect(cancelHandler);}});return this.show(id,config);},close:function(canceled){if(dojo.byId('bannerHP')!=null){dojo.byId('bannerHP').style.visibility='visible';}
if(dojo.byId('bannerLeaderboard')!=null){dojo.byId('bannerLeaderboard').style.visibility='visible';}
if(dojo.byId('banner')!=null){dojo.byId('banner').style.visibility='visible';}
if(this.currentDialog){if(parent.VsUserDialog!=undefined)console.warn("Closing the dialog will stop the execution of the current script!");if(this.destroyable){this.currentDialog.destroy();this.initedDialog[this.dialogId]=null;this.currentDialog=null;}else{this.currentDialog.hide();dojo.byId('dijit_DialogUnderlay_0').style.display='none';}}
else{console.warn("UserDialog.js: Trying to close an active dialog but there is none!");}
if(!canceled&&this.reload){window.location.reload();}},onCancel:function(e){dojo.stopEvent(e);e.preventDefault();if(VsUserDialog){VsUserDialog.close(true);}else{parent.VsUserDialog.close(true);}},onKeyPress:function(e){var keycode;if(window.event)keycode=window.event.keyCode;else if(e.keyCode){keycode=e.keyCode;}
else if(e)keycode=e.which;if(keycode==13){return void(0);}
if(keycode==27&&this.closable){dojo.stopEvent(e);e.preventDefault();if(VsUserDialog){VsUserDialog.close(true);}else{parent.VsUserDialog.close(true);}}},showImage:function(id,title,UrlImage){var i;var img=dojo.byId('dialogImageContent');var cont=dojo.byId('dialogImage');if(!img){img=new Image();img.id='dialogImageContent';cont.appendChild(img);}
img.alt=title;img.src=UrlImage;dojo.connect(img,'onload',this,function(){this.show(id,{container:'dialogImage',title:title});});},doAction:function(id){var sParentLocation=parent.location.href;if(sParentLocation.charAt(sParentLocation.length-1)=='#'){sParentLocation=sParentLocation.substring(0,sParentLocation.length-1);}
if(this.currentDialog&&this.reload){parent.location.href=sParentLocation;parent.location.reload();}else{this.currentDialog.hide();}},initLoginAndDoAction:function(actionTriggerId,action,logged){if(typeof actionTriggerId=='string'){trigger=dojo.byId(actionTriggerId);}
else{trigger=actionTriggerId;}
if(trigger){clickObject.connectionHandle=dojo.connect(trigger,'onclick',function(evt){dojo.stopEvent(evt);if(logged){action();}else{if(VsUserDialog.actionToDoAfterLogging){dojo.disconnect(VsUserDialog.actionToDoAfterLogging);}
var safeReloadAfterAjax=function(){action();if(VsUserDialog.currentDialog&&VsUserDialog.reload){VsUserDialog.reload=false;var sParentLocation=parent.location.href;if(sParentLocation.charAt(sParentLocation.length-1)=='#'){sParentLocation=sParentLocation.substring(0,sParentLocation.length-1);}
VsAjaxManager.addOnAjaxFinish(function(){parent.location.href=sParentLocation;parent.location.reload();});}};VsUserDialog.actionToDoAfterLogging=dojo.connect(VsUserDialog,"doAction",safeReloadAfterAjax);VsUserDialog.show('Login');}});if(dojo.byId('registrazioneLogin')){dojo.connect(dojo.byId('registrazioneLogin'),'onclick',function(evt){dojo.stopEvent(evt);if(logged){action();}else{if(VsUserDialog.actionToDoAfterLogging){dojo.disconnect(VsUserDialog.actionToDoAfterLogging);}
VsUserDialog.actionToDoAfterLogging=dojo.connect(VsUserDialog,"doAction",action);parent.VsUserDialog.currentDialog.hide();VsUserDialog.show('Registration');}});}}},initUnloggedPrivatePage:function(){this.actionOnHideBox=dojo.connect(this.currentDialog,"hide",function(){window.location='/'});this.show('Login');}}
dojo.addOnLoad(function(){dojo.addClass(dojo.body(),"tundra");});dojo.require("dojo.cookie");dojo.require("dojo.fx");dojo.declare("VsFacebook",null,{perms:'email',cookieDomain:null,onInitLoggedIn:function(){},_loginAlert:function(){dojo.addOnLoad(function(){var alertBox=dojo.create('div',{innerHTML:'<p style="font-size:14px; margin:10px; margin-top: 20px;">Login tramite Facebook Connect</p>'
+'<p><img style="cursor:pointer" src="http://static.ak.fbcdn.net/images/fbconnect/login-buttons/connect_white_large_short.gif" /></p>',style:{zIndex:101,color:"#292929",textAlign:"center",fontFamily:"Arial,Helvetica,Tahoma,Verdana,sans-serif",width:"480px",border:"4px solid #3b5998",backgroundColor:"#d3effc",opacity:0,overflow:"hidden",position:"absolute",borderRadius:"10px",MozBorderRadius:"10px",WebkitBorderRadius:"10px",WebkitBoxShadow:"0px 3px 7px #adadad"}},dojo.body());alertBox.style.left=parseInt((dijit.getViewport().w-alertBox.offsetWidth)/2)+"px";alertBox.style.top=parseInt((dijit.getViewport().h-alertBox.offsetHeight)/2)+"px";dojo.fx.chain([dojo.fadeIn({node:alertBox,duration:200}),dojo.fadeOut({node:alertBox,duration:200,delay:1000})]).play();});},_ensurePermissionsConfirm:function(){return confirm("Attenzione, per poter utilizzare al meglio il sito dovresti consentire l'invio di mail.\n\nDesideri riprovare?");},constructor:function(fbApiKey,cookieDomain,alreadyLoggedIn){this.cookieDomain=cookieDomain;FB.init({appId:fbApiKey,status:false,cookie:true,xfbml:false});if(!alreadyLoggedIn){var auxThis=this;FB.getLoginStatus(function(response){if(response.session&&dojo.cookie('remote_auto_login_anti_loop')!='1'&&dojo.cookie('disable_remote_auto_login')!='1'){dojo.cookie('remote_auto_login_anti_loop','1',{domain:auxThis.cookieDomain,path:'/'});auxThis._login(auxThis.onInitLoggedIn,true);}});}
else{dojo.cookie('remote_auto_login_anti_loop',null,{domain:this.cookieDomain,path:'/',expires:-1});}},login:function(afterLogin){dojo.cookie('disable_remote_auto_login',null,{domain:this.cookieDomain,path:'/',expires:-1});dojo.cookie('remote_auto_login_anti_loop',null,{domain:this.cookieDomain,path:'/',expires:-1});if(FB.getSession()!=null){this._login(afterLogin);}
else{var auxThis=this;FB.login(function(response){if(response.session){if(response.perms){auxThis._login(afterLogin);}else{auxThis._ensurePermissions(afterLogin);}}else{if(response.perms){auxThis._loginError(afterLogin);}
else{auxThis._ensurePermissions(afterLogin);}}},{perms:this.perms});}},_login:function(optionalAfterLogin,bWithAlert){if(optionalAfterLogin==null)optionalAfterLogin=function(){};if(bWithAlert==null)bWithAlert=false;if(bWithAlert)this._loginAlert();optionalAfterLogin();},_ensurePermissions:function(afterLogin){var bRetry=this._ensurePermissionsConfirm();if(bRetry){this.login(afterLogin);}},_loginError:function(){alert("Errore");},logout:function(optionalAfterLogout){if(optionalAfterLogout==null)optionalAfterLogout=function(){};dojo.cookie('disable_remote_auto_login','1',{domain:this.cookieDomain,path:'/'});optionalAfterLogout();}});dojo.declare("EurekasaFacebook",VsFacebook,{onInitLoggedIn:function(){if(parent.VsUserDialog!=null&&parent.VsUserDialog.currentDialog!=null){parent.VsUserDialog.close();}
else{window.location.reload();}}});VsUserDialog.dialogData['Login']={width:586,height:258,page:'/utenti/login.html',reload:true,title:ekLang._("Accesso utenti registrati")};VsUserDialog.dialogData['Registration']={width:398,height:440,page:'/utenti/registrazione.html',reload:true,title:ekLang._("Registrazione utenti")};VsUserDialog.dialogData['CompleteRegistration']={width:630,height:210,reload:true,title:ekLang._("Completa la tua Registrazione")};VsUserDialog.dialogData['PasswordRecovery']={width:630,height:151,page:'/utenti/recuperaPassword.html',title:ekLang._("Recupero password")};VsUserDialog.dialogData['Profile']={width:480,height:560,page:'/utenti/modificaDati.html',title:ekLang._("Modifica i tuoi dati")};VsUserDialog.dialogData['agencyContact']={width:370,height:242,title:ekLang._("Contatta l'agenzia")};VsUserDialog.dialogData['privateContact']={width:628,height:242,title:ekLang._("Contatta")};VsUserDialog.dialogData['lotImage']={width:339,height:410};VsUserDialog.dialogData['Map']={width:605,height:408,title:ekLang._('Mappa')};VsUserDialog.dialogData['Project']={width:615,height:440,title:ekLang._('Mappa')};VsUserDialog.dialogData['ErrorReport']={container:'errorReport',width:100,height:100,title:ekLang._('Segnala Errori')};VsUserDialog.dialogData['newsletterNonLogged']={width:620,height:130,title:ekLang._('Conferma Attivazione Ricerca via email')};VsUserDialog.dialogData['selectZone']={width:0,height:0,title:ekLang._('Scegli una o più zone')};VsUserDialog.dialogData['sendToFriend']={width:400,height:338,reload:true,title:ekLang._('Invia questo annuncio ad un amico')};VsUserDialog.dialogData['mutui']={width:430,height:450,title:ekLang._('Trova il mutuo immobiliare più conveniente'),page:"http://www.immobiliare.it/xajax/popupMutui_it.html"};VsUserDialog.dialogData['traslochi']={width:620,height:520,title:ekLang._('Confronta preventivi traslochi. Risparmia fino al 30%!'),page:"http://www.traslochi-online.it/iframe/9-eurekasa"};VsUserDialog.dialogData['traslochiCommerciali']={width:640,height:680,title:ekLang._('Confronta preventivi traslochi. Risparmia fino al 30%!'),page:"http://www.traslochi-online.it/iframe/11-eurekasa-ufficio"};VsUserDialog.dialogData['mq']={width:460,height:450,title:ekLang._('Come vengono calcolati i metri quadrati?')};VsUserDialog.dialogData['saveSearchTop']={width:550,height:200,title:ekLang._('Ricevi gli annunci via mail')};if(dojo.isIE){VsUserDialog.dialogData['mq'].height=445;VsUserDialog.dialogData['Map'].height=414;VsUserDialog.dialogData['traslochi'].width=640;VsUserDialog.dialogData['traslochi'].height=480;VsUserDialog.dialogData['traslochiCommerciali'].height=650;if(dojo.isIE==7){VsUserDialog.dialogData['traslochi'].height=520;VsUserDialog.dialogData['traslochiCommerciali'].width=640;VsUserDialog.dialogData['traslochiCommerciali'].height=640;}}
