var _debug_app = false;
/* log message in the debug div */
function LogMessage(msg) {
	if ( _debug_app ) {
		var o = document.getElementById('div_log_id');
		if ( o != null ) o.innerHTML += msg+"<br>";
	}
}
function LogClear() {
	if ( _debug_app ) {
		var o = document.getElementById('div_log_id');
		if ( o != null ) o.innerHTML = "";
	}
}

/* find absolute position of objects */
function FindPosX(obj)
{
var curleft = 0;
if(obj.offsetParent)
    while(1) 
    {
      curleft += obj.offsetLeft;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
else if(obj.x)
    curleft += obj.x;
return curleft;
}

function FindPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
    while(1)
    {
      curtop += obj.offsetTop;
      if(!obj.offsetParent)
        break;
      obj = obj.offsetParent;
    }
else if(obj.y)
    curtop += obj.y;
return curtop;
}

/* Strip whitespace from the beginning and end of a string */
if (typeof String.prototype.trim == "undefined") {
    String.prototype.trim = function () {
        var s = this.replace(/^\s*/, "");
        return s.replace(/\s*$/, "");
    }
}
/* Count the number of substring occurrences */
if (typeof String.prototype.substrCount == "undefined") {
    String.prototype.substrCount = function (s) {
        return this.split(s).length - 1;
    }
}
String.prototype.isAlpha = function () {
    return (this >= 'a' && this <= 'z\uffff') || (this >= 'A' && this <= 'Z\uffff');
}
String.prototype.isDigit = function () {
    return (this  >= '0' && this  <= '9');
}

function getobj(id) {
  return document.getElementById(id);
}

// browser detection
var _is_MSIE = false;
var _is_MSIE_6_OR_LESS = false;
var _is_GECKO = false;
var _is_OPERA = false;
var _is_SAFARI = false;
var _is_KONQUEROR = false;
if ( navigator.userAgent.indexOf("MSIE") >= 0 ){
  _is_MSIE = true;
  if (window.XMLHttpRequest) {
     _is_MSIE_6_OR_LESS = false;
  } else {
	 _is_MSIE_6_OR_LESS = true;
  }
} else if ( navigator.userAgent.indexOf("Opera") >= 0 ) {
  _is_OPERA = true;
} else if ( navigator.userAgent.indexOf("Safari") >= 0 ) {
  _is_SAFARI = true;
} else if ( navigator.userAgent.indexOf("Gecko") >= 0 ) {
  _is_GECKO = true;
} else if ( navigator.userAgent.indexOf("KHTML") >= 0 ) {
  _is_KONQUEROR = true;
}

// get the opacity of an object, browser independent
function GetOpacity(o) {
  try { 
      if ( _is_MSIE ) {
        return o.filters.alpha.opacity;
      } else if ( _is_GECKO ) {
        return o.style.MozOpacity * 100;
      } else if ( _is_OPERA ) {
        return o.style.opacity * 100;
      } else if ( _is_KONQUEROR || _is_SAFARI ) {
        return o.style.KhtmlOpacity * 100; 
	  } else {
        return o.style.opacity * 100;
      }
  }
  catch ( error ) {
    return 100;
  }  
}

// set the opacity of an object, browser independent
function SetOpacityById(objId, percent) {
	var o = getobj(objId);
	if ( o != null ) {
		SetOpacity(o,percent);
	}	
}

// set the opacity of an object, browser independent
function SetOpacity(o, percent) {
  var mozpercent = percent/100;
  try { 
      if ( _is_MSIE ) {
        o.filters.alpha.opacity = percent;
      } else if ( _is_GECKO ) {
        o.style.MozOpacity = mozpercent;
      } else if ( _is_OPERA ) {
        o.style.opacity = mozpercent;
      } else if ( _is_KONQUEROR || _is_SAFARI) {
        o.style.KhtmlOpacity = mozpercent; 
      } else {
        o.style.opacity = mozpercent;
      }
  }
  catch ( error ) {
  }  
}