
var m_eFVDiv=null;var m_sFVAutoThread=null;var m_sFVAutoPost=null;var m_iFVNowClient=0;var m_iFVNowServer=0;var m_iFVAgeInterval=-1;var m_bFVQuick=false;function FVModified(d,t)
{this.Div=d;this.Time=(new Date(t)).getTime();}
function FVModifiedAdd(d,t)
{if(this.length)
{this.length++;this[(this.length-1)]=new FVModified(d,t);}
else
{this.length=1;this.FVModifiedAdd=FVModifiedAdd;}
return this.length-1;}
var m_lstFVModified=new FVModifiedAdd('','');function FVPreload(g,t,r)
{this.Guid=g;this.Type=t;this.Result=r;}
function FVPreloadAdd(g,t,r)
{if(this.length)
{this.length++;this[(this.length-1)]=new FVPreload(g,t,r);}
else
{this.length=1;this.FVPreloadAdd=FVPreloadAdd;}
return this.length-1;}
var m_lstFVPreload=new FVPreloadAdd('',0,'');function FVThread(sAnchorId,sDivId,sGuid)
{if(m_eFVDiv==null)
{var a=$(sAnchorId);m_eFVDiv=$(sDivId);if(m_eFVDiv.style==null||m_eFVDiv.style.display==null||m_eFVDiv.style.display=='')
{Common.TextAdd(m_eFVDiv,'Loading...');m_eFVDiv.style.display='block';a.className=a.className.replace(/wdsectionplus/g,'wdsectionminus');var b=false;for(var i=1;i<m_lstFVPreload.length;i++)
{if(sGuid==m_lstFVPreload[i].Guid&&12==m_lstFVPreload[i].Type)
{FVThreadComplete(m_lstFVPreload[i].Result,'','');b=true;break;}}
if(!b)
{JavaService.ForumView(Common.SessionID(),sGuid,12,FVThreadComplete,FVError,'');}}
else
{if(m_eFVDiv.style.display=='none')
{m_eFVDiv.style.display='block';a.className=a.className.replace(/wdsectionplus/g,'wdsectionminus');}
else
{m_eFVDiv.style.display='none';a.className=a.className.replace(/wdsectionminus/g,'wdsectionplus');}
m_eFVDiv=null;}}}
function FVThreadComplete(result,context,senderFunction)
{Common.TextRemove(m_eFVDiv);if(result.substring(0,6)=='Error:')
{Common.TextAdd(m_eFVDiv,result);}
else
{var cItems=JSON.parse(result);if(cItems.Items.length>0)
{for(var i=0;i<cItems.Items.length;i++)
{m_eFVDiv.appendChild(FVAddThread(cItems.Items[i].Item,cItems));}}
if(m_bFVQuick&&cItems.CanThreadWrite=='True')
{if(cItems.Items.length>0)
{var d=document.createElement('div');d.className='wdsectionquickpostseperator g9b';m_eFVDiv.appendChild(d);}
m_eFVDiv.appendChild(FVQuick(cItems.Key,cItems.Name,false));}}
m_eFVDiv.style.display='block';FVAgeUpdate();m_eFVDiv=null;}
function FVError(error,context,senderFunction)
{Common.TextRemoveAll(m_eFVDiv);Common.TextAdd(m_eFVDiv,error.get_message());m_eFVDiv=null;}
function FVAddThread(i,pa)
{var y='t'+i.ID;var z='c'+i.ID;var d=document.createElement('div');d.className='wdsectionthread g9b';var h=document.createElement('div');h.className='wdsectionthreadheader a0p';if(i.HasImage=='True')
{var p=document.createElement('div');p.className='wdsectionthreadimage';var pp=document.createElement('img');pp.src=eItem.ImageUrl;p.appendChild(pp);h.appendChild(p);}
var t=document.createElement('div');t.className='wdsectionthreadtitle';var a=document.createElement('a');a.id=y;a.className='wdsectionplus';a.href="javascript: FVPost('"+y+"','"+z+"','"+i.Key+"');";a.title=i.Name;a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status=\""+i.Name+"\";return true;");a.appendChild(document.createTextNode(i.Name));t.appendChild(a);h.appendChild(t);if(m_sFVAutoThread==i.ID)
{self.setTimeout("FVPost('"+y+"','"+z+"','"+i.Key+"')",100);m_sFVAutoThread=null;}
if(!m_bFVQuick&&(i.CanPostWrite=='True'||i.CanDelete=='True'))
{var m=Common.RoundedPanel(h,'wdsectionmenu','m9b','g0p','m1b','m9p','m9i');if(i.CanPostWrite=='True')
{var a=document.createElement('a');a.className='wdmenuitem';a.href='/New/Post/'+i.Key+Common.SessionQS();a.title='Create a new post';a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status='Create a new post';return true;");a.appendChild(document.createTextNode('New post'));m.appendChild(a);if(i.CanDelete=='True')
m.appendChild(document.createTextNode('|'));}
if(i.CanDelete=='True')
{var a=document.createElement('a');a.className='wdmenuitem';a.href='?adoptionmove='+pa.Key+'&'+pa.Format+'&'+i.Key+Common.SessionQS();a.title='Move thread to another forum';a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status='Move thread to another forum';return true;");a.appendChild(document.createTextNode('Move thread'));m.appendChild(a);m.appendChild(document.createTextNode('|'));var a=document.createElement('a');a.className='wdmenuitem';a.href='/Delete/'+i.Key+Common.SessionQS();a.title='Delete this thread and all posts within';a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status='Delete this thread and all posts within';return true;");a.appendChild(document.createTextNode('Delete thread'));m.appendChild(a);}}
var m=document.createElement('div');m.className='wdsectionmodified';m.title=i.LatestPostModifiedDisplay;m.id='a'+i.ID;if(i.LatestPostModified=='')
i.LatestPostModified=i.Modified;m_lstFVModified.FVModifiedAdd(m.id,i.LatestPostModified);h.appendChild(m);var r=document.createElement('div');r.className='clearfixprev';h.appendChild(r);var c=document.createElement('div');c.className='clearfix';h.appendChild(c);d.appendChild(h);c=document.createElement('div');c.id=z;c.className='wdsectionthreadcontent';c.style.display='none';d.appendChild(c);return d;}
function FVPost(sAnchorId,sDivId,sGuid)
{if(m_eFVDiv==null)
{var a=$(sAnchorId);m_eFVDiv=$(sDivId);if(m_eFVDiv.childNodes==null||m_eFVDiv.childNodes.length==0)
{Common.TextAdd(m_eFVDiv,'Loading...');a.className=a.className.replace(/wdsectionplus/g,'wdsectionminus');var b=false;for(var i=1;i<m_lstFVPreload.length;i++)
{if(sGuid==m_lstFVPreload[i].Guid&&13==m_lstFVPreload[i].Type)
{FVPostComplete(m_lstFVPreload[i].Result,'','');b=true;break;}}
if(!b)
{JavaService.ForumView(Common.SessionID(),sGuid,13,FVPostComplete,FVError,'');}}
else
{if(m_eFVDiv.style.display=='none')
{m_eFVDiv.style.display='block';a.className=a.className.replace(/wdsectionplus/g,'wdsectionminus');}
else
{m_eFVDiv.style.display='none';a.className=a.className.replace(/wdsectionminus/g,'wdsectionplus');}
m_eFVDiv=null;}}}
function FVPostComplete(result,context,senderFunction)
{Common.TextRemoveAll(m_eFVDiv);if(result.substring(0,6)=='Error:')
{Common.TextAdd(m_eFVDiv,result);}
else
{var cItems=JSON.parse(result);if(cItems.Items.length>0)
{for(var i=0;i<cItems.Items.length;i++)
{if(i!=0)
{var g=document.createElement('div');g.className='ViewPostGap';m_eFVDiv.appendChild(g);}
m_eFVDiv.appendChild(FVAddPost(cItems.Items[i]));}}
if(m_bFVQuick&&cItems.CanPostWrite=='True')
{m_eFVDiv.appendChild(FVQuick(cItems.Key,cItems.Name,true));}}
m_eFVDiv.style.display='block';if(m_sFVAutoPost!=null)
{var s=$(m_sFVAutoPost);m_sFVAutoPost=null;}
FVAgeUpdate();m_eFVDiv=null;}
function FVAddPost(i)
{var d=document.createElement('div');d.className='wdsectionpost g9b g0p';var h=document.createElement('div');h.className='wdsectionpostheader g1p';var t=document.createElement('div');t.className='wdsectionposttitle';var u=document.createElement('a');u.href='/View/'+i.UserKey+Common.SessionQS();u.title='View user';u.onmouseout=new Function("window.status=' ';");u.onmouseover=new Function("window.status='View user';return true;");u.appendChild(document.createTextNode(i.UserName));t.appendChild(u);if(i.GroupKey!=null)
{t.appendChild(document.createTextNode(' of '));var g=document.createElement('a');g.href='/View/'+i.GroupKey+Common.SessionQS();g.title='View group';g.onmouseout=new Function("window.status=' ';");g.onmouseover=new Function("window.status='View group';return true;");g.appendChild(document.createTextNode(i.GroupName));t.appendChild(g);}
h.appendChild(t);if(!m_bFVQuick&&(i.CanWrite=='True'||i.CanDelete=='True'))
{var m=Common.RoundedPanel(d,'wdsectionmenu','m9b','g0p','m1b','m9p','m9i');if(i.CanWrite=='True')
{var a=document.createElement('a');a.className='wdmenuitem';a.href='/Edit/Post/'+i.Key+Common.SessionQS();a.title='Edit your post';a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status='Edit your post';return true;");a.appendChild(document.createTextNode('Edit post'));m.appendChild(a);if(i.CanDelete=='True')
m.appendChild(document.createTextNode('|'));}
if(i.CanDelete=='True')
{var a=document.createElement('a');a.className='wdmenuitem';a.href='/Delete/'+i.Key+Common.SessionQS();a.title='Delete this post';a.onmouseout=new Function("window.status=' ';");a.onmouseover=new Function("window.status='Delete this post';return true;");a.appendChild(document.createTextNode('Delete post'));m.appendChild(a);}}
var m=document.createElement('div');m.className='wdsectionpostmodified';m.title=i.ModifiedDisplay;m.id='a'+i.ID;m_lstFVModified.FVModifiedAdd(m.id,i.Modified);h.appendChild(m);var r=document.createElement('div');r.className='clearfixprev';h.appendChild(r);var r=document.createElement('div');r.className='clearfix';h.appendChild(r);d.appendChild(h);var eContent=document.createElement('div');eContent.className='wdsectionpostcontent';eContent.innerHTML=Common.UnhexHtml(i.Description);d.appendChild(eContent);return d;}
function FVAgeUpdate()
{self.clearInterval(m_iFVAgeInterval);var n=(new Date()).getTime();var o=m_iFVNowServer-m_iFVNowClient;for(var i=1;i<m_lstFVModified.length;i++)
{var d=$(m_lstFVModified[i].Div);if(d!=null)
{Common.TextRemoveAll(d);var p=m_lstFVModified[i].Time;Common.TextAdd(d,FVAgeDisplay((n-p+o)/1000));}}
m_iFVAgeInterval=self.setInterval('FVAgeUpdate()',10000);}
function FVAgeDisplay(s)
{var r;if(s>(60*60*24*365*50))
r='';else if(s>(60*60*24*365*2))
r=Math.floor(s/(60*60*24*365))+' years ago';else if(s>(60*60*24*60))
r=Math.floor(s/(60*60*24*30))+' months ago';else if(s>(60*60*24*14))
r=Math.floor(s/(60*60*24*7))+' weeks ago';else if(s>(60*60*24*2))
r=Math.floor(s/(60*60*24))+' days ago';else if(s>(60*60*2))
r=Math.floor(s/(60*60))+' hours ago';else if(s>(60*2))
r=Math.floor(s/60)+' minutes ago';else
r=Math.floor(s)+' seconds ago';return r;}
function FVQuick(k,h,b)
{var dd=document.createElement('div');dd.id='q'+k;var rr=document.createElement('div');rr.id='qu'+k;var ti;var te;if(b)
{ti='Reply to this thread with your own message';te='Reply to thread '+h;}
else
{ti='Start a new thread with your own message, for others to read and reply too';te='Start a new thread in '+h;}
rr.appendChild(Common.ACButton(te,ti,new Function('Common.Animate($(\''+rr.id+'\'),Common.AnimateType.HorizontalCollapse);Common.Animate($(\'qt'+k+'\'),Common.AnimateType.HorizontalExpand);')));dd.appendChild(rr);var d=document.createElement('div');d.id='qt'+k;d.className='wdsectionquickpost g0p g0i g9b';d.style.display='none';var t;var r=document.createElement('div');r.className='wdsectionquicktitle g9i g9p';r.title=ti;r.appendChild(document.createTextNode(te));d.appendChild(r);var re=document.createElement('div');re.id=Common.Unique();re.className='wdsectionquickerror f1p f1i f9b';re.title='View_tipForumQuickError';re.style.display='none';d.appendChild(re);r=document.createElement('div');r.className='wdsectionquickfield';r.title='Give yourself a name, between 3 and 128 characters long using only letters, numbers and the odd space, so no symbols';var s=document.createElement('span');s.className='wdsectionquickfieldtitle';t=document.createTextNode('Name:');s.appendChild(t);r.appendChild(s);var iu=document.createElement('input');iu.className='eck_text javaedit';iu.type='text';iu.size='50';iu.minlength=3;iu.maxlength=25;iu.name=iu.id=Common.Unique();iu.autocomplete='off';r.appendChild(iu);d.appendChild(r);r=document.createElement('div');r.className='wdsectionquickfield';r.title='Heading for message';s=document.createElement('span');s.className='wdsectionquickfieldtitle';t=document.createTextNode('Heading:');s.appendChild(t);r.appendChild(s);var ih=document.createElement('input');ih.className='eck_text javaedit';ih.type='text';ih.size='50';ih.minlength=1;ih.maxlength=128;ih.id=Common.Unique();if(b)
{r.style.display='none';ih.value=h;}
r.appendChild(ih);d.appendChild(r);r=document.createElement('div');r.className='wdsectionquickfield';r.title='Enter the message of your post';s=document.createElement('span');s.className='wdsectionquickfieldtitle';t=document.createTextNode('Message:');s.appendChild(t);r.appendChild(s);var ic=document.createElement('textarea');ic.className='eck_text javaedit';ic.rows='5';ic.cols='50';ic.minlength=0;ic.maxlength=4000;ic.id=Common.Unique();r.appendChild(ic);d.appendChild(r);r=document.createElement('div');r.appendChild(Common.ACButton('Submit','Post this message, so others can read it',new Function('return FVQuickSubmit(\''+k+'\',\''+re.id+'\',\''+iu.id+'\',\''+ih.id+'\',\''+ic.id+'\');')));d.appendChild(r);dd.appendChild(d);return dd;}
function FVQuickSubmit(k,e,u,t,p)
{ee=$(e);Common.TextRemoveAll(ee);var b=false;var uu=$(u).value;var r=/^[\w\s]{1,25}$/;if(uu.length<3||uu.length>25||r.test(uu)==false)
{if(b==false)
{FVQuickSubmitHeader(ee);b=true;}
Common.TextAdd(ee,'Your name must be between 3 and 128 letters or numbers long');ee.appendChild(document.createElement('br'));}
var tt=$(t).value;r=/^[\w\s]{1,128}$/;if(tt.length<1||tt.length>128||r.test(tt)==false)
{if(b==false)
{FVQuickSubmitHeader(ee);b=true;}
Common.TextAdd(ee,'The heading must be between 1 and 128 letters, numbers or spaces long, without symbols');ee.appendChild(document.createElement('br'));}
var pp=$(p).value;r=/^[\w\ \.\,\x27\x22\+\-\=\;\:\&\!\(\)\\[\]\*\@\#\x2f\n\r\??\$\???\??\%\{\}\?]{0,4000}$/;if(pp.length<0||pp.length>4000||r.test(pp)==false)
{if(b==false)
{FVQuickSubmitHeader(ee);b=true;}
Common.TextAdd(ee,'The message has to be between 1 and 4000 characters long, Only letters, numbers, spaces and a few symbols can be used');ee.appendChild(document.createElement('br'));}
if(b)
{ee.style.display='block';}
else
{ee.style.display='none';JavaService.PostAdd(Common.SessionID(),k,uu,tt,pp,FVPostAddComplete,FVError,'');var d=$('qt'+k);Common.TextRemoveAll(d);Common.TextAdd(d,'Processing request...');}
return true;}
function FVQuickSubmitHeader(a)
{var b=document.createElement('b');Common.TextAdd(b,'There are errors with your entries:');a.appendChild(b);a.appendChild(document.createElement('br'));}
function FVPostAddComplete(result,context,senderFunction)
{if(result.substring(0,6)=='Error:')
{alert(result);}
else
{var cItems=JSON.parse(result);var d=$('qt'+cItems.Key);Common.TextRemoveAll(d);Common.TextAdd(d,'Your request is now awaiting to be approved');}}
