function tabClick(a){
	var li_s = a.parentNode.parentNode.parentNode.getElementsByTagName('li');
	for(var i=0; i<li_s.length; i++)
		li_s[i].id = "";
	a.parentNode.parentNode.id = "active";
	loadTab(a.getAttribute('href'));
	return false;
}
function loadTab(url){
	var req = new ajaxEngine();
	req.url = url;
	req.readyState1 = function(){
		tabsLoading.style.display = "block";
		tabsContent.style.display = "none";
	};
	req.readyState4 = function(){
		rssParser((req.getXML()),'tabsContent');
		tabsLoading.style.display = "none";
		tabsContent.style.display = "block";
	};
	req.run();
}
function rssParser(rss,id){
  var items=rss.getElementsByTagName("item"), re="";
  for(var i=0;i<items.length;i++){
    var item=items.item(i);
    var child=firstChild(item);
    while(child){
      var tname=child.tagName;
      if(tname=="title")title=dataOf(firstChild(child));
      if(tname=="link")link=dataOf(firstChild(child));
      child=nextNode(child);
    }
    re += '<li><a href="'+ link +'" target=_blank>'+ title +'</a></li>';
  }
  document.getElementById(id).innerHTML = "<un>"+ re +"</un>";
}
var txtLines = Array();
function addLines(){
	var a = document.getElementById('Facilities').innerHTML.split(/<br>|<br\/>/i);
	for(var i=0; i<a.length; i++)
		txtLines.push(a[i]);
}
function contentMaker(key){
   key = (key>txtLines.length-1)?key%txtLines.length:key;
   var lines = Array();
   for(var i=0; i<6;i++){
      key = (txtLines[key])?key:0;
      lines.push('&bull;&nbsp;'+txtLines[key]);
      key++;
   }
   Facilities.innerHTML = lines.join("<br/>");
   Facilities.scrollTop = 0;
}
function scrollText(key){
   contentMaker(key);
   _down(0)
   window.setTimeout('scrollText('+(key+1)+');',6000);
}
function _down(times){
  Facilities.scrollTop = Facilities.scrollTop+1;
  if(parseInt(Facilities.style.lineHeight)>times)
     window.setTimeout('_down('+(times+1)+')',20);
}
function is_all_ws( nod ){
  return !(/[^\t\n\r ]/.test(nod.data));
}

function isIgnorable( nod ){
  return ( nod.nodeType == 8) || // A comment node
         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}
function firstChild( par ){
  var res=par.firstChild;
  while (res) {
    if (!isIgnorable(res)) return res;
    res = res.nextSibling;
  }
  return null;
}
function dataOf( txt ){
  var data = txt.data;
  data = data.replace(/[\t\n\r ]+/g, " ");
  if (data.charAt(0) == " ")
    data = data.substring(1, data.length);
  if (data.charAt(data.length - 1) == " ")
    data = data.substring(0, data.length - 1);
  return data;
}
function nextNode( sib ){
  while ((sib = sib.nextSibling)) {
    if (!isIgnorable(sib)) return sib;
  }
  return null;
}
function login(){
   var re = new ajaxEngine();
   re.url = "login-ajax.php";
   re.makeQuery("username",document.loginForm.username.value,"password",document.loginForm.password.value,"rememberme",document.loginForm.rememberme.value);
   document.getElementById("login").innerHTML = document.getElementById("login-text").innerHTML;
   re.readyState4 = function(){
      var result = re.getText();
   document.getElementById("login").innerHTML=result;
   };
   re.run();
}
function logout(){
   var re = new ajaxEngine();
   re.url = "login-ajax.php";
   re.makeQuery("task","logout");
   document.getElementById("login").innerHTML = document.getElementById("logout-text").innerHTML;
   re.readyState4 = function(){
      var result = re.getText();
   document.getElementById("login").innerHTML=result;
   };
   re.run();
}