function gblParseInt(e) {
    try {
        v = parseInt(e);
        return isNaN(v) ? 0 : v;
    }
    catch (e) {
    }
}

function gblParseFloat(e) {
    try {
        v = parseFloat(e);
        return (isNaN(v) ? 0 : v);
    }
    catch (e) {
        return 0;
    }
}

function roundNumber(num, dec) {
    var result = String(Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec));
    if (result.indexOf('.') < 0) { result += '.'; }
    while (result.length - result.indexOf('.') <= dec) { result += '0'; }
    return result;
}

function isNumeric(inputVal)
 {
	oneDecimal = false;
	inputStr = ((inputVal==null)?"":inputVal.toString());
	
	for (var i = 0; i < inputStr.length; i++) 
	{
		var oneChar = inputStr.charAt(i)
		if (i == 0 && oneChar == "-") 
		{
			continue
		}
		if (oneChar == "." && !oneDecimal) 
		{
			oneDecimal = true
			continue
		}
		if (oneChar < "0" || oneChar > "9") 
		{
			return false
		}
	}
	
	return true
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var size = new Object();
  size.width = myWidth;
  size.height = myHeight;
  
  return size;
}

// The winodow object on the browser (root most)
function getRootWindow() {
    var w = window;
    while (w.parent != w) {
        w = w.parent;
    }
    return w;
}

function doFocus(obj) {
    try {
        obj.focus();
    }
    catch(e){
    }
}

function doFocusWait(obj) {
    try {
        window.setTimeout(
            function() {
                try {
                    obj.focus();
                }
                catch (e) { }
            }, 500);
    }
    catch (e) {
    }
}

function getSelectedText() {
    var v = "";
    if (window.getSelection) {
        v = window.getSelection();
    }
    else if (document.getSelection) {
        v = document.getSelection();
    }
    else if (document.selection) {
        v = document.selection.createRange().text;
    }
    else {
    }

    return v;
}
