


// this function puts the dark screen over the entire page
function DARKENPAGE() {
    //var page_screen = document.getElementById('page_screen');
    //page_screen.style.height = document.body.parentNode.scrollHeight + 'px';
    //page_screen.style.display = 'block';
}

// this function removes the dark screen and the page is light again
function LIGHTENPAGE() {
    //var page_screen = document.getElementById('page_screen');
    //page_screen.style.display = 'none';
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


function findDim(obj) {

	var CW=''+getStyleO(obj,'width');
	var CH=''+getStyleO(obj,'height');
	
	var OW=obj.offsetWidth;
	var OH=obj.offsetHeight;


	if ('auto'==CH && OH!=null) CH=OH;
	else if ('auto'==CH) CH=50;


	if ('auto'==CW && OW!=null) CW=OW;
	else if ('auto'==CW) CW=50;

	CH=''+CH;
	CW=''+CW;
		
	CH=CH.replace('px','');
	CW=CW.replace('px','');

	return [CW,CH];
}



function centerOBJ(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");
		
		if ('auto'==CH) CH='500';
		if ('auto'==CW) CW='500';
		
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =document.body.parentNode.scrollHeight+'';
		var PW =document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH/2;
		CW=CW/2;

		PH=PH/2;
		PW=PW/2;

		var L=PW-CW;
		var T=PH-CH;
	
		if (L<0) L=100;
		if (T<0) T=100;
		
		if ((''+T)=='NaN') T='100';
		E.style.left=L+'px';

		E.style.top=T+'px';


	}
	

}




function centerOBJ2(n,tt) {
	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");
		
		if ('auto'==CH) CH='500';
		if ('auto'==CW) CW='500';
		
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =document.body.parentNode.scrollHeight+'';
		var PW =document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH/2;
		CW=CW/2;

		PH=PH/2;
		PW=PW/2;

		var L=PW-CW;
		var T=PH-CH+tt;

		if (L<0) L=100;
		if (T<0) T=100;
		
		E.style.left=L+'px';
		E.style.top=T+'px';

	}
	

}



function bottomOBJ(n) {
	var E=document.getElementById(n);
	if (E!=null) {
		var pp=findPos(E);
		//var CW=window.getComputedStyle(E,"").getPropertyValue("width");
		//var CH=window.getComputedStyle(E,"").getPropertyValue("height");

		var CW=''+getStyle(n,'width');//''+E.offsetWidth;//window.getComputedStyle(E,"").getPropertyValue("width");
		var CH=''+getStyle(n,'height');//''+E.offsetHeight;//window.getComputedStyle(E,"").getPropertyValue("height");
		
		if ('auto'==CH) CH='500';
		if ('auto'==CW) CW='500';
		
		CH=CH.replace('px','');
		CW=CW.replace('px','');

		var PH =document.body.parentNode.scrollHeight+'';
		var PW =document.body.parentNode.scrollWidth+'';

		PH=PH.replace('px','');
		PW=PW.replace('px','');

		CH=CH;
		CW=CW/2;

		PH=PH;
		PW=PW/2;

		var L=PW-CW;
		var T=PH-CH;
		
		//alert(PH+"   "+CH+" ::: "+L+" "+T);		


		if (L<0) L=100;
		if (T<0) T=100;

		E.style.left=L+'px';
		E.style.top=T+'px';


		//E.style.left='0px';
		//E.style.top='0px';

		
		//alert(CW+" "+CH+" "+PH+" "+PW+" :: "+L+" "+T);		
	}
	

}






function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}


function getStyleO(x,styleProp) {
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}





				function hideInfoCENTER(n) {
					LIGHTENPAGE();
					var E=document.getElementById("INFO"+n);
					if (E!=null) E.style.display='none';
				}


				function showInfoCENTER(n) {

					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						DARKENPAGE();
						centerOBJ("INFO"+n);
						E.style.display='';
						scroll(0,0);
					}
				}

				function showInfoCENTERDY(n,fr,jsp) {

					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						var FRR=document.getElementById(fr);
						if (FRR!=null) {
							FRR.src=jsp;
						}

						DARKENPAGE();
						centerOBJ("INFO"+n);
						E.style.display='';

						scroll(0,0);
					}
				}



				function showInfoCENTER2(n,tt) {

					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						DARKENPAGE();
						centerOBJ2("INFO"+n,tt);
						E.style.display='';
						scroll(0,0);
					}
				}


				function showInfoCENTER2DY(n,tt,fr,jsp) {

					var E=document.getElementById("INFO"+n);
					if (E!=null) {
						var FRR=document.getElementById(fr);
						if (FRR!=null) {
							FRR.src=jsp;
						}

						DARKENPAGE();
						centerOBJ2("INFO"+n,tt);
						E.style.display='';
						scroll(0,0);
					}
				}



function showMEDGLEWGT(p) {

	showInfoCENTER2DY('MEDGLEWGTDIV',-200,'MEDGLEWGT','http://www.medgle.com/?partnerurl='+escape(p));
}
function hideMEDGLEWGT() {
	hideInfoCENTER('MEDGLEWGTDIV');
}

function writeMEDgleWidget(partner) {
if (partner=='') partner='unknown';
var R='';
R+='<style>';
//R+='.page_screen {background: url(http://www.medgle.com/blackTransparent80.png);position:absolute;top:0px;left:0px;width:100%;height:100%;z-index: 25;display:none;}';
R+='</style>';
R+='<link href="http://www.medgle.com/widgetstyle.css" type="text/css" rel="stylesheet"/>';
//R+='<div id="page_screen" class="page_screen" style="background:url(blackTransparent802.png);" >&nbsp;</div>';
R+='<div id="INFOMEDGLEWGTDIV" style="display:none;width: 1100px; z-index: 50;position: absolute;">';

				R+='<center>';
				R+='<table border="0" cellpadding="0" cellspacing="0" class="FW" >';
					R+='<TR>';
						R+='<TD><img border="0" src="http://www.medgle.com/w2_lt.png" ></TD>';
						R+='<TD style="background: url(http://www.medgle.com/w2_ts.png) repeat-x;" height="7px" ></TD>';
						R+='<TD><img border="0" src="http://www.medgle.com/w2_rt.png"  ></TD>';
					R+='</TR>';
					R+='<TR>';
						R+='<TD style="background: url(http://www.medgle.com/w2_ls.png) repeat-y;"  ></TD>';
						R+='<TD style="background-color: #ffffff;" valign="top" class="FW" >';




	R+='<div style="text-align:right;margin:0px;padding:0px;">';
		R+='<a href="javascript:hideMEDGLEWGT()"><img border="0" src="http://www.medgle.com/HMECLOSE2.png"></a>';
	R+='</div>';
	R+='<IFRAME src="http://www.medgle.com/blank.jsp" name="MEDGLEWGT" id="MEDGLEWGT" frameborder="0" width="1050" height="550" align="center" style="vertical-align: top;background-color: #ffffff;"></IFRAME>';




						R+='</TD>';
						R+='<TD style="background: url(http://www.medgle.com/w2_rs.png) repeat-y;"  >&nbsp;</TD>';
					R+='</TR>';

					R+='<TR>';
						R+='<TD><img border="0" src="http://www.medgle.com/w2_lb.png"  ></TD>';
						R+='<TD style="background: url(http://www.medgle.com/w2_bs.png) repeat-x;" height="10px"  ></TD>';
						R+='<TD><img border="0" src="http://www.medgle.com/w2_rb.png"  ></TD>';
					R+='</TR>';
				R+='</table>';
				R+='</center>';

R+='</div>';
R+='<img border="0" src="http://www.medgle.com/MEDGLEWIDGET.png" onClick="showMEDGLEWGT('+"'"+partner+"'"+')">';
document.write(R);
}


