var secs=0;
var scrollon=0;
var scmax=7;
function scroller_c() {
secs++;
if (secs==4) {
scroller_u(1);
}
setTimeout('scroller_c()', 1000);
}
function scroller_u(dir) {
secs=0;
if (dir==0) {
scrollon--;
}
else {
scrollon++;
}
if (scrollon<0) {
scrollon=scmax;
}
else if (scrollon>scmax) {
scrollon=0;
}
switch (scrollon) {
case 0:
sctxt="Latest Blog: 'Last FridayDay!', by Fireblast950";
sclink="/blogs/index.php?blogid=193";break;
case 1:
sctxt="We now have a Draynor Manor Location guide on the site";
sclink="/guides/index.php?id=327";break;
case 7:
sctxt="RuneRadio: DJ Lily B Allen - Now Playing \"Hammerfall - Heeding the call\""
sclink="/radio/";
break;case 2:
sctxt="Latest News: RuneScape - Latest Concept Art [VIDEO]";
sclink="/news.php?id=172";break;
case 3:
sctxt="Latest Poll: Friends chat";
sclink="/poll.php";break;
case 4:
sctxt="Latest Development Blog: Featuring...";
sclink="/blogs/index.php?blogid=70";break;
case 5:
sctxt="Bored in RuneScape? Join our Chat Channel, \"RuneZone\"!";
sclink="/runezonechat.php";
break;
case 6:
sctxt="Want to chat? Connect to our Teamspeak server! Host: <i>runezone.com</i>";
sclink="/teamspeak.php";
}
document.getElementById('scroller').innerHTML="<a href='" + sclink + "'>" + sctxt + "</a>";
}

fadingvar=0;
function msgfade() {
setTimeout("msgfadea()", 3500);
}
function msgfadea() {
if (fadingvar==0) {
fadingvar=1;
opacity('popup', 100, 0, 700);
}
}

chatnotif=0;
chaton=0;
chatloaded=0;
titlestore='';
titleflash=0;
function titleflashf(type) {
if (type==1) {
document.title=titlestore;
setTimeout('titleflashf()',1000);
}
else {
if (titleflash==1) {
titlestore=document.title;
document.title="New Message!";
setTimeout('titleflashf(1)',1000);
}
}
}

function showchat() {
titleflash=0;
if (statdivon==1) { showstatuses(); }
if (chaton==0) {
chaton=1;
chatnotif=0;
if (chatloaded==0) {
document.getElementById('cboxdiv').innerHTML="<iframe class='cboxframe' id='cboxframe' src='/chatbox/chatfr.php'></iframe>";
chatloaded=1;
}
document.getElementById('cboxdiv').style.display='block';
document.getElementById('cboxbut').style.background="url('/require/main/chaton.png')";
}
else {
chaton=0;
document.getElementById('cboxdiv').style.display='none';
document.getElementById('cboxbut').style.background="url('/require/main/chatbg.png')";
}
}

function chatnotify() {
if (chatnotif=='0' && chaton=='0') {
chatnotif=1;
document.getElementById('cboxbut').style.background="url('/require/main/chatactive.png')";
if (titleflash==0) {
titleflash=1;
titleflashf(0);
}
}
}

statdivon=0;
function showstatuses() {
if (chaton==1) { showchat(); }
if (statdivon==0) {
status_b_update();
statdivon=1;
document.getElementById('statdiv').style.display='block';
document.getElementById('statbut').style.background="url('/require/main/chaton.png')";
}
else {
statdivon=0;
document.getElementById('statdiv').style.display='none';
document.getElementById('statbut').style.background="url('/require/main/chatbg.png')";
}
}


function ajax_setup() {
var http_request=false;
try { http_request=new XMLHttpRequest(); } catch (e) {
 try { http_request=new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) {
  try { http_request=new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {
   alert('Your browser does not support AJAX!');
   http_request=false;
  }
 }
}
return http_request;
}
function $(elem) {
return document.getElementById(elem);
}
function friends_list_ref() {
http_request=ajax_setup();
http_request.onreadystatechange = function() {
if(http_request.readyState == 4 && http_request.status == 200) {
	document.getElementById('friendsdiv').innerHTML=http_request.responseText;
}
}
var chosen = '/members/flite.php';
http_request.open('GET', chosen, true);
http_request.send(null);
}

function opacity(id, opacStart, opacEnd, millisec) {
    var speed = Math.round(millisec / 100);
    var timer = 0;
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100); // Firefox, Safari etc.
    object.MozOpacity = (opacity / 100); // Old version of Mozilla.
    object.KhtmlOpacity = (opacity / 100); // Linux (Konqueror) and Safari's WebKit framework.
    object.filter = "alpha(style=0,opacity=" + opacity + ")"; // Internet Explorer 5.5+

	if(opacity == 0)
	{
		document.getElementById(id).style.display='none';
	}
}
function cont_tog(obj,id) {
	if (document.getElementById(id).style.display=="none") {
		obj.innerHTML='–'; 
		document.getElementById(id).style.display="block"; 
	} 
	else {
		obj.innerHTML='+'; 
		document.getElementById(id).style.display="none"; 
	} 
}
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
	} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}
function globsearch() {
obj = document.getElementById('globsearchbar')
if (obj.value!='') {
locs=findPos(obj);
boxes=document.getElementById('globsearchbox');
boxes.style.display='block';
boxes.style.position='absolute';
//boxes.style.right=(locs[0]-50) + 'px';
boxes.style.right='65px';
boxes.style.top=(locs[1]+16) + 'px';
globsearchreq(obj.value);
}
else {
globboxlive=false;
globhidebox();
}
}
globlastreq = new Date().getTime();
function globsearchreq(str) {

var http_request = false;
try
  {
  // Firefox, Opera 8.0+, Safari
  http_request=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    http_request=new ActiveXObject('Msxml2.XMLHTTP');
    }
  catch (e)
    {
    try
	{
      http_request=new ActiveXObject('Microsoft.XMLHTTP');
      }
    catch (e)
      {
      alert('Your browser does not support AJAX!');
      return false;
      }
    }
  }

http_request.onreadystatechange = function() {

if(http_request.readyState == 4 && http_request.status == 200) {
	if (globlastreq<=globthisreq) {
	document.getElementById('globsearchbox').innerHTML = http_request.responseText;
	}
}

}
globlastreq = new Date().getTime();
var globthisreq = new Date().getTime();
var chosen = '/require/slist.php?q=' + str;
http_request.open('GET', chosen, true);
http_request.send(null);
}
function globhidebox() {
globselitvar='null';
if (globboxlive==false) {
boxes=document.getElementById('globsearchbox');
boxes.style.display='none';
}
}
document.onkeydown=searchArrows;
function searchArrows(evt) {
evt = (evt) ? evt : ((window.event) ? event : null);
if (evt) {
if (document.getElementById('globsearchbox').style.display=='block') {
	switch (evt.keyCode) {
		case 38:
			globselit(0)
		break;      
		case 40:
			globselit(1)
		break;
		default:
			globselitvar='null';
		break;
	}
}
}
}
globselitvar='null';
origtext=null;
function globselit(dir) {
gsb=document.getElementById('globsearchbar')
list=document.getElementById('globslist');
if (globselitvar=='null') {
origtext=gsb.value;
}
length=list.childNodes.length-2;
if (dir==0) {
	if (globselitvar=='null') {
		globselitvar=length;
		sellistitem(globselitvar,1);
		gsb.value=list.childNodes[globselitvar].title;
	}
	else if (globselitvar==0) {
		sellistitem(globselitvar,0);
		globselitvar='null';
		gsb.value=origtext;
	}
	else {
		sellistitem(globselitvar,0);
		globselitvar=globselitvar-2;
		sellistitem(globselitvar,1);
		gsb.value=list.childNodes[globselitvar].title;
	}
}
else {
	if (globselitvar=='null') {
		globselitvar=0;
		sellistitem(globselitvar,1);
		gsb.value=list.childNodes[globselitvar].title;
	}
	else if (globselitvar==length) {
		sellistitem(globselitvar,0);
		globselitvar='null';
		gsb.value=origtext;
	}
	else {
		sellistitem(globselitvar,0);
		globselitvar=globselitvar+2;
		sellistitem(globselitvar,1);
		gsb.value=list.childNodes[globselitvar].title;
	}
}
document.getElementById('globval').value=globselitvar;
document.getElementById('length').value=length;
}
function sellistitem(id,type) {
list=document.getElementById('globslist');
if (type==1) {
list.childNodes[id].className='sel';
}
else {
list.childNodes[id].className='';
}
}

function status_b_update() {
var http_request = false;
try
  {
  // Firefox, Opera 8.0+, Safari
  http_request=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    http_request=new ActiveXObject('Msxml2.XMLHTTP');
    }
  catch (e)
    {
    try
	{
      http_request=new ActiveXObject('Microsoft.XMLHTTP');
      }
    catch (e)
      {
      alert('Your browser does not support AJAX!');
      return false;
      }
    }
  }

http_request.onreadystatechange = function() {

if(http_request.readyState == 4 && http_request.status == 200) {

	document.getElementById('statdiv').innerHTML=http_request.responseText;

}

}
var chosen = '/status/index.php?act=lite';
http_request.open('GET', chosen, true);
http_request.send(null);
}
function statusshowcom(id,arrstr) {
arr=arrstr.split(',');
for (a=0;a<arr.length;a++) {
if (arr[a]==id) { document.getElementById('l_stcb'+arr[a]).style.display='table'; document.getElementById('l_s_sc'+arr[a]).style.display='none'; }
else { document.getElementById('l_stcb'+arr[a]).style.display='none'; document.getElementById('l_s_sc'+arr[a]).style.display='block'; }
}
}
function statusparsemsg(str) {
	str=str.replace(/\\/g, '\\')
	str=str.replace(/\&#x00AD/g, '')
	str=str.replace(/&#173;/g, '')
	str=str.replace(/\&nbsp/g, ' ')
	str=str.replace(/\&shy/g, '')
	str=str.replace(/\&thinsp/g, '')
	str=str.replace(/\&/g, '&amp;')
	str=str.replace(/£/g, '&pound;')
	str=str.replace(/^0$/, ' 0')
	str=str.replace(/\s{2,}/, ' ')
	str=str.replace(/¬/g, '&not;');

	str=encodeURIComponent(str);
	return str;
}
function sb_tog(int) {
if (int==0) {
fgsb();
}
else {
rmsb();
}
}
function rmsb() {
cookieValue='1';
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000*24*365);
document.cookie = 'sbstat=' + escape(cookieValue) + ';expires=' + expire.toGMTString();
}
function fgsb() {
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime());
document.cookie = 'sbstat=;expires=' + expire.toGMTString();
}
