function getVar(p, gf) {
	var tr = null,r = new RegExp(p + "(\\w*)", "i"),rs = r.exec(gf);
	
	if(rs) {
		tr = rs[1];
	}
	return tr;
};

function GB_show(theGB) {
	var ifram, el, pso, ifram,
		gb_hd = 400,
		gb_wd = 400,
		gb_a = false,
		title = theGB.title||theGB.innerHTML||theGB.href,
		gb_h=(getVar("gbh_", theGB.className)||gb_hd)-0,
		gb_w=(getVar("gbw_", theGB.className)||gb_wd)-0;
	  
  try {
	el=document.getElementById('GB_overlay');
    if (!el) {
      document.body.innerHTML+=
	  	'<div id="GB_overlay"></div>'+
		'<div id="GB_window" style="width:'+gb_w+'px;height:'+gb_h+'px;">'+
		'	<div id="GB_head" style="background-color:#FFF;width:'+gb_w+'px;height:21px;padding:0px;">'+
		'		<div id="GB_caption" style="text-align:left;float:left;">&nbsp;'+title+'</div>'+
		'		<div id="GB_close" style="float:right;">'+
		'			<img src="/images/closeSquare.gif" style="width:23px;height:21px;cursor:pointer;" alt="Close window" onclick="GB_hide();" style="border:0px;cursor:pointer;" />'+
		'		</div>'+
		'	</div>'+
		'	<div id="GB_body" style="width:'+gb_w+'px;height:'+(gb_h-21)+'px;"></div>'+
		'</div>';
    }

	centerAbsoluteDivById('GB_window');
	
	pso=getPageSizeObj();
	el=document.getElementById('GB_overlay');
	el.style.width=pso.width+'px';
	el.style.height=pso.height+'px';
			
	ifram = document.createElement('iframe');
	ifram.src = theGB.href;
	ifram.id = 'GB_f';
	ifram.name = 'GB_f';
	ifram.scrolling = 'no';
	ifram.border = '0';
	ifram.frameBorder = '0';
	ifram.style.width = gb_w+'px';
	ifram.style.height = gb_h+'px';
	
	el=document.getElementById('GB_body');
	if(el) {
		el.appendChild(ifram);
	}	
  } catch(e) {
    //alert(e);
  }
}

function GB_hide() {
	var el=document.getElementById('GB_window');
	el.parentNode.removeChild(el);
	el=document.getElementById('GB_overlay');
	el.parentNode.removeChild(el);
}

function centerAbsoluteDivById(elementID) {
	var scrollY,
		el=document.getElementById(elementID),
		scrollY=getScrollOffsetXY().Y,
		elementWidth=parseInt(el.style.width.replace(/px/,''),10),
		elementHeight=parseInt(el.style.height.replace(/px/,''),10),
		pso=getPageSizeObj();
		
	if(scrollY+elementHeight>pso.height) {
		scrollY=pso.height-elementHeight-10;
	}

	el.style.left=((pso.width-elementWidth)/2)+'px';
	el.style.top=scrollY+'px';
}

function getPageSizeObj(){
	var pageWidth, pageHeight;

	if(window.innerHeight && window.scrollMaxY) {
		pageWidth = window.innerWidth + window.scrollMaxX - 17;
		pageHeight = window.innerHeight + window.scrollMaxY;
	} else if( document.body.scrollHeight > document.body.offsetHeight ) {
		pageWidth = document.body.scrollWidth;
		pageHeight = document.body.scrollHeight;
	} else {
		pageWidth = document.body.offsetWidth + document.body.offsetLeft;
		pageHeight = document.body.offsetHeight + document.body.offsetTop;
	}
	
	return {
		width: pageWidth,
		height: pageHeight
	};
}

function getScrollOffsetXY() {
	var scrOfX = 0, scrOfY = 0;
	if(typeof(window.pageYOffset)=='number') {
		//Netscape compliant
		scrOfY=window.pageYOffset;
		scrOfX=window.pageXOffset;
	} else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)) {
		//DOM compliant
		scrOfY=document.body.scrollTop;
		scrOfX=document.body.scrollLeft;
	} else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)) {
		//IE6 standards compliant mode
		scrOfY=document.documentElement.scrollTop;
		scrOfX=document.documentElement.scrollLeft;
	}
	return {
		X: scrOfX, 
		Y: scrOfY
	};
}