function reloadPage()   {
   if ("undefined" == typeof(POST) || !POST) {
      location.reload(true);
   }  else  {
      location.href = HOME;
   }
}

//jquery's substitute won't work in Opera
function getOffset(obj) {
   var t=0, l=0, el = obj;
   while(el)   {
      l += el.offsetLeft;
      t += el.offsetTop;
      el = el.offsetParent;
   }
   return {left: l, top: t };
}
/*
function getPositionLeft(This){
var el = This;var pL = 0;
while(el){pL+=el.offsetLeft;el=el.offsetParent;}
return pL
}

// To find the top position, add this snippet to your code:

function getPositionTop(This){
var el = This;var pT = 0;
while(el){pT+=el.offsetTop;el=el.offsetParent;}
return pT
}
*/

function getCommonArea(a, b)	{
	if (a.offsetLeft >= b.offsetLeft + b.offsetWidth) return 0;
	if (b.offsetLeft >= a.offsetLeft + a.offsetWidth) return 0;
	if (a.offsetTop >= b.offsetTop + b.offsetHeight) return 0;
	if (b.offsetTop >= a.offsetTop + a.offsetHeight) return 0;

	var dy = Math.min(a.offsetHeight, b.offsetHeight, a.offsetTop + a.offsetHeight - b.offsetTop, b.offsetTop + b.offsetHeight - a.offsetTop);
	var dx = Math.min(a.offsetWidth, b.offsetWidth, a.offsetLeft + a.offsetWidth - b.offsetLeft, b.offsetLeft + b.offsetWidth - a.offsetLeft);

	return dx*dy;
}

function getJQCommonArea(a, b)	{
   var a_offset = a.offset();
   var b_offset = b.offset();
   var a_w = a.width();
   var a_h = a.height();
   var b_w = b.width();
   var b_h = b.height();

	if (a_offset.left >= b_offset.left + b_w) return 0;
	if (b_offset.left >= a_offset.left + a_w) return 0;
	if (a_offset.top >= b_offset.top + b_h) return 0;
	if (b_offset.top >= a_offset.top + a_h) return 0;

	var dy = Math.min(a_h, b_h, a_offset.top + a_h - b_offset.top, b_offset.top + b_h - a_offset.top);
	var dx = Math.min(a_w, b_w, a_offset.left + a_w - b_offset.left, b_offset.left + b_w - a_offset.left);

	return dx*dy;
}

function getSquaredDistance(a, b)	{
   
   var ax = a.offsetLeft + a.offsetWidth/2;
   var ay = a.offsetTop + a.offsetHeight/2;
   var bx = b.offsetLeft + b.offsetWidth/2;
   var by = b.offsetTop + b.offsetHeight/2;

   return (ax - bx)*(ax - bx) + (ay - by)*(ay - by);
}

function xmlEncode(string) {
   return string.replace(/\&/g,'&amp;').replace(/\</g,'&lt;').replace(/\>/g,'&gt;').replace(/\'/g,'&apos;').replace(/\"/g,'&quot;');
}

function getObjectString(obj) {
   var s = "";
   for (var i in obj)   {
      s += ("<p>" + i + ": " + obj[i] + "</p>");
   }
   return s;
}