// here we define global variable
var ajaxdestination="";

function getdata(what,where,txt) { // get data from source (what)
 try {
   xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 ajaxdestination=where;
 xmlhttp.onreadystatechange = triggered; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("POST", what, true);
 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 xmlhttp.send("szoveg="+txt);
  return false;
}

function triggered() { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200)
    document.getElementById(ajaxdestination).innerHTML =xmlhttp.responseText;
}

function flipflop(what) {
  var e = document.getElementById(what);
  if (e.style.display=='none') {
    e.style.display='block';
  } else {
    e.style.display='none';
  }
  return false;
}

function addformat(f) {
  var txt = document.getElementById('txt');
  var bbo = new Array();
  var bbc = new Array();
  bbo['b']='[b]'; bbc['b']='[/b]';
  bbo['i']='[i]'; bbc['i']='[/i]';
  bbo['u']='[u]'; bbc['u']='[/u]';

  bbo['left']='[align=left]'; bbc['left']='[/align]';
  bbo['center']='[align=center]'; bbc['center']='[/align]';
  bbo['right']='[align=right]'; bbc['right']='[/align]';

  bbo['a']='[url]'; bbc['a']='[/url]';
  bbo['mail']='[mail]'; bbc['mail']='[/mail]';
  bbo['img']='[img]'; bbc['img']='[/img]';

  bbo['codearea']='[codearea]'; bbc['codearea']='[/codearea]';
  txt.focus();
  var range = document.selection.createRange();
  range.text = bbo[f] + range.text + bbc[f];

}


   function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    }
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX +
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY +
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

       function show(id){
         var kurz;
         kurz = getPosition();
         document.getElementById(id).style.top = kurz.y+20;
         document.getElementById(id).style.left = kurz.x+20;
         document.getElementById(id).style.display = 'block';
       }

       function disable(id){
         document.getElementById(id).style.display = 'none';
       }


var m_iInterval;
var m_Height;
//window.onload = wl;
var iScroll=0;

var arrTitles;

var arrCursor = 0;

var arrMax;
window.onload=wl;

function wl() {
  m_iInterval = setInterval(ontimer, 10);
  var base = document.getElementById("jump_base");

  m_Height = base.offsetHeight;

  var divi = parseInt(m_Height/5);
  m_Height = divi*5;

  var td1 = document.getElementById("td1");
  var td2 = document.getElementById("td2");
  var td3 = document.getElementById("td3");
  td1.height = m_Height-5;
  td2.height = m_Height-5;
  td3.height = m_Height-5;

  arrLinks = new Array();
  arrTitles = new Array();

  setupLinks();
  setLink(arrCursor);
}

function setLink(arrCursor) {
  var ilink = document.getElementById("jump_link");
  ilink.innerHTML = arrTitles[arrCursor];
}

function ontimer() {
  var base = document.getElementById("jump_base");
  iScroll+=2;
  if (iScroll>(m_Height*2)) {
    iScroll=0;
    arrCursor++;
    if (arrCursor>arrMax)
      arrCursor=0;
    setLink(arrCursor);
  }
  if (iScroll==m_Height) {
    pause();
    m_iInterval = setTimeout(resume, 3000);
  }
  base.scrollTop=iScroll;
}


function pause() {
  clearInterval(m_iInterval);
}

function resume() {
  m_iInterval = setInterval(ontimer, 10);
}