function d()
{ return document;
}

function e(id)
{ return document.getElementById(id) || null;
}

function v(id)
{ var o = e(id);
  if(o)return o.value;
  return false;
}

function $g(o,a)
{ try
  { return typeof o=='object'?o.getAttribute(a):e(o).getAttribute(a);
  }
  catch(err){}
  return false;
}

function is(t)
{ return navigator.userAgent.toLowerCase().indexOf(t)>-1; 
}

function stop_event(e)
{ if(browser.msie)
  { e = window.event;
    e.cancelBubble = true;
    e.returnValue = false;
  }
  else
  { e.preventDefault();
    e.stopPropagation();
  }
  return false;
}

function add_event(element, event_name, func)
{ if(element.attachEvent)element.attachEvent("on" + event_name, func);
  else if(element.addEventListener)element.addEventListener(event_name, func, true);
  else element["on" + event_name] = func;
}

function remove_event(element, event_name, func)
{ if(element.detachEvent)element.detachEvent("on" + event_name, func);
  else if(element.removeEventListener)element.removeEventListener(event_name, func, true);
  else element["on" + event_name] = null;
}

function create_event(element, event_name)
{ if(is("msie"))
  { var e = document.createEventObject();
    return element.fireEvent("on" + event_name, e);
  }
  else
  { var e = document.createEvent("HTMLEvents");
    e.initEvent(event_name, true, true);
    return !element.dispatchEvent(e);
  }
}

function getElement(e)
{ return (e&&e.target)||(event&&event.srcElement);
}

function link(url)
{ location=url;
}

function pngfix()
{ var x = document.getElementsByTagName("img");
  if(!x)return;
  for(var i=0;i<x.length;i++)
  { if(x[i].rel=="png")
    { x[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+x[i].src+'", sizingMethod="scale");';
      x[i].src='images/blank.gif';
    }
  }
}

function initSys()
{ if(is("msie 6")||is("msie 5"))pngfix();
  swfobject.embedSWF("images/authentic.swf", "authentic-flash", "430", "219", "9.0.0", "expressInstall.swf", {}, {wmode:"transparent"}, {});
}

function preg_match(v,r)
{ switch(r)
  { case "i":
      return v.match(/^\d{1,}$/);
    break;
    case "f":
      return v.match(/^\d{1,}(\.(\d{1,})+)*$/);
    break;
    case "s":
      return v.match(/^[\w\"\'\s]+$/);
    break;
  }
}

function x_delreport(i)
{ sajax("user","x_delreport","msg",i,function(r){r=r.split("|");if(confirm(r[0]))sajax("user","x_delreport","action",r[1],function(r){alert(r);location.reload()});});
}

function x_delfolder(i)
{ sajax("folder","x_delfolder","msg",i,function(r){r=r.split("|");if(confirm(r[0]))sajax("folder","x_delfolder","action",r[1],function(r){alert(r);location.reload()});});
}

function x_newfolder()
{ var x = window.prompt('Enter name for the new folder:','new folder');
  if(x.length)sajax("folder","x_newfolder",x,function(r){location.reload()});else alert("You don't enter anyone symbol!");
}

function x_renamefolder(i)
{ var x = window.prompt('Enter new name for folder:','new name folder');
  if(x.length)sajax("folder","x_renamefolder",i,x,function(r){location.reload()});else alert("You don't enter anyone symbol!");
}

function x_analyze11()
{ sajax('user','x_analyze','',function(r)
  { if(r.length>0)
    { r = r.split('#');
      switch(r[0])
      { case 'value':
          e('analyze-status').style.width = (r[1]>0?r[1]*2-1:0)+'px';
          x_analyze();
        break;
        case 'url':
          location.href = r[1];
        break;
      }
    }
  });
}


function x_analyze(v)
{ sajax('user','x_analyze',v,function(r)
  { if(r.length>0)
    { r = r.split('#');
      switch(r[0])
      { case 'value':
          e('analyze-status').style.width = (r[1]>0?r[1]*2-1:0)+'px';
          x_analyze('');
        break;
        case 'sub_search':
          x_analyze(r[1]);
        break;
        case 'url':
          location.href = r[1];
        break;
      }
    }
  });
}


function sac(z)
{ var x = e('cac').getElementsByTagName("input");
  if(!x)return;
  for(var i=0;i<x.length;i++)
  { if(x[i].value>0&&$g(x[i],'type')=='checkbox')x[i].checked=z.checked;
  }
}

function txtorfile(o,t)
{ e('t-'+o.rel).style.display = 'block';
  o.style.textDecoration = 'none';
  e('t-'+t).style.display = 'none';
  e('l-'+t).style.textDecoration = 'underline';
}

function highlight(o)
{ var x = e('found-text').getElementsByTagName('a');
  if(!x)return;
  for(var i=0;i<x.length;i++)
  { if(x[i].href==o.href&&x[i].rel=="highlight")
    { if(x[i].className!='c0')
      { x[i].title = x[i].className;
        x[i].className = 'c0';
      }
      else
      { x[i].className = x[i].title;
        x[i].title = '';
      }
    }
  }
  return false;
}

// START OF MESSAGE SCRIPT //

var MSGTIMER = 20;
var MSGSPEED = 5;
var MSGOFFSET = 3;
var MSGHIDE = 3;

function inlineMsg(target,string,autohide) {
  var msg;
  var msgcontent;
  if(!document.getElementById('tt2msg')) {
    msg = document.createElement('div');
    msg.id = 'tt2msg';
    msgcontent = document.createElement('div');
    msgcontent.id = 'msgcontent';
    document.body.appendChild(msg);
    msg.appendChild(msgcontent);
    msg.style.filter = 'alpha(opacity=0)';
    msg.style.opacity = 0;
    msg.alpha = 0;
  } else {
    msg = document.getElementById('tt2msg');
    msgcontent = document.getElementById('msgcontent');
  }
  msgcontent.innerHTML = string;
  msg.style.display = 'block';
  var msgheight = msg.offsetHeight;
  var targetdiv = document.getElementById(target);
  targetdiv.focus();
  var targetheight = targetdiv.offsetHeight;
  var targetwidth = targetdiv.offsetWidth;
  var topposition = topPosition(targetdiv) - ((msgheight - targetheight) / 2);
  var leftposition = leftPosition(targetdiv) + targetwidth + MSGOFFSET;
  msg.style.top = topposition + 'px';
  msg.style.left = leftposition + 'px';
  clearInterval(msg.timer);
  msg.timer = setInterval("fadeMsg(1)", MSGTIMER);
  if(!autohide) {
    autohide = MSGHIDE;  
  }
  window.setTimeout("hideMsg()", (autohide * 1000));
}

function hideMsg(msg) {
  var msg = document.getElementById('tt2msg');
  if(!msg.timer) {
    msg.timer = setInterval("fadeMsg(0)", MSGTIMER);
  }
}

function fadeMsg(flag) {
  if(flag == null) {
    flag = 1;
  }
  var msg = document.getElementById('tt2msg');
  var value;
  if(flag == 1) {
    value = msg.alpha + MSGSPEED;
  } else {
    value = msg.alpha - MSGSPEED;
  }
  msg.alpha = value;
  msg.style.opacity = (value / 100);
  msg.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(msg.timer);
    msg.timer = null;
  } else if(value <= 1) {
    msg.style.display = "none";
    clearInterval(msg.timer);
  }
}

function leftPosition(target) {
  var left = 0;
  if(target.offsetParent) {
    while(1) {
      left += target.offsetLeft;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.x) {
    left += target.x;
  }
  return left;
}

function topPosition(target) {
  var top = 0;
  if(target.offsetParent) {
    while(1) {
      top += target.offsetTop;
      if(!target.offsetParent) {
        break;
      }
      target = target.offsetParent;
    }
  } else if(target.y) {
    top += target.y;
  }
  return top;
}

if(document.images) {
  arrow = new Image(7,80); 
  arrow.src = "images/msg_arrow.gif"; 
}

function live_chat(chats)
{
 var me = this, active = [], load_listeners = [], update_listeners = [];
 
 this.online = function()
 {
  return active.length;
 }
 
 this.open = function(n)
 {
  if (typeof n == "undefined")
   n = active.length ? active[0] : 0;
  if (chats[n])
   window["ps" + chats[n].id + "ow"]();
 }
 
 this.open_random = function()
 {
  var n;
  if (arguments.length)
  {
   for (var i = 0; i < arguments.length; i++)
    if ((i + 1) in active && Math.random() * 100 <= arguments[i])
     n = i + 1;
  }
  else if (active.length)
   n = active[Math.floor(Math.random() * (active.length + 1))];
  me.open(n);
 }
 
 this.onload = function(f)
 {
  if (typeof f != "function") return
  for (var i in load_listeners)
   if (load_listeners[i] == f) return;
  load_listeners.push(f);
  if (active.length) f(chats, active);
 }
 
 this.onupdate = function(f)
 {
  if (typeof f != "function") return
  for (var i in update_listeners)
   if (update_listeners[i] == f) return;
  update_listeners.push(f);
  //if (active.length) f(chats, active);
 }
 
 this.remove = function(f)
 {
  for (var i in load_listeners)
   if (load_listeners[i] == f)
    load_listeners.splice(i, 1);
  for (var i in update_listeners)
   if (update_listeners[i] == f)
    update_listeners.splice(i, 1);
 }
 
 this.status = function()
 {
  var loaded = false;
  for (var i in chats)
   if (typeof window["ps" + chats[i].id + "ol"] != "undefined")
    loaded = true;
  if (!loaded) return false;
  active = [];
  for (var i in chats)
   if (window["ps" + chats[i].id + "ol"])
    active.push(i);
  return true;
 }
 
 var checks = 0, checker = setInterval(function() {
  if (checks++ < 60 && !me.status()) return;
  clearTimeout(checker);
  for (var i in load_listeners)
   load_listeners[i](chats, active);
  setInterval(function() {
   var l = active.length;
   me.status();
   if (active.length != l)
    for (var i in update_listeners)
     update_listeners[i](chats, active);
  }, 10000);
 }, 1000);
}
