function trim(s) {
  return s.replace(/^\s+/,'').replace(/\s+$/,'');
}
function validEmail(s) {
  var re =/^[\w\.\-]+\@[\w\.\-]+\.[a-zA-Z]{2,4}$/;
  return re.test(s);
}
function setMax(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}
function popup(mylink, windowname) {
  if (! window.focus) return true;
  var href = (typeof(mylink) == 'string')?mylink:mylink.href;
  window.open(href, windowname, 'width=500,height=400,scrollbars=yes,resizable=yes');
  return false;
}
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;
}
