//
// Javascript utility functions
//
// Author: C. Bach
//
// Changes:
// 	Version: 1.1/28.11.01
//		Added support for InternetExplorer 5.0
//
// Description:
//	1.0:
//		Tested under Suse Linux 7.3 with Netscape/Mozilla/Konqueror
//	1.1:
//  	Tested under Windows 2000 with Internet Explorer 5.0


/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

var isMozilla, isIE, isNetscape, isKonqueror

isMozilla = false
isIE = false
isKonqueror = false
isNetscape = false

if (parseInt(navigator.appVersion) >= 4) {
  if (navigator.appName == "Konqueror") {
  	isKonqueror = true

  } else if (navigator.appName == "Netscape" && parseInt(navigator.appVersion)== 5) {
    isMozilla = true

  } else if (navigator.appName == "Microsoft Internet Explorer") {
    isIE = true

  } else {
  	isNetscape = true
  }

} else {
	alert(
  	"You can't use dynamic positioning with your browser!. (Version below 4)"
  )
}

function who() {
	if (isMozilla) {
  	return "Mozilla (Linux)"
  } else if (isIE) {
  	return "Internet Explorer"
  } else if (isKonqueror) {
  	return "Konqueror (Linux)"
  } else if (isNetscape) {
  	return "Netscape (Linux)"
  } else {
  	return "unknown"
  }
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function getInsideWindowHeight() {
  if (isKonqueror || isMozilla || isNetscape) {
    return window.innerHeight
  } else {
    return document.body.clientHeight
  }
}

function getInsideWindowWidth() {
  if (isKonqueror || isMozilla || isNetscape) {
    return window.innerWidth
  } else {
    return document.body.clientWidth
  }
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function getObjById(id) {
	if (isIE) {
  	return document.all[id]
  } else {
		return document.getElementById(''+id+'')
  }
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function getObjHeight(id) {
  return getObjById(id).offsetHeight
}

function getObjWidth(id) {
  return getObjById(id).offsetWidth
}

function getObjLeft(id) {
  return getObjById(id).offsetLeft
}

function getObjTop(id) {
    return getObjById(id).offsetTop
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function shiftTo(id, left, top) {
	var styleObj = getObjById(id).style
  styleObj.left = left
  styleObj.top = top
}

function shiftBy(id, deltaX, deltaY) {
 	shiftTo(id, getObjLeft(id)+deltaX, getObjTop(id)+deltaY)
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function getHTMLText(id) {
	return getObjById(id).innerHTML
}

function setHTMLText(id, htmltext) {
	return getObjById(id).innerHTML = htmltext
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */


function min(a, b) {
   return a < b ? a : b
}

function max(a, b) {
   return a > b ? a : b
}

function elts(obj) {
  var s = "Elements of " + obj.nodeName + "\n"
  var elt
	for(elt in obj) {
    s = s + elt +"; "
	}
	return s
}

function elts(obj) {
  var s = "Elements of " + obj.nodeName + "\n"
  var elt
	for(elt in obj) {
    s = s + elt +"; "
	}
	return s
}

function eltsHTML(obj) {
  var s = "<p>Elements of " + obj.nodeName + "</p><ul>"
  var elt
	for(elt in obj) {
    s = s + "<li>" + elt + "</li>"
	}
  s = s + "</ul>"
	return s
}

/* ****************************************************************** */
/* ****************************************************************** */
/* ****************************************************************** */

function alertHTML(msg) {
	alert("aH")
}
function xalertHTML(msg){

	var logWindow
	logWindow = window.open("", "logWindow", "")
  logWindow.document.write("<HTML><HEAD><TITLE>Log window</TITLE></HEAD>")
  logWindow.document.write("<BODY>" + msg + "</BODY></HTML>")
}


