var dom = Boolean(document.getElementById) ? true : false;
var ns4 = Boolean(document.layers) ? true : false;
var ie = Boolean(document.all) ? true : false;
var ie4 = ie && !dom;

/* Returns the given object. */
function objGet(id) {
 if (dom){
   return document.getElementById(id);
 }
 else if (ie4){
   return eval('document.all.'+id);
 }
 else{
   return eval('document.'+id);
 }
}

/* Opens the given url in a new window. */
function targetBlank(url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
  return blankWin;
}

/* Opens a new window. */
function openWindow(url, width, height) {
  var scrHeight = screen.availHeight;
  var scrWidth = screen.availWidth;
  var leftPos = scrWidth/2 - width/2;
  var topPos = scrHeight/2 - height/2 - 100;
  
  newWindow = window.open(url,"Map","width="+width+",height="+height+",left="+leftPos+",top="+topPos+",directories=no,status=yes,scrollbars=no,resizable=no,menubar=no");
  if(newWindow.focus != null){
    newWindow.focus();
  }
}

function openImgWindow(url){
  openWindow(url, 650, 650);
}

/* Shows the floating hint.*/
function showFloatingHint(e, invoker){
  if(document.all) e = event;
	var obj = document.getElementById('floatingHint');
	obj.innerHTML = invoker.alt;
	obj.style.display = 'block';
	var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
	if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
	var leftPos = e.clientX;
	if(leftPos<0)leftPos = 0;
	obj.style.left = leftPos + 'px';
	obj.style.top = e.clientY - obj.offsetHeight -1 + st + 'px';
}


/* Hides the floating hint.*/
function hideFloatingHint(){
  document.getElementById('floatingHint').style.display = 'none';
}

/* Trims a string. */
function trim(sString){
  while (sString.substring(0,1) == ' '){
    sString = sString.substring(1, sString.length);
  }
  while (sString.substring(sString.length-1, sString.length) == ' '){
    sString = sString.substring(0,sString.length-1);
  }
  
  return sString;
}


