var global_reset_newposts_length=30000;var global_update_newposts_length=55000;var global_add_on_posts_length=500;function emptycheck(what)
{if(ctl!=0)
{document.getElementById('ctl_id').value=(timenow()-ctl);}
if(document.getElementById('post_ta').value=='')
{alert('Cannot submit nothing!');return false;}
document.getElementById('post_ta').value=document.getElementById('post_ta').value.replace(/from/g,' f rom ');if(what==0)
{return true;}
else if(what==1)
{return confirm("You are 'reviving' a very old thread, are you sure you want to?");}
return true;}
function open_msg()
{return true;if(document.getElementById('postingarea'))
{document.getElementById('postingarea').style.display="inline";}
do_open();}
function do_open()
{return true;var wut=document.getElementById('postingarea').style.display;if(wut!="none"){document.getElementById('post_ta').focus();}}
function posttimer(id)
{if(document.getElementById(id))
{var startingfinal=document.getElementById(id).getAttribute('name');var starting=startingfinal;startingfinal++;var work;var hours;var seconds;var mins;var returnage;var days;var months;work=starting/2678400;months=Math.floor(work);starting=work-months;starting=starting*2678400;work=starting/86400;days=Math.floor(work);starting=work-days;starting=starting*86400;work=starting/3600;hours=Math.floor(work);starting=work-hours;starting=starting*3600;work=starting/60;mins=Math.floor(work);seconds=work-mins;seconds=seconds*60;seconds=Math.round(seconds);seconds=seconds+'s';if(mins==0)
{mins='';}
else
{mins=mins+'m ';}
if(hours==0)
{hours='';}
else
{hours=hours+'h ';seconds='';}
if(days==0)
{days='';}
else if(days>=7)
{days=days/7;days=Math.floor(days);var wkword='wks';if(days==1)
{wkword='wk';}
days=days+' '+wkword+' ';hours='';mins='';seconds='';}
else
{days=days+'d ';mins='';seconds='';}
if(months==0)
{months='';}
else
{if(months>11)
{months=months/12;months=Math.round(months*100)/100
months=months+' years ';days='';}
else
{var mword='months';if(months==1)
{mword='month';}
months=months+' '+mword+' ';}
hours='';mins='';seconds='';}
returnage=' '+months+days+hours+mins+seconds+' ago';document.getElementById(id).innerHTML=returnage;document.getElementById(id).setAttribute('name',startingfinal);if(months==0)
{var t=setTimeout("posttimer('"+id+"')",1000)}}}
function minimizeexpand(post_id)
{var what=delposts2[post_id];document.getElementById(post_id).innerHTML=what;}
while(a<maxn)
{a++;if(document.getElementById("p"+a))
{posttimer("p"+a);}}
var lastnum=0;var upto=9;function counter_donewposts()
{}
var ctl=0;function checktyping()
{var cur_len=document.getElementById('post_ta').value.length;if(cur_len>=1)
{updatetyping(1);if(ctl==0)
{ctl=timenow();}}
else
{updatetyping(0);}}
var current_update=2;function updatetyping(what)
{if(current_update==what)
{return;}
else
{current_update=what;}
var xmlHttp=new_connection();if(xmlHttp)
{xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4)
{var i=xmlHttp.responseText;}}
var url=rootdir+"xml/updatetyping.php?tid="+thr+"&v="+what;url=url+"&chk="+Math.random();xmlHttp.open("GET",url,true);xmlHttp.send(null);}}
function handlelocked(val)
{var what="";if(val==1)
{what=" [LOCKED]";}
if(document.getElementById('thread_title_top'))
{var title_part=document.getElementById('thread_title_top').innerHTML;title_part=title_part.replace(' [LOCKED]','');title_part=title_part.replace('[LOCKED]','');document.getElementById('thread_title_top').innerHTML=title_part+what;}
if(document.getElementById('thread_title_bottom'))
{var title_part=document.getElementById('thread_title_bottom').innerHTML;title_part=title_part.replace(' [LOCKED]','');title_part=title_part.replace('[LOCKED]','');document.getElementById('thread_title_bottom').innerHTML=title_part+what;}}
var zb;var tep=0;function addnewposts()
{var xmlHttpf=new_connection();xmlHttpf.onreadystatechange=function()
{if(xmlHttpf.readyState==4)
{var w=xmlHttpf.responseText;if(globaladdnewposts==true)
{setTimeout("addnewposts()",global_update_newposts_length);}
if(w==''||w==null||w==false||w=='undefined')
{return;}
if(w=='error')
{globaladdnewposts=false;return;}
w=trim(w);if(w.substr(0,4)!='good')
{return;}
w=w.substr(4);var frmarray=w.split('|"|');var newlocked=frmarray[0];if(document.getElementById('debug_display'))
{document.getElementById('debug_display').innerHTML=document.getElementById('debug_display').innerHTML+' &nbsp; '+'LOCKED: '+newlocked;}
if(newlocked!=curlocked)
{curlocked=newlocked;handlelocked(newlocked);}
w=frmarray[1];var wtype=frmarray[2];var newposts=frmarray[3];if(Math.random()<.01)
{if(document.getElementById('curviewing'))
{if(document.getElementById('curviewing').innerHTML!=w)
{document.getElementById('curviewing').innerHTML=w;}}}
if(document.getElementById('curviewingbot'))
{if(document.getElementById('curviewingbot').innerHTML!=w)
{document.getElementById('curviewingbot').innerHTML=w;}}
if(document.getElementById('curtyping'))
{if(document.getElementById('curtyping').innerHTML!=wtype)
{document.getElementById('curtyping').innerHTML=wtype;}}
if(wtype=='')
{forumhide('curtypingpart');forumhide('curtyping');}
else
{forumunhide('curtypingpart');forumunhide('curtyping');}
if(newposts==false||newposts==null||newposts==''||newposts=='undefined')
{return;}
if(newposts!='')
{zb=newposts.substr(0,15);zb=trim(zb);if(zb!=za)
{za=zb;newposts=newposts.substr(15);if(newposts!='')
{if(document.getElementById('extraposts'))
{global_update_newposts_length=global_reset_newposts_length;document.getElementById('extraposts').innerHTML=document.getElementById('extraposts').innerHTML+newposts;}}
counter_donewposts();tep++;}}}}
var url=rootdir+"xml/threadnewposts.php?z="+za+"&t="+thr+"&pn="+pn+"&sid="+si+"&platform="+platform;url=url+"&chk="+Math.random();xmlHttpf.open("GET",url,true);xmlHttpf.send(null);global_update_newposts_length=global_update_newposts_length+global_add_on_posts_length;if(document.getElementById('debug_display'))
{document.getElementById('debug_display').innerHTML='Updating: '+timenow();}
return;}
if(globaladdnewposts==true)
{setTimeout("addnewposts()",global_update_newposts_length);}
function DeleteMyPost(post_id)
{if(confirm("Are you sure you want to delete your post\nThis cannot be un-done"))
{}
else
{return false;}
var working='<div class="fremoved"><div class="whomod"><strong>Removing Post</strong> <span>please wait...</span></div></div>';document.getElementById(post_id).innerHTML=working;var xmlHttpch=new_connection();if(xmlHttpch)
{xmlHttpch.onreadystatechange=function()
{if(xmlHttpch.readyState==4)
{var ret=xmlHttpch.responseText;if(ret=='good'||ret.substr(0,8)=='reloadto')
{document.getElementById(post_id).style.display="none";if(ret.substr(0,8)=='reloadto')
{window.location=rootdir+'forums/thread/p'+ret.substr(8)+'#'+ret.substr(8);}}
else if(ret=='error')
{working='<div class="fremoved"><div class="whomod"><strong>ERROR</strong> <span>please try again...</span></div></div>';document.getElementById(post_id).innerHTML=working;}
else
{working='<div class="fremoved"><div class="whomod"><strong>UNKNOWN ERROR</strong> <span>please try again...</span></div></div>';document.getElementById(post_id).innerHTML=working;}
return false;}}
var url=rootdir+"xml/removemypost.php?id="+post_id;url=url+"&chk="+Math.random();xmlHttpch.open("GET",url,true);xmlHttpch.send(null);}
return false;}
function do_quote(theadid,quote_name,page,pid)
{var userselect;var where=document.postbox.post;if(document.selection)
{userselect=document.selection.createRange().text;if(userselect)
{var toshow='[QUOTE='+quote_name+']\n'+userselect+'[/QUOTE]\n';where.value+=toshow;open_msg();thread_textarea_focus();return;}}
else if(window.getSelection)
{var userselect=window.getSelection();if(userselect!='')
{var toshow='[QUOTE='+quote_name+']\n'+userselect+'[/QUOTE]\n';where.value+=toshow;open_msg();thread_textarea_focus();return;}}
window.location=rootdir+"forums/thread/"+theadid+"/"+page+"/q"+pid;return;}
function addtopostbox(what)
{document.postbox.post.value+=what;thread_textarea_focus();}
function do_emotion(what,middle,extra)
{var whata='['+what+extra+']';var whatb='[/'+what+']';var where=document.postbox.post;if(document.selection)
{var text=document.selection.createRange().text;if(text)
{text=whata+text+whatb;document.selection.createRange().text=text;where.focus();return;}}
else if(where.selectionEnd&&(where.selectionEnd-where.selectionStart>0))
{var start=where.selectionStart;var end=where.selectionEnd;var length=end-start;var currenttext=where.value;var before=currenttext.substr(0,start);var selection=currenttext.substr(start,length);var after=currenttext.substr(end);selection=whata+selection+whatb;where.value=before+selection+after;where.focus();return;}
var whattodo=whata+middle+whatb;addtopostbox(whattodo);return;}
function do_url()
{var where=document.postbox.post;var putme;if(document.selection)
{var text=document.selection.createRange().text;if(text)
{var test=text.substr(0,4);if(test=='www.'||test=='http')
{putme='[URL='+text+']Click this Link[/URL]';}
else
{putme='[URL=www.example.com]'+text+'[/URL]';}
document.selection.createRange().text=putme;where.focus();return;}}
else if(where.selectionEnd&&(where.selectionEnd-where.selectionStart>0))
{var start=where.selectionStart;var end=where.selectionEnd;var length=end-start;var currenttext=where.value;var before=currenttext.substr(0,start);var selection=currenttext.substr(start,length);var after=currenttext.substr(end);var test=selection.substr(0,4);if(test=='www.'||test=='http')
{putme='[URL='+selection+']Click this Link[/URL]';}
else
{putme='[URL=www.example.com]'+selection+'[/URL]';}
where.value=before+putme+after;where.focus();return;}
var what='[URL=www.example.com]Click this Link[/URL]';addtopostbox(what);return;}
function MultiExpand()
{var a=arguments;var totalitems=a.length;var postid=0;for(var i=0;i<totalitems;i++)
{postid=a[i];if(i==0)
{if(document.getElementById(postid))
{document.getElementById(postid).style.display="none";}}
else if(!isNaN(postid)&&postid>0)
{if(totalitems==2)
{expand(postid);}
else
{forumunhide('bury_'+postid);forumunhide('bury2_'+postid);}}}}
function thread_textarea_focus()
{window.scroll(0,13371337);if(document.getElementById("post_ta"))
{document.getElementById("post_ta").focus();}}
var global_thread_split_value=0;function handle_thread_splitting()
{if(global_thread_split_value==0)
{thread_splitting(1);global_thread_split_value=1;}
else
{thread_splitting(0);global_thread_split_value=0;}
return false;}
function thread_split_move_to_new(thread_id)
{var posts_string=thread_splitting_get_posts_string();if(posts_string=="")
{alert("No posts have been selected");return false}
var new_thread_title=prompt("Enter new thread title","");if(new_thread_title==""||new_thread_title==false||new_thread_title==null)
{return false;}
var id_req="thread_splitting_new";cg_alert(id_req,"Moving posts to: "+htmlentities(new_thread_title),"SPLITTING POSTS FROM THREAD",2);thread_splitting(0);var loc=rootdir+"forums/thread.php?id="+thread_id+"&new_thread_title="+urlencode(new_thread_title)+"&split_posts="+posts_string;window.location=loc;}
function thread_split_move_to_existing(thread_id)
{var posts_string=thread_splitting_get_posts_string();if(posts_string=="")
{alert("No posts have been selected");return false}
var move_to_thread_id=prompt("Enter the ID of the thread you wish to move posts to\nThe ID is the number in the URL ie:\n forums/thread/123/threadtitle/","");if(move_to_thread_id==""||move_to_thread_id==false||move_to_thread_id==null||isNaN(move_to_thread_id)||move_to_thread_id<=0)
{return false;}
var id_req="thread_splitting_existing";cg_alert(id_req,"Moving posts to thread ID: "+htmlentities(move_to_thread_id),"SPLITTING POSTS FROM THREAD",2);thread_splitting(0);var loc=rootdir+"forums/thread.php?id="+thread_id+"&split_to_thread_id="+urlencode(move_to_thread_id)+"&split_posts="+posts_string;window.location=loc;}
function thread_splitting_get_posts_string()
{var content="";var listsArray=document.getElementsByTagName("input");var listsNo=listsArray.length;for(i=0;i<listsNo;i++)
{if(listsArray[i].className=="thread_splitting"&&listsArray[i].checked==true&&listsArray[i].value!="")
{content=content+listsArray[i].value+"_";}}
return content;}
function thread_splitting(val)
{var listsArray=document.getElementsByTagName("input");var listsNo=listsArray.length;for(i=0;i<listsNo;i++)
{if(listsArray[i].className=="thread_splitting")
{if(val==1)
{listsArray[i].style.display="";}
else
{listsArray[i].style.display="none";}}}}