function CObject(b,a){this.id=b;this.refresh=a;this.failcount=0;this.time=0;this.content}function CImage(d,b,c){this.id=d;this.refresh=b;this.time=0;var a=new Image();a.src=c;this.i=a;this.done=0;this.width=0;this.height=0;this.link="";this.alt=""}function CDialog(c,a,b){this.id=c;this.x=a;this.y=b;this.offsetx=0;this.offsety=0;this.active}var contr=new Array();var imgs=new Array();var dialogs=new Array();var sinc=0;window.settingMessage=false;window.message="";window.lastmessage="";window.requestPending=0;window.norequest=0;var maxscroll=0;function refresh(a){sendMessage("refresh#"+a)}function sendMessage(a){if(window.message.indexOf(a)!=-1){return}window.settingMessage=true;if(window.message.length!=0){window.message+="&"}window.message+=a;window.settingMessage=false}function gotopage(a){setHash("?command=gotopage%23"+a);sendMessage("gotopage#"+a)}function gotoarticle(a){setHash("?command=gotoarticle%23"+a);sendMessage("gotoarticle#"+a)}function gotousermanagement(a){sendMessage("gotousermanagement#"+a)}function gotonewuser(){sendMessage("gotonewuser")}function gotoforum(){setHash("?command=gotoforum%23");sendMessage("gotoforum#")}function gotosubforum(a){setHash("?command=gotosubforum%23"+a);sendMessage("gotosubforum#"+a)}function gotothread(a){setHash("?command=gotothread%23"+a);sendMessage("gotothread#"+a)}function gotomessage(a){setHash("?command=gotomessage%23"+a);sendMessage("gotomessage#"+a)}function gotousermanagementlist(){sendMessage("gotousermanagementlist#")}function showaddcommentdialog(a){sendMessage("showaddcommentdialog#"+a)}function getHash(c){if(c==null){return 0}var b=0;var a=0;for(a=0;a<c.length;a++){b+=c.charCodeAt(a)}return b}function GetFromServer(sadrzaj,context){var filled=false;var strings=sadrzaj.split("###");var i=0;var last=-1;while(i<strings.length){if(last==i){alert(sadrzaj);sinc=0;requestPending=0;message=oldmessage+"&"+message;return}last=i;if(strings[i]=="empty"){i++;continue}if(strings[i]=="message"){i++;alert(strings[i]);i++;continue}if(strings[i]=="settitle"){i++;var title=strings[i];if(window.IE){var k=0;title+="   ";for(k=0;title.length<200;k++){title+=String.fromCharCode(171)}}document.title=title;i++;continue}if(strings[i]=="fill"){i++;if(document.getElementById(strings[i])!=null){var c=getControl(strings[i]);var refr=false;var myhash=getHash(strings[i+1]);if(c==null){refr=true}else{if(c.content!=myhash||strings[i+1]==""){refr=true}}if(refr){lastscroll=-1;filled=true;if(c!=null){c.content=myhash}strings[i+1]=strings[i+1].replace("<#rand#>","rand="+Math.random());document.getElementById(strings[i]).innerHTML=strings[i+1];if(strings[i+1]==""){document.getElementById(strings[i]).style.height="0px";document.getElementById(strings[i]).style.width="0px";document.getElementById(strings[i]).style.position="absolute"}else{document.getElementById(strings[i]).style.position="static";document.getElementById(strings[i]).style.height="auto";document.getElementById(strings[i]).style.width="auto"}}}else{if(strings[i]!="MainContent"){sendMessage("delete#"+strings[i]);removeControl(strings[i])}}if(strings[i]=="MainContent"){window.visibleHeight=-2;scrollheight=-1}i+=2;continue}if(strings[i]=="append"){i++;if(document.getElementById(strings[i])!=null){document.getElementById(strings[i]).innerHTML+=strings[i+1]}else{sendMessage("delete#"+strings[i]);removeControl(strings[i])}i+=2;continue}if(strings[i]=="dialog"){i++;getScroll();var sw=window.width;var sh=window.height;document.getElementById("dialog").innerHTML='<table id="diatable" width=100% height='+sh+'px background="images/forum/back.gif" cellpadding=0 cellspacing=0 border=0><tr valign=middle><td align=center>'+strings[i]+"</td></tr></table>";document.getElementById("dialog").style.visibility="visible";scrollEvent();i++;continue}if(strings[i]=="dialog1"){getScroll();i++;showdialog1(strings[i]);scrollEvent();i++;continue}if(strings[i]=="searchdialog"){i++;showsearchdialog(strings[i]);i++;continue}if(strings[i]=="popup"){window.popuptime=0;i++;document.getElementById("popupdialog").innerHTML=strings[i];var sw=window.width;var sh=window.height;var w=document.getElementById("popupdialog").offsetWidth;var h=document.getElementById("popupdialog").offsetHeight;document.getElementById("popupdialog").style.left=(sw-w-40+window.scrollx)+"px";document.getElementById("popupdialog").style.top=(40+window.scrolly)+"px";document.getElementById("popupdialog").style.visibility="visible";i++;continue}if(strings[i]=="closedialog"){i++;closedialog();continue}if(strings[i]=="closedial"){i++;closedial(strings[i+1]);i++;continue}if(strings[i]=="closedialog1"){i++;closedialog1();continue}if(strings[i]=="filldialog"){window.popuptime=0;i++;document.getElementById(strings[i]).innerHTML=strings[i+1];var sw=window.width;var sh=window.height;var w=document.getElementById(strings[i]).offsetWidth;var h=document.getElementById(strings[i]).offsetHeight;var posx=parseInt(strings[i+2]);if(posx<0){posx=(sw-w-posx+window.scrollx)}var posy=parseInt(strings[i+3]);if(posy<0){posy=(sh-h-posx+window.scrolly)}if(posx!=0){document.getElementById(strings[i]).style.left=posx+"px"}if(posy!=0){document.getElementById(strings[i]).style.top=posy+"px"}document.getElementById(strings[i]).style.visibility="visible";document.getElementById(strings[i]).style.position="absolute";i+=4;continue}if(strings[i]=="refreshall"){i++;var j=0;for(j=0;j<contr.length;j++){if(contr[j].id.indexOf("Menu")==-1&&contr[j].id.indexOf("Template")==-1){contr[j].time=2000000}}continue}if(strings[i]=="refresh"){i++;var j=0;for(j=0;j<contr.length;j++){if(contr[j].id==strings[i]){contr[j].time=2000000}}i++;continue}if(strings[i]=="fileuploaddone"){i++;onafterfiledone(strings[i],strings[i+1],strings[i+2]);i+=3;continue}if(strings[i]=="documentuploaddone"){i++;window.afterdocumentdone(strings[i],strings[i+1]);i+=2;continue}if(strings[i]=="playsound"){i++;document.getElementById("sound1").Play();i++;continue}if(strings[i]=="register"){i++;if(!controlExists(strings[i])){var c=new CObject(strings[i],strings[i+1]);c.time=2000000;contr[contr.length]=c}else{getControl(strings[i]).time=2000000}i+=2;continue}if(strings[i]=="image"){i++;var io=new CImage(strings[i],10000,strings[i+1]);io.alt=strings[i+2];io.width=strings[i+3];io.height=strings[i+4];io.link=strings[i+5];imgs[imgs.length]=io;i+=6;continue}if(strings[i]=="sethash"){i++;setHash(strings[i]);i++;continue}if(strings[i]=="loadmenu"){i++;eval(strings[i]);i++;continue}if(strings[i]=="runscript"){i++;eval(strings[i]);i++;continue}if(strings[i]=="changetemplate"){i++;window.triedToWriteMenus=false;contr=new Array();imgs=new Array();var c=new CObject(strings[i],1900000);c.time=2000000;contr[contr.length]=c;i++;continue}}oldmessage="";if(filled){getScroll();lastscroll=-1;window.scrollTo(0,window.scrolly)}sinc=0;requestPending=0}var skip=0;var scrolldone=true;function setscrollto(a){if(scrolldone){scrolldone=false;window.scrolltoval=a;setTimeout("doautoscroll()",10)}}function ParseControls(){if(scrollheight!=l){var n=document.getElementById("MainContent");if(n!=null){var l=n.offsetTop+n.offsetHeight+500;if(scrollheight==l){window.visibleHeight=l;lastscroll=-1}if(scrollheight<l){scrollheight=l}}}if(lastscroll!=window.scrolly){scrollEvent();lastscroll=window.scrolly;if(window.visibleHeight<window.scrolly&&scrollheight!=-1&&window.visibleHeight!=-2){var d=window.visibleHeight-600;if(d<0){d=0}setscrollto(d)}if(maxscroll<document.body.scrollHeight){maxscroll=document.body.scrollHeight+50;window.scrolldiv.style.width="2px";window.scrolldiv.style.height=maxscroll+"px"}}skip++;var g=0;var c=0;for(g=0;g<contr.length;g++){if(document.getElementById(contr[g].id)==null){if(contr[g].failcount>skip*5){sendMessage("delete#"+contr[g].id);removeControl(contr[g].id)}else{contr[g].failcount+=1}}else{if(contr[g].time>contr[g].refresh){if(sinc==0&&Math.random()>-1){if(c>10){sinc=1;c=0}c+=1;refresh(contr[g].id);contr[g].time=0}}if(skip>5){contr[g].time+=1}}}if(skip>5){skip=0;window.popuptime+=1;if(window.popuptime==10){closepopup()}}var k=0;var f=0;for(f=0;f<imgs.length;f++){if(document.getElementById(imgs[f].id)==null){removeimage(imgs[f].id);f--;continue}if(imgs[f].done==0){if(imgs[f].i!=null){if(imgs[f].i.complete){var b="";if(imgs[f].width!=0){b+=" width="+imgs[f].width}if(imgs[f].height!=0){b+=" height="+imgs[f].height}var e="<img src="+imgs[f].i.src+b+' alt="'+imgs[f].alt+'" border="0" />';if(imgs[f].link!=""){e='<a href="'+imgs[f].link+'">'+e+"</a>"}document.getElementById(imgs[f].id).innerHTML=e;imgs[f].done=1}}}}window.norequest++;if(window.settingMessage==false&&window.message.length!=0){var m=document.getElementById("pageInstance").value;UseCallback(m+"?"+window.message)}if(window.message.length==0&&window.norequest>20){window.norequest=0;var m=document.getElementById("pageInstance").value;UseCallback(m+"?empty")}var a="";if(window.IE){if(document.getElementById("fakeframe").readyState!="loading"){a=window.location.href;if(a.indexOf("#?")!=-1){a="#"+a.substr(a.indexOf("#?")+1)}else{a=""}if(a!=""&&a!=window.lastHash){setHash(a.substr(1));sendMessage(a.substr(a.indexOf("#?")+2+8).replace("%23","#"))}else{a=document.getElementById("fakeframe").contentWindow.location.href;if(a.indexOf("?")!=-1){a="#"+a.substr(a.indexOf("?"))}else{a=""}}}else{a=window.lastHash}}else{a=window.location.href;if(a.indexOf("#?")!=-1){a="#"+a.substr(a.indexOf("#?")+1)}else{a=""}}if(a!=""&&window.lastHash!=a){setHash(a.substr(1));sendMessage(a.substr(a.indexOf("#?")+2+8).replace("%23","#"))}setTimeout("ParseControls();",200)}function starttimer(a){scrollheight=-1;window.scrolldiv=document.getElementById("scrolldiv");window.htmlTag=document.getElementsByTagName("HTML")[0];window.bodyTag=document.getElementsByTagName("BODY")[0];getScroll();scrollEvent();if(a==0){setTimeout("ParseControls();",50)}}function removeControl(b){var a=0;for(a=0;a<contr.length;a++){if(contr[a].id==b){contr.splice(a,1);return}}}function removeimage(b){var a=0;for(a=0;a<imgs.length;a++){if(imgs[a].id==b){imgs.splice(a,1);return}}}function controlExists(b){var a=0;for(a=0;a<contr.length;a++){if(contr[a].id==b){return true}}return false}function getControl(b){var a=0;for(a=0;a<contr.length;a++){if(contr[a].id==b){return contr[a]}}return null}function onEnter(e,fname){var ev;if(e==null){ev=event}else{ev=e}if(ev.keyCode==13){eval(fname);return true}return false}function submitCommandValue(a,d,c){var b="submitcommand#"+a+"#"+d+"#"+c;sendMessage(b)}function setHash(e){var d=document.title;var c="";if(window.IE){c=document.getElementById("fakeframe").contentWindow.location.href;if(c.indexOf("?")!=-1){c="#"+c.substr(c.indexOf("?"))}else{c=""}}else{c=window.location.href;if(c.indexOf("#?")!=-1){c="#"+c.substr(c.indexOf("#?")+1)}else{c=""}}window.location.hash=e.replace("#","%23");window.lastHash="#"+e;if(window.IE){var b=document.getElementById("fakeframe");b.contentWindow.location="blank.html"+e}if(window.IE){var a=0;d+="   ";for(a=0;d.length<200;a++){d+=String.fromCharCode(171)}}document.title=d}function getScroll(){var b=0;if(window.navigator.appName.indexOf("Internet")==-1){window.scrolly=window.pageYOffset;window.scrollx=window.pageXOffset;window.height=window.innerHeight;window.width=window.innerWidth}else{window.scrolly=0;window.scrollx=0;var a=document.body;if(a.scrollTop!=0){window.scrolly=a.scrollTop}if(a.scrollLeft!=0){window.scrollx=a.scrollLeft}window.height=a.offsetHeight;window.width=a.offsetWidth;var a=window.htmlTag;if(a.scrollTop!=0){window.scrolly=a.scrollTop}if(a.scrollLeft!=0){window.scrollx=a.scrollLeft}window.height=a.offsetHeight;window.width=a.offsetWidth}}function scrollEvent(){var e=document.getElementById("diatable");if(e!=null){var b=document.getElementById("dialog");var i=window.width;var d=window.height;var g=b.offsetWidth;var c=b.offsetHeight;b.style.left=(i/2-g/2+window.scrollx)+"px";b.style.top=(d/2-c/2+window.scrolly)+"px";e.style.top=window.scrolly+"px";e.style.left=window.scrollx+"px";e.style.width=i+"px";e.style.height=d+"px"}var f=document.getElementById("diatable1");if(f!=null){var j=document.getElementById("dialog1");var i=window.width;var d=window.height;var g=j.offsetWidth;var c=j.offsetHeight;j.style.left=(i/2-g/2+window.scrollx)+"px";j.style.top=(d/2-c/2+window.scrolly)+"px";f.style.top=window.scrolly+"px";f.style.left=window.scrollx+"px";f.style.width=i+"px";f.style.height=d+"px"}var a=document.getElementById("popupdialog");if(a.innerHTML!=""){var i=window.width;var d=window.height;var g=a.offsetWidth;var c=a.offsetHeight;a.style.left=(i-g-40+window.scrollx)+"px";a.style.top=(40+window.scrolly)+"px"}}function movedialog(g){try{var c=0;for(c=0;c<dialogs.length;c++){if(dialogs[c].active==true){var f;if(g==null){f=event}else{f=g}var b=f.screenX-dialogs[c].x;var a=f.screenY-dialogs[c].y;document.getElementById(dialogs[c].id).style.left=dialogs[c].offsetx+b+"px";document.getElementById(dialogs[c].id).style.top=dialogs[c].offsety+a+"px"}}}catch(d){}}function doautoscroll(){var a=Math.abs(window.scrolly-window.scrolltoval);if(a<20){window.scrollTo(window.scrollx,window.scrolly-a/10);scrolldone=true;return}window.scrollTo(window.scrollx,window.scrolly-a/10);setTimeout("doautoscroll()",10)}var lastscroll=-1;var sevent=false;var scrollheight=-1;
