function divOn(hid) {
  var p = document.getElementById(hid)
  if (p.style.display=='none') {
    p.style.display='';
    p.style.visibility='visible';
  }
  return;
}
function divOff(hid, modal) {
  divOnActive = null;
  var p = document.getElementById(hid)
  if (p.style.display!='none') {
    p.style.display='none';
    p.style.visibility='hidden';
  }
  if (modal) {
    document.getElementById('disablingDiv').style.display='none';
  }
  return;
}
function divOnCenter(hid, modal) {
  var p = document.getElementById(hid);
  var width = getWidth(p);
  var height = getHeight(p);
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var top = (myHeight - height) / 2;
  var left = (myWidth - width) / 2;
  if (top<0) top = 100;
  if (left<0) left = 100;
  p.style.left = left;
  p.style.top = top;
  if (modal) {
    p.style.zIndex = "1002";
    try {
    var pageWidth = document.body.offsetWidth;
    var pageHeight = document.body.offsetHeight;
		var min_w = 1024;
		pageWidth = pageWidth < min_w ? min_w : pageWidth;
		document.getElementById('disablingDiv').style.height = pageHeight+"px";
		document.getElementById('disablingDiv').style.width = pageWidth+"px";
    } catch(e2) {}
		document.getElementById('disablingDiv').style.display='block';
  }
  if (p.style.display=='none') {
    p.style.display='';
    p.style.visibility='visible';
  }
  return;
}
function getWidth(obj) {
  myWidth = 0;
  if( obj.clientWidth || obj.clientHeight ) {
    myWidth = obj.clientWidth;
  } else {
    if (obj.style.width) {
      myWidth = obj.style.width.substring(0,obj.style.width.length-2);
    }
  }
  return myWidth;
}
function getHeight(obj) {
  myHeight = 0;
  if( obj.clientWidth || obj.clientHeight ) {
    myHeight = obj.clientHeight;
  } else {
    if (obj.style.height) {
      myHeight = obj.style.height.substring(0,obj.style.height.length-2);
    }
  } 
  return myHeight;
}

//hova, mit, x,y
function divOnToObj(g,hid,dx,dy) {
  var p = document.getElementById(hid)
  if (p&&p.style.display=='none') {
  if (g!=null) {
    p.style.left=findPosX(g)+dx;
    p.style.top=findPosY(g)+dy;
    p.style.display='';
    p.style.visibility='visible';
  }
  }
  return;
}
function divOnTo(gid,hid,dx,dy) {
  var g = document.getElementById(gid);
  if (g==null) g = document.getElementsByName(gid)[0];
  divOnToObj(g,hid,dx,dy)
  return;
}
function divOnToDelay(gid,hid,dx,dy,wt) {
  if (divOnActive) divOff(divOnActive)
  divOnActive = hid;
  setTimeout("divOnTo('"+gid+"','"+hid+"',"+dx+","+dy+")", wt);
  return;
}
function divOffWaiting(p) {
  if (p.style.display=='') {
    p.style.display='none';
    p.style.visibility='hidden';
  }
  return;
}
function divOnAndClose(hid) {
  var p = document.getElementById(hid)
  if (p.style.display=='none') {
    p.style.display='';
    p.style.visibility='visible';
  }
  eval('setTimeout(\'divOff(' + hid + ')\',' + 5000 + ')');
}

function findPosX(obj){
  var curleft = 0;
  if (obj.offsetParent){
    while (obj.offsetParent){
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}
function findPosY(obj){
  var curtop = 0;
  if (obj.offsetParent) {
    while (obj.offsetParent){
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
    curtop += obj.y;
  return curtop;
}
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

