
function getInternetExplorerVersion() {
	var rv = -1;
	if (navigator.appName == 'Microsoft Internet Explorer') {
	var ua = navigator.userAgent;
	var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	if (re.exec(ua) != null)
		rv = parseFloat( RegExp.$1 );
  }
  return rv;
}

function checkVersion() {
	var ver = getInternetExplorerVersion();
	if (ver > -1)
		return true;
	else
		return false;
}

var isIE = null;

function myGetComputedStyle(elem, extra){
	if (isIE == null)
		isIE = checkVersion();
	if (isIE)
		return elem.currentStyle;
	else
		return window.getComputedStyle(elem, null);
}

function getElementHeight(computedstyle, elem) {
	var height = 0;
	
	if(checkVersion())
		height = "" + elem.offsetHeight;
	else if (computedstyle == null)
		height = window.getComputedStyle(elem, null).height;
	else
		height = computedstyle.height;
	
	if (typeof(height) != 'number')
		return parseInt(height);
	else
		return height;
}

function getAbsolutePosition(obj) {
	var output = new Object();
	var mytop = 0, myleft = 0;
	
	while(obj) {
		mytop = obj.offsetTop + mytop;
		myleft = obj.offsetLeft + myleft;
		obj = obj.offsetParent;
	}
	
	output.left = myleft;
	output.top = mytop;
	return output;
}

function isEscapeKey(event){ 
	if (event == null) { // ie 
		keycode = event.keyCode; 
	} else { // mozilla 
		keycode = event.which; 
	} 
	if(keycode == 27)
		return true;
	else
		return false;
};

function strtrimstart (texto) {
	return texto.replace(/^\s*/, "");
}

function strtrimend (texto) {
	return texto.replace(/\s*$/, "");
}

function strtrim (texto) {
	return texto.replace(/^\s*/, "").replace(/\s*$/, "");
}

function parseIntList (csvIntList) {
	csvIntList = csvIntList.split(',');
	
	var csvInts = new Array();
	for(var c = 0; c < csvIntList.length; c++) {
		csvInts.push(parseInt(strtrim(csvIntList[c])));
	}
	
	return csvInts;
}

function contains(array, obj) {
	var toReturn = -1;
	for (var i = 0; i < array.length; i++) {
		if (array[i] === obj) {
			toReturn = i;
			break;
		}
	}
	return toReturn;
}

function isDescendant(parent, child) {
	if (parent == null || child == null)
		return false;
	var node = child.parentNode;
	while (node != null) {
		if (node == parent) {
			return true;
		}
		node = node.parentNode;
	}
	return false;
}

