// JavaScript Document
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var opened;

function showPopup(url, w, h){
	if (opened ){
		opened.close();
	}
	var canResize = ( arguments.length > 3 ) ? arguments[3] : 1;
	var canScroll = ( arguments.length > 4 ) ? arguments[4] : 0;
	
	var y = ( window.screen.availHeight - h ) / 2;
	var x = ( window.screen.availWidth - w ) / 2;
	
	var config = 'top='+y+',left='+x+',height='+h+',width='+w+',toolbar=0,location=0,statusbar=0,menubar=0,scrollbars='+canScroll+',resizable='+ canResize;
	opened = window.open(url, '_popup', config);
	opened.focus();
}

function trim(input){
	var output = input.replace(/^\s+|\s+$/g, '');
	return output;
}

/*====================================================================
 * Get the bounds
 *====================================================================*/
function getBounds( obj ){
	var t = obj.offsetTop;
	var l = obj.offsetLeft;
	var w = obj.offsetWidth;
	var h = obj.offsetHeight;
	var preObj = null;

	while ( obj=obj.offsetParent ){
		if ( obj.tagName.toUpperCase() == 'TABLE' ){
			var cIndex = preObj.cellIndex;
			for ( var i=0 ; i<obj.rows.length ; i++ ){
				if ( obj.rows[i][cIndex] == preObj ){
					for ( var j=0; j<cIndex; j++){
						l +=  obj.rows[i][j].offsetLeft;
					}					
					break;
				}
			}
		}
		t += obj.offsetTop;
		l += obj.offsetLeft;
		
		if ( obj.tagName.toUpperCase() == 'TD' ){
			preObj = obj;
		}
	}

	return {top:t, left:l, width:w, height:h}
}
