var newsBox;var defaultTheme='div.itemBox {'
+' color: black; background-color: #e0e9f2; border: 1px dashed #95b1cf; padding: 15px; margin: 15px; '
+' border-radius: 10px; -webkit-border-radius: 10px; -opera-border-radius: 10px; -moz-border-radius: 10px; }'
+' div.itemBox span { font-size: 10px; color: gray; padding-left: 15px; padding-right: 15px; }'
+' div.itemBoxHead { background-color: #DDD; border-top: 1px solid #AAA; border-bottom: 1px solid #AAA; margin: 3px; padding: 3px; height: 40px; }'
+'div.itemBox .content { margin: 5px; overflow: hidden; }'
+' div.itemBoxTail { background-color: #DDD; border-top: 1px solid #AAA; border-bottom: 1px solid #AAA; margin: 3px; padding: 3px; }'
+'div.itemBox span.dato { float: right; }'
+'div.itemBox span.author { float: left; width: 100%; margin-bottom: 10px; }'
+'div.unhide { float: right; width: 100%; margin-bottom: 10px; color: gray; cursor: pointer; }'
+'div.itemBoxHead select { width: 100%; margin: 3px;}'
+'.forwardButton {float: right; width: 18px; height: 18px; background: transparent url(images/icons/arrow_right.gif) no-repeat 50% 50%; cursor: pointer; }'
+'.backButton {float: left; width: 18px; height: 18px; background: transparent url(images/icons/arrow_left_disabled.gif) no-repeat 50% 50%; }';function StyleBox(ID)
{newsBox=this;debug("<h3>Archive</h3>");newsBox.itemBoxDiv=document.getElementById(ID);newsBox.page=1;newsBox.pageSize=1;newsBox.maxHeight=200;newsBox.theme='defaultTheme';newsBox.stylesheet=false;newsBox.themes=new Array();newsBox.items=new Array();newsBox.themes['defaultTheme']=defaultTheme;newsBox.loadTheme('defaultTheme');newsBox.initItemBox();newsBox.loadItems(1);}
StyleBox.prototype={initItemBox:function()
{var el;var sorts=new Array('Date','Author','Headline','Sort by...');try{newsBox.content=elem('div',{className:'newsBox'},{},'');}catch(e){alert('You need to include the helper function "elem"');return;}
newsBox.head=elem('div',{className:'itemBoxHead'},{},'');var navigate=elem('div',{},{cssFloat:'left',width:'150px',textAlign:'center',verticalAlign:'bottom'},'');var sel=elem('select',{tabindex:'3'},{},'');sel.onchange=function(){newsBox.sortBy(this.options[this.selectedIndex].value);};while(el=sorts.pop())sel.appendChild(elem('option',{},{},el));navigate.appendChild(sel);navigate.appendChild(document.createElement('br'));navigate.appendChild(elem('div',{className:'backButton',title:'Go back one page',onclick:'newsBox.lastPage()'},{},''));navigate.appendChild(elem('div',{className:'forwardButton',title:'Go to next page',onclick:'newsBox.nextPage()'},{},''));navigate.appendChild(document.createTextNode(newsBox.page+'-'+newsBox.pageSize*newsBox.page+' ud af '+50));newsBox.head.appendChild(navigate);el=elem('div',{className:'search'},{cssFloat:'right'},'');var search=elem('input',{title:'Enter a filter word',value:'Filter'},{},'');search.onclick=function(){if(this.value=='Filter')this.value='';}
search.onblur=function(){if(this.value=='')this.value='Filter';}
el.appendChild(search);newsBox.head.appendChild(el);newsBox.head.appendChild(document.createElement('br'));newsBox.head.appendChild(document.createElement('br'));var res=elem('div',{},{cssFloat:'right',marginTop:'-8px',marginRight:'15px'},'Results per page: ');res.appendChild(elem('a',{href:'#',disabled:'true'},{textDecoration:'underline'},'10 '));res.appendChild(elem('a',{href:'#',onclick:'alert("25");'},{},'25 '));res.appendChild(elem('a',{href:'',onclick:'alert("50");'},{},'50 '));res.appendChild(elem('a',{href:'null',onclick:'alert("All");'},{},'All'));newsBox.head.appendChild(res);newsBox.tail=elem('div',{className:'itemBoxTail'},{},'');newsBox.tail.appendChild(elem('div',{className:'backButton',title:'Go back one page',onclick:'newsBox.lastPage()'},{},''));newsBox.tail.appendChild(elem('div',{className:'forwardButton',title:'Go to next page',onclick:'newsBox.nextPage()'},{},''));newsBox.tail.appendChild(document.createElement('br'));newsBox.itemBoxDiv.appendChild(newsBox.head);newsBox.itemBoxDiv.appendChild(newsBox.content);newsBox.itemBoxDiv.appendChild(newsBox.tail);},loadItems:function(page)
{try{ajaxObj=new sack('load.php');}catch(e){alert('You need to include the AJAX(SACK) js file');return;}
ajaxObj.setVar('action','blog');ajaxObj.setVar('page',newsBox.page-1);ajaxObj.setVar('pageSize',newsBox.pageSize);ajaxObj.onLoading=function(){newsBox.content.appendChild(elem('img',{src:'images/icons/loading.gif',alt:'Loading...'},{},''));};ajaxObj.onCompletion=function()
{if(!ajaxObj.response){alert("loadItems(): No response from server");return;}
var itemObj=[];var i,j,pos=0;var textPtr=ajaxObj.response;for(i=0;i<newsBox.pageSize;i++)
{for(j=0;j<4;j++){textPtr=textPtr.substring(pos+2);pos=textPtr.indexOf('::');itemObj[j]=textPtr.substring(0,pos);}
if(textPtr.indexOf('::')<0)break;debug('&raquo; <a href="#">'+itemObj[2]+'</a>');newsBox.showItem(newsBox.addItem(itemObj[2],itemObj[1],itemObj[0],itemObj[3]));}
resize_sidebar();}
ajaxObj.runAJAX();},loadTheme:function(theme)
{if(!newsBox.themes[theme])
{try{ajaxObj=new sack('load.php');}catch(e){alert('You need to include the AJAX(SACK) js file');return;}
ajaxObj.setVar('action','theme');ajaxObj.setVar('theme',theme);ajaxObj.onCompletion=function()
{if(ajaxObj.response)
{newsBox.themes[theme]=ajaxObj.response;applyTheme(ajaxObj.response);}
else alert("loadTheme(): No response from server");}
ajaxObj.runAJAX();}
else{newsBox.applyTheme(theme);}},applyTheme:function(theme)
{var newStyle=newsBox.themes[theme];if(typeof PRO_addStyle!='undefined')PRO_addStyle(newStyle,document);else if(typeof GM_addStyle!='undefined')GM_addStyle(newStyle);else if(typeof document.createStyleSheet!='undefined')
{newsBox.stylesheet=document.createStyleSheet();newStyle=newStyle.replace(/;/g," !important;");var styles=newStyle.split(/}/);for(var i=0;i<styles.length;i++)
{var rule=styles[i].split(/{/);newsBox.stylesheet.addRule(rule[0],rule[1]);}}else
{try{newsBox.stylesheet=document.createElement('style');newsBox.stylesheet.setAttribute('type','text/css');newsBox.stylesheet.innerHTML=newStyle;document.getElementsByTagName('head')[0].appendChild(newsBox.stylesheet);}catch(e){var warning=elem('div',{className:'warning'},{},'This browser does not support appending CSS styles!\nThis page uses AJAX to append CSS to the items... Please use another browser or just enable javascript to see the page in its fullest.');newsBox.itemBoxDiv.appendChild(warning);}}},addItem:function(headline,author,date,content)
{var index=newsBox.items.length;newsBox.items[index]=new Array();var newItem=newsBox.items[index];newItem['headline']=headline;newItem['author']=author;newItem['date']=date;newItem['content']=content;return newItem;},deleteItem:function(index)
{return newsBox.items.splice(index,1);},httpReq:function(file)
{var http=(typeof XMLHttpRequest!='undefined'?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP'));http.open('GET',file,false);http.send(null);if(http.status!=200||http.readyState!=4)
alert('Error '+http.status+' ('+http.statusText+') trying to apply new page content');return http.responseText;},showItems:function(start,end)
{if((end-start)<1)return;newsBox.content.innerHTML='';if(!newsBox.items[end])
{var page=parseInt(newsBox.page)-1;var pageSize=end-start;var textPtr=newsBox.httpReq('load.php?action=blogBetween&start='+start+'&end='+end);var itemObj=[];var i,j,pos=0;for(i=0;i<(end-start);i++)
{for(j=0;j<4;j++){textPtr=textPtr.substring(pos+2);pos=textPtr.indexOf('::');itemObj[j]=textPtr.substring(0,pos);}
if(textPtr.indexOf('::')<0)break;debug('&raquo; <a href="#">'+itemObj[2]+'</a>');newsBox.showItem(newsBox.addItem(itemObj[2],itemObj[1],itemObj[0],itemObj[3]));resize_sidebar();<div class="search"><form id="search_form"method="post"action="Search"onsubmit="alert('searching for '+document.getElementById('search').value);"><input name="search"type="text"class="search"id="search"title="Enter your searchword"value="Search"onclick="if (this.value=='Search') this.value='';"onblur="if (this.value=='') this.value='Search';"/></form></div>}}
else
{for(var i=start;i<=end;i++)
newsBox.showItem(newsBox.items[i]);}},showItem:function(item)
{var headline=item['headline'];var author=item['author'];var dateText=item['date'];var content=item['content'];var itemBox,itemContent;itemBox=elem('div',{className:'itemBox'},{},'');itemBox.appendChild(elem('span',{className:'dato'},{},dateText));itemBox.appendChild(elem('h2',{},{},headline));itemBox.appendChild(elem('span',{className:'author'},{},'by '+author));itemContent=elem('div',{className:'content'},{},'');itemContent.innerHTML=content;itemBox.appendChild(itemContent);newsBox.content.appendChild(itemBox);if(newsBox.maxHeight){itemContent.style.height=newsBox.maxHeight+'px';var unhide=elem('div',{className:'unhide'},{},'Show the rest...');unhide.onclick=function(){this.on=!this.on;itemContent.style.height=(this.on)?'auto':newsBox.maxHeight+'px';this.innerHTML=(this.on)?'Hide':'Unhide';}
itemBox.appendChild(unhide);}
return itemBox;},searchText:function(text,fields)
{var fieldsLen=fields.length;var len=newsBox.items.length;var results=new Array();for(var i=0;i<len;i++)
for(var j=0;j<fieldsLen;j++)
if(newsBox.items[i][fields[j]].search(text)>0)
results.push(newsBox.items[i]);return results;},sortBy:function(sorting)
{alert("Sorting by "+sorting);}}