﻿function $(elementid) {
	if (document.getElementById)
		return document.getElementById(elementid);
	else if (document.all)
		return document.all[elementid];
	else if (document.layers)
		return document.layers[elementid];
	else
		return false;
}

function getAbsolutePosition(obj) {
	var result = new Array(2);
	result[0] = obj.offsetTop;
	result[1] = obj.offsetLeft;
	while (obj = obj.offsetParent) {
		result[0] += obj.offsetTop;
		result[1] += obj.offsetLeft;
	}
	return result;
}

String.prototype.trim = function () {
	return this.replace(/^\s*|\s*$/g,"");
}

String.prototype.convertSpace = function () {
	return this.replace(/\s/g,"&nbsp;");
}

function IsNull(str)
{
  return (str.replace(/(^\s*)|(\s*$)/g, "")=="");
}

function IsEmail(str)
{
	var reg_email =/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	return reg_email.test(str)
}