function isNumber(value) {
  var regex = /^\d+$/;
  if(value.match(regex))
    return true;
  else
    return false;
}
function isNotNumber(value) {
  var regex = /^\d*$/;
  if(!value.match(regex))
    return true;
  else
    return false;
}
function isNotEmpty(value) {
  var regex = /.+/;
  if(value.match(regex))
    return true;
  else
    return false;
}
function isEmpty(value) {
  var regex = /.+/;
  if(!value.match(regex))
    return true;
  else
    return false;
}
function validEmail(value) {
  var regex = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  if(!value.match(regex))
    return false;
  else
    return true;
}
function addLoadEvent(func) {
  var oldonload = window.onload;
  if(typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function setFocus() {
  if(document.getElementById('googleMap')) return false;
  if(document.getElementsByTagName("INPUT").length) {
    var inputs = document.getElementsByTagName("INPUT");
    for(i=0;i<inputs.length;i++) {
      if(inputs[i].type=="text") {
        inputs[i].focus();
	return true;
      }
    }
  }
}
addLoadEvent(setFocus);
function insertAfter(newNode, targetNode) {
  var parent = targetNode.parentNode;
  if (parent.lastChild == targetNode) {
    parent.appendChild(newNode);
  } else {
    parent.insertBefore(newNode, targetNode.nextSibling);
  }
}
function getClientDim() {
  if(window.innerWidth) {
    return [window.innerWidth, window.innerHeight];
  } else if(document.documentElement.clientWidth) {
    return [document.documentElement.clientWidth, document.documentElement.clientHeight];
  } else if(document.body.clientHeight) {
    return [document.body.clientWidth, document.body.clientHeight];
  }
}
function getObject(obj) {
  var theObj = getRawObject(obj);
  if (theObj)
    theObj = theObj.style;
  return theObj;
}
function getRawObject(obj) {
  var theObj;
  if (typeof obj == "string") {
    theObj = document.getElementById(obj);
  } else {
    // pass through object reference
    theObj = obj;
  }
  return theObj;
}
function show(obj) {
  var theObj = getObject(obj);
  if (theObj) {
    theObj.visibility = "visible";
  }
}
function hide(obj) {
  var theObj = getObject(obj);
  if (theObj) {
    theObj.visibility = "hidden";
  }
}
function shiftTo(obj, x, y) {
  var theObj = getObject(obj);
  if (theObj) {
    var units = (typeof theObj.left == "string") ? "px" : 0 
    theObj.left = x + units;
    theObj.top = y + units;
  }
}
function getElementPosition(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return {left:curleft, top:curtop};
}	
