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,b,c,f,g,d,e,h,j){this._BoxId=b;this._LnId=c;this._SecId=f;this._InfId=g;this._ReplyParentId=0;this._ReplySubject="";this._element=a;this._Shadow=this._FormBox=null;this._idSubject=a+"_sbj";this._idText=a+"_txt";this._btnOkSrc=d==""?"/Images/ok.gif":d;this._btnCancelSrc=e==""?"/Images/Annulla.gif":e;this._LoginText=h;this._AddNewText=j;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(a,b){this._ReplyParentId=a;this._ReplySubject=b;Auth.get_isLoggedIn()?this._RenderAddForm():this._RenderLoginForm()},AddNew:function(){this._ReplyParentId=0;Auth.get_isLoggedIn()?this._RenderAddForm():this._RenderLoginForm()},_RenderAddForm:function(){this._CreatePopUp("msgform");if(this._AddNewText!="")this._FormBox.innerHTML="<div>"+this._AddNewText+"</div>";var a="<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>";
a+="<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!="")a="<div>"+this._AddNewText+"</div>"+a;this._FormBox.innerHTML=a;$addHandler(document.getElementById("pp_frm_bar_toggle_btn"),"click",Function.createDelegate(this,this._RenderEmoticonBar));if(this._ReplyParentId!=0){a=$get(this._idSubject);a.disabled=true;a.value="Re: "+this._ReplySubject}a=document.createElement("img");
a.style.cursor="hand";a.setAttribute("src",this._btnOkSrc);$addHandler(a,"click",Function.createDelegate(this,this._OnOkClick));this._FormBox.appendChild(a);this._FormBox.appendChild(document.createTextNode("  "));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 b="";for(i=0;i<ForumSmileyImg.length;i++)b+="<img src='/images/emt/"+ForumSmileyImg[i]+"' style='cursor: hand; margin: 1px;' onclick=\"InsertTxt('"+this._idText+"','','','"+ForumSmiley[i]+"',true);\"  title='"+ForumSmiley[i]+"'/> ";b+="<img onclick=\"javascript:InsertTxt('"+this._idText+"','[yt]','','[/yt]',true);\" style='cursor: hand; margin: 1px;' title='Youtube' src='/images/yt.gif' />";b+="<img onclick=\"javascript:InsertTxt('"+this._idText+
"','[gv]','','[/gv]',true);\" style='cursor: hand; margin: 1px;' title='Goolgle Video' src='/images/gv.gif' />";a.innerHTML=b;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 a=$get(this._idText),b=$get("pp_frm_preview");if(a.style.display!="none"){b.style.width=a.offsetWidth+"px";b.style.height=a.offsetHeight+"px";b.style.overflow="auto";b.style.border="1px solid gray";b.innerHTML=this._ParseText(a.value);a.style.display="none";b.style.display="block"}else{a.style.display="block";b.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>');
return 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>")},_CreatePopUp:function(a){this._FormBox=document.createElement("div");this._FormBox.id=a;this._FormBox.style.position="absolute";this._FormBox.style.display="block";this._FormBox.style.zIndex=1E4;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 a="<span class='tag'>Login/E-mail:</span><br/><input type='text' id='login_"+this._BoxId+"' /><br/>";a+="<span class='tag'>Password:</span><br/><input type='password' id='password_"+this._BoxId+"' /><br/><br/>";if(this._LoginText!=
"")a="<div>"+this._LoginText+"</div>"+a;this._FormBox.innerHTML=a;a=document.createElement("a");a.href="#";a.onclick=Function.createDelegate(this,this._RenderForgotPassword);a.innerHTML=RES_FRM_FORGOTPWD;this._FormBox.appendChild(a);this._FormBox.appendChild(document.createElement("br"));this._FormBox.appendChild(document.createElement("br"));a=document.createElement("img");a.style.cursor="hand";a.setAttribute("src",this._btnOkSrc);$addHandler(a,"click",Function.createDelegate(this,this._OnLogin));
this._FormBox.appendChild(a);this._FormBox.appendChild(document.createTextNode("  "));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 a=RES_FRM_INSERTLOGINPWD+
".<br/><br/><span class='tag'>Login:</span><br/><input type='text' id='login_"+this._BoxId+"' /><br/>";a+="<span class='tag'>Email:</span><br/><input type='text' id='email_"+this._BoxId+"' /><br/><br/>";this._FormBox.innerHTML=a;a=document.createElement("img");a.style.cursor="hand";a.setAttribute("src",this._btnOkSrc);$addHandler(a,"click",Function.createDelegate(this,this._OnForgotOkClick));this._FormBox.appendChild(a);this._FormBox.appendChild(document.createTextNode("  "));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 a=$get("login_"+
this._BoxId).value,b=$get("password_"+this._BoxId).value;Auth.Login(a,b,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 a=$get("login_"+this._BoxId).value,b=$get("email_"+this._BoxId).value;a==""&&b==""?alert(RES_FRM_MISSING):Auth.ForgotPassword(a,b,
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 a=this._FormBox.offsetWidth?this._FormBox.offsetWidth:this._FormBox.scrollWidth,b=document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft,c=document.documentElement.scrollTop?document.documentElement.scrollTop:
document.body.scrollTop;this._FormBox.style.left=(this._getWindowWidth()-a)/2+b+"px";this._FormBox.style.top=(this._getWindowHeight()-this._FormBox.offsetHeight)/2+c+"px";this._Shadow.style.top=c+"px";this._Shadow.style.height=this._getWindowHeight()+"px"},_getWindowHeight:function(){if(window.self&&self.innerHeight)return self.innerHeight;if(document.documentElement&&document.documentElement.clientHeight)return document.documentElement.clientHeight;return 0},_getWindowWidth:function(){if(window.innerWidth)return window.innerWidth;
if(document.documentElement&&document.documentElement.clientWidth)return document.documentElement.clientWidth;else if(document.body&&document.body.clientWidth)return document.body.clientWidth;return 0}};
