function numbersonly(myfield, e) {
	var key;
	var keychar;

	if (window.event) {
		key = window.event.keyCode;
	} else if (e) {
		key = e.which;
	} else {
		return true;
	}

	keychar = String.fromCharCode(key);

	var xchar = "."; //**
	if (arguments[2] != undefined) {
		xchar = arguments[2];
	}

	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27)) {
		return true;
	} else if (((".0123456789"+xchar).indexOf(keychar)>-1)) {
		return true;
	} else {
		return false;
	}
}



function getScrollTop() {
	var sTop = 0;
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("firefox") != -1 || agt.indexOf("netscape") != -1 || agt.indexOf("msie") != -1) {
		sTop = document.documentElement.scrollTop;
	} else if (agt.indexOf("safari") != -1 || agt.indexOf("opera") != -1) {
		sTop = document.body.scrollTop;
	} else {
		sTop = 0;
	}
	return sTop;
}


function getBodyHeight() {
	var bHeight = "100%";
	if (window.innerHeight && window.scrollMaxY) {
		// Firefox
		bHeight = (window.innerHeight+window.scrollMaxY);
	} else if (document.body.scrollHeight>document.body.offsetHeight) {
		// all but Explorer Mac
		bHeight = document.body.scrollHeight;
	} else {
		// works in Explorer 6 Strict, Mozilla (not FF) and Safari
		bHeight = (document.body.offsetHeight+document.body.offsetTop);
	}
	return bHeight;
}


function getScreenSizeArr() {
	var xSize = 0;
	var ySize = 0;
	
	if (window.innerWidth && window.innerHeight) {
		xSize = window.innerWidth;
		ySize = window.innerHeight - 32;
	} else if (document.documentElement && document.documentElement.clientWidth && document.documentElement && document.documentElement.clientHeight) {
		xSize = document.documentElement.clientWidth;
		ySize = document.documentElement.clientHeight -32;
	} else if (document.body) {
		xSize = document.body.clientWidth;
		ySize = document.body.clientHeight -32;
	}
	
	var screenSizeArr = new Array(xSize, ySize);
	return screenSizeArr;
}



function getScreenWidth() {
	var xSize = 0;
	var ySize = 0;
	
	if (window.innerWidth) {
		xSize = window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth) {
		xSize = document.documentElement.clientWidth;
	} else if (document.body) {
		xSize = document.body.clientWidth;
	}
	
	return xSize;
}




function setHTML(id,str) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).innerHTML != undefined) {
			document.getElementById(id).innerHTML = str;
		}
	}
}


function setTxt(id,str) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).innerText != undefined) {
			document.getElementById(id).innerText = str;
		} else if (document.getElementById(id).textContent != undefined){
			document.getElementById(id).textContent = str;
		}
	}
}

function getTxt(id) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).innerText != undefined) {
			return document.getElementById(id).innerText;
		} else if (document.getElementById(id).textContent != undefined){
			return document.getElementById(id).textContent;
		}
	}
}



function findPos(obj, which) {
	var cur = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {

			if (which == "X") {
				cur += obj.offsetLeft;
			} else if (which == "Y") {
				cur += obj.offsetTop;

			}

			obj = obj.offsetParent;
		}
	} else {
		if (which == "X" && obj.x) {
			cur += obj.x;
		} else if (which == "Y" && obj.y) {
			cur += obj.y;
		}

	}

	return cur;
}


function mousePos(pos,e) {
	var posX = 0;
	var posY = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posX = e.pageX;
		posY = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posX = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posY = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posX and posY contain the mouse position relative to the document

	if (pos == "X") {
		return posX;
	} else if (pos == "Y") {
		return posY;
	}

}


function getWidth(obj) {

	if (obj.style.width.indexOf("%") != -1) {
		// if percentage
		var thisWidth = obj.offsetWidth;
	} else {
		// if style width in pixel
		var thisWidth = obj.style.width.substr(0,obj.style.width.length-2);
	}


	return parseFloat(thisWidth);
}

function getHeight(obj) {

	if (obj.style.height.indexOf("%") != -1) {
		// if percentage
		var thisHeight = obj.offsetHeight;
	} else {
		// if style width in pixel
		var thisHeight = obj.style.height.substr(0,obj.style.height.length-2);
	}


	return parseFloat(thisHeight);
}


function isIE7() {
 var agent = navigator.userAgent.toLowerCase();
 var major  = parseInt(navigator.appVersion);
 var ie7 = ((major ==  4) && (agent.indexOf("msie 7.0") != -1));
 return ie7;
}


function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}

function setTop() {
	var agt = navigator.userAgent.toLowerCase();
	if (agt.indexOf("firefox") != -1 || agt.indexOf("netscape") != -1 || agt.indexOf("msie") != -1) {
		document.documentElement.scrollTop = 0;
	} else if (agt.indexOf("safari") != -1 || agt.indexOf("opera") != -1) {
		document.body.scrollTop = 0;
	}
}


function mcolor(obj, bcol) {
	
	if (obj.className.indexOf('odd') != -1) {

		if (bcol == 'over') {
			obj.className = 'oddblue';
		} else if (bcol == 'out') {
			obj.className = 'odd';
		}

	} else if (obj.className.indexOf('even') != -1) {

		if (bcol == 'over') {
			obj.className = 'evenblue';
		} else if (bcol == 'out') {
			obj.className = 'even';
		}

	}
}
