var ForumSmileyImg=["regular_smile.gif","sad_smile.gif","wink_smile.gif","teeth_smile.gif","confused_smile.gif","tounge_smile.gif","embaressed_smile.gif","cry_smile.gif","angel_smile.gif","devil_smile.gif","cry_smile.gif","kiss.gif"],ForumSmiley=[":)",":(",";)",":D",":/",":P",":s",";(","0:-)","]:)",";(",":kiss"];function Forum(a,f,i,h,g,c,b,e,d){this._BoxId=f;this._LnId=i;this._SecId=h;this._InfId=g;this._ReplyParentId=0;this._ReplySubject="";this._element=a;this._FormBox=null;this._Shadow=null;this._idSubject=a+"_sbj";this._idText=a+"_txt";this._btnOkSrc=c==""?"/Images/ok.gif":c;this._btnCancelSrc=b==""?"/Images/Annulla.gif":b;this._LoginText=e;this._AddNewText=d;this._WindowResize=Function.createDelegate(this,this._OnWindowResize);this._KeyPres=null;typeof InsertTxt!="function"&&document.write('<script type="text/javascript" src="/objects/Utilities.js"><\/script>')}Forum.prototype={Reply:function(b,a){this._ReplyParentId=b;this._ReplySubject=a;if(Auth.get_isLoggedIn())this._RenderAddForm();else this._RenderLoginForm()},AddNew:function(){this._ReplyParentId=0;if(Auth.get_isLoggedIn())this._RenderAddForm();else this._RenderLoginForm()},_RenderAddForm:function(){this._CreatePopUp("msgform");if(this._AddNewText!="")this._FormBox.innerHTML="<div>"+this._AddNewText+"</div>";var c="<span class='tag'>"+RES_FRM_SUBJECT+"</span><br/><input type='text' id='"+this._idSubject+"' /><img id='pp_frm_bar_toggle_btn' style='display: none; cursor: hand;' src='/images/plus.gif'/><br/><div id='pp_frm_bar' style='display: none;'></div>";c+="<span class='tag'>"+RES_FRM_MESSAGE+"</span><br/><div id='pp_frm_preview' style='display: none;'></div><textarea rows='20' id='"+this._idText+"' ></textarea><br/><br/>";if(this._AddNewText!="")c="<div>"+this._AddNewText+"</div>"+c;this._FormBox.innerHTML=c;$addHandler(document.getElementById("pp_frm_bar_toggle_btn"),"click",Function.createDelegate(this,this._RenderEmoticonBar));if(this._ReplyParentId!=0){var d=$get(this._idSubject);d.disabled=true;d.value="Re: "+this._ReplySubject}var b=document.createElement("img");b.style.cursor="hand";b.setAttribute("src",this._btnOkSrc);$addHandler(b,"click",Function.createDelegate(this,this._OnOkClick));this._FormBox.appendChild(b);this._FormBox.appendChild(document.createTextNode("  "));var a=document.createElement("img");a.style.cursor="hand";a.setAttribute("src",this._btnCancelSrc);this._FormBox.appendChild(a);$addHandler(a,"click",Function.createDelegate(this,this._RemovePopUp));this._OnWindowResize()},_RenderEmoticonBar:function(){var a=document.getElementById("pp_frm_bar");if(a.style.display=="none"){if(a.innerHTML==""){var c="";for(i=0;i<ForumSmileyImg.length;i++)c+="<img src='/images/emt/"+ForumSmileyImg[i]+"' style='cursor: hand; margin: 1px;' onclick=\"InsertTxt('"+this._idText+"','','','"+ForumSmiley[i]+"',true);\"  title='"+ForumSmiley[i]+"'/> ";c+="<img onclick=\"javascript:InsertTxt('"+this._idText+"','[yt]','','[/yt]',true);\" style='cursor: hand; margin: 1px;' title='Youtube' src='/images/yt.gif' />";c+="<img onclick=\"javascript:InsertTxt('"+this._idText+"','[gv]','','[/gv]',true);\" style='cursor: hand; margin: 1px;' title='Goolgle Video' src='/images/gv.gif' />";a.innerHTML=c;var b=document.createElement("img");b.title="Preview";b.style.cursor="hand";b.style.margin="1";b.setAttribute("src","/images/preview2.gif");$addHandler(b,"click",Function.createDelegate(this,this._PreviewText));a.appendChild(b)}a.style.display="block";document.getElementById("pp_frm_bar_toggle_btn").src="/images/minus.gif"}else{a.style.display="none";document.getElementById("pp_frm_bar_toggle_btn").src="/images/plus.gif"}},_PreviewText:function(){var b=$get(this._idText),a=$get("pp_frm_preview");if(b.style.display!="none"){a.style.width=b.offsetWidth+"px";a.style.height=b.offsetHeight+"px";a.style.overflow="auto";a.style.border="1px solid gray";a.innerHTML=this._ParseText(b.value);b.style.display="none";a.style.display="block"}else{b.style.display="block";a.style.display="none"}},_ParseText:function(a){a=a.replace(/<([A-Z][A-Z0-9]*)[^>]*>.*?<\/\1>/gi,"");a=a.replace(/<([A-Z][A-Z0-9]*)[^>]*>/gi,"");for(i=0;i<ForumSmileyImg.length;i++)a=a.replace(ForumSmiley[i],"<img src='/images/emt/"+ForumSmileyImg[i]+"' />");a=a.replace(/\[yt\]([A-Z0-9]*)\[\/yt\]/gi,'<object width="400" height="295"><param name="movie" value="http://www.youtube.com/v/$1&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$1&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="295"></embed></object>');a=a.replace(/\[gv\](.*)\[\/gv\]/gi,"<embed id=VideoPlayback src=http://video.google.it/googleplayer.swf?docid=$1&hl=it&fs=true style=width:400px;height:326px allowFullScreen=true allowScriptAccess=always type=application/x-shockwave-flash> </embed>");return a},_CreatePopUp:function(b){this._FormBox=document.createElement("div");this._FormBox.id=b;this._FormBox.style.position="absolute";this._FormBox.style.display="block";this._FormBox.style.zIndex=1e4;var a=document.getElementsByTagName("body");a[0].appendChild(this._FormBox);this._Shadow=document.createElement("div");this._Shadow.style.position="absolute";this._Shadow.style.left="0px";this._Shadow.style.top="0px";this._Shadow.style.zIndex=10;this._Shadow.style.display="block";this._Shadow.style.width="100%";this._Shadow.style.height=this._getWindowHeight()+"px";a[0].appendChild(this._Shadow);this._Shadow.id="modalbackground";$addHandler(window,"resize",this._WindowResize);$addHandler(window,"scroll",this._WindowResize)},_RemovePopUp:function(){var a=document.getElementsByTagName("body");a[0].removeChild(this._FormBox);a[0].removeChild(this._Shadow);$removeHandler(window,"resize",this._WindowResize);$removeHandler(window,"scroll",this._WindowResize)},_OnOkClick:function(){var a=$get(this._idSubject).value,b=$get(this._idText).value;Sys.Net.WebServiceProxy.invoke("/WsWebControls.asmx","Forum_AddNew",false,{ParentId:this._ReplyParentId,BoxId:this._BoxId,LnId:this._LnId,SecId:this._SecId,InfId:this._InfId,Subject:a,Text:b},Function.createDelegate(this,this._OnAddComplete),Function.createDelegate(this,this._OnAddError))},_OnAddComplete:function(){this._RemovePopUp();var a=window.location;if(window.__doPostBack!=null)window.__doPostBack("","");else window.location=a},_OnAddError:function(){alert("Errore")},_RenderLoginForm:function(){this._CreatePopUp("loginform");var d="<span class='tag'>Login/E-mail:</span><br/><input type='text' id='login_"+this._BoxId+"' /><br/>";d+="<span class='tag'>Password:</span><br/><input type='password' id='password_"+this._BoxId+"' /><br/><br/>";if(this._LoginText!="")d="<div>"+this._LoginText+"</div>"+d;this._FormBox.innerHTML=d;var c=document.createElement("a");c.href="#";c.onclick=Function.createDelegate(this,this._RenderForgotPassword);c.innerHTML=RES_FRM_FORGOTPWD;this._FormBox.appendChild(c);this._FormBox.appendChild(document.createElement("br"));this._FormBox.appendChild(document.createElement("br"));var b=document.createElement("img");b.style.cursor="hand";b.setAttribute("src",this._btnOkSrc);$addHandler(b,"click",Function.createDelegate(this,this._OnLogin));this._FormBox.appendChild(b);this._FormBox.appendChild(document.createTextNode("  "));var a=document.createElement("img");a.setAttribute("src",this._btnCancelSrc);a.style.cursor="hand";this._FormBox.appendChild(a);$addHandler(a,"click",Function.createDelegate(this,this._RemovePopUp));$addHandler(this._FormBox,"keypress",Function.createDelegate(this,this._OnLoginKeyPres));this._OnWindowResize()},_RenderForgotPassword:function(){this._RemovePopUp();this._CreatePopUp("loginform");var c=RES_FRM_INSERTLOGINPWD+".<br/><br/><span class='tag'>Login:</span><br/><input type='text' id='login_"+this._BoxId+"' /><br/>";c+="<span class='tag'>Email:</span><br/><input type='text' id='email_"+this._BoxId+"' /><br/><br/>";this._FormBox.innerHTML=c;var b=document.createElement("img");b.style.cursor="hand";b.setAttribute("src",this._btnOkSrc);$addHandler(b,"click",Function.createDelegate(this,this._OnForgotOkClick));this._FormBox.appendChild(b);this._FormBox.appendChild(document.createTextNode("  "));var a=document.createElement("img");a.setAttribute("src",this._btnCancelSrc);a.style.cursor="hand";this._FormBox.appendChild(a);$addHandler(a,"click",Function.createDelegate(this,this._RemovePopUp));$addHandler(this._FormBox,"keypress",Function.createDelegate(this,this._OnForgotKeyPres));this._OnWindowResize()},_OnLoginKeyPres:function(a){if(a.charCode==13){this._OnLogin();return false}else return true},_OnForgotKeyPres:function(a){if(a.charCode==13){this._OnForgotOkClick();return false}else return true},_OnLogin:function(){var b=$get("login_"+this._BoxId).value,a=$get("password_"+this._BoxId).value;Auth.Login(b,a,Function.createDelegate(this,this._OnLoginCompleted),Function.createDelegate(this,this._OnLoginFailed))},_OnLoginCompleted:function(a){if(a){this._RemovePopUp();this._RenderAddForm()}else alert(RES_FRM_LOGINFAILED)},_OnLoginFailed:function(a){alert(a.get_message())},_OnForgotOkClick:function(){var b=$get("login_"+this._BoxId).value,a=$get("email_"+this._BoxId).value;if(b==""&&a=="")alert(RES_FRM_MISSING);else Auth.ForgotPassword(b,a,Function.createDelegate(this,this._OnForgotCompleted),Function.createDelegate(this,this._OnLoginFailed))},_OnForgotCompleted:function(a){if(a){alert(RES_FRM_MAILSENT);this._RemovePopUp();this._RenderLoginForm()}else alert(RES_FRM_WRONGUSER)},_OnWindowResize:function(){var c=this._FormBox.offsetWidth?this._FormBox.offsetWidth:this._FormBox.scrollWidth,b=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft,a=document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop;this._FormBox.style.left=(this._getWindowWidth()-c)/2+b+"px";this._FormBox.style.top=(this._getWindowHeight()-this._FormBox.offsetHeight)/2+a+"px";this._Shadow.style.top=a+"px";this._Shadow.style.height=this._getWindowHeight()+"px"},_getWindowHeight:function(){return window.self&&self.innerHeight?self.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:0},_getWindowWidth:function(){return window.innerWidth?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body&&document.body.clientWidth?document.body.clientWidth:0}}