var running = false
var updateTime = null
var timerMesg = null
var winwidth= window.screen.width
var winheight= window.screen.height
var browser = navigator.appName

function MouseMove(e){
    mouse_x=event.x+document.body.scrollLeft;
    mouse_y=event.y+document.body.scrollTop;
}

function CheckMouseMove() {
  document.onmousemove=MouseMove;
}
CheckMouseMove();

function click(e) {
  if (document.all) {
    if (event.button == 2) {
//      alert("Na tejto stránke nie je povolené vyvolať myšou kontextové menu!");
      return false;
    }
  }
  if (document.layers) {
    if (e.which == 3) {
//      alert(message);
      return false;
    }
  }
}

if (document.layers) {
  document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;



function checkcount(form,minstr) {
  str= form.text.value
  strlength= str.length
  if (strlength < minstr ) {
    alert("Napísali ste príliš krátky príspevok. Minimálna dĺžka príspevku je "+minstr+" znakov!");
  return false }
}

function countit(form,maxstr) {
  str= form.text.value
  strlength= str.length
  if (strlength > maxstr ) {
    alert("Text je príliš dlhý!");
    form.text.value=str.substring(0,maxstr);
    charleft = "!!!"; }
  else
    charleft = maxstr - strlength
    form.cntr1.value=charleft
    form.cntr2.value=strlength
}

// function HelpScreen(target) {
//   window.open(target,'Help','width=350,height=300,top=20,left=20,scrollbars=1'); }

// function PrintScreen(target) {
//   window.open(target,'Print','width=1,height=1,top=0,left=0,scrollbars=0'); }

// function InsertScreen(target) {
//   window.open(target,'Insert','width=640,height=480,top=0,left=0,scrollbars=1'); }

function NewScreen(url, name, width, height, scrolls) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  str += ",scrollbars=" + scrolls;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;
    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  return window.open(url, name, str);
}

function NewScreenModal(url,dialoghide,width,height,scroll) {
  var str = "dialogheight: "+(height+26)+"px;";
  str += "dialogwidth: "+(width+7)+"px;";
  str += "scroll: "+scroll+";";
  str += "help: no;";
  str += "status: no;";
  str += "dialoghide: "+dialoghide+";";
  return window.showModalDialog(url,"",str);
}

function ZavriOkno() {
  curPop.visibility="hidden";
  document.onmousemove=MouseMove; 
}

var curPop = null;
function clearCurrent() {
  if (null != curPop) {
    curPop.style.display = "";
    curPop = null; }
}

function popup() {
  clearCurrent();	  
  var el = event.srcElement;
  if (("P" == el.tagName) && ("menu" == el.parentElement.parentElement.parentElement.parentElement.id)) {
    var elpop = document.all[el.sourceIndex + 1];
    elpop.style.pixelLeft = el.parentElement.offsetLeft+90;
    elpop.style.pixelTop  = el.parentElement.offsetTop+68;
//    elpop.style.pixelLeft = mouse_x+20;
//    elpop.style.pixelTop  = mouse_y-10;
    elpop.style.display = "block";
    curPop = elpop;
  }
  event.cancelBubble = true;
}

function highlight() {
  if (null != event.fromElement)
    if ((event.fromElement.tagName == "P") && (event.fromElement.parentElement.parentElement.parentElement.parentElement.id == "menu")) {
      event.fromElement.className = ""; }
  if (null != event.toElement)
    if ((event.toElement.tagName == "P") && (event.toElement.parentElement.parentElement.parentElement.parentElement.id == "menu")) {
      popup();					
      event.toElement.className = "over";	}
}		

function ClearChatForm(form, param) {
  chat_form.text.value=chat_form.tmp_text.value;
  chat_form.tmp_text.value="";
  chat_form.tmp_text.focus();
}