var phWinPopup;
function KCG_openBrWindow(theURL, winName, features)
{
 sFeatures = new String(features);
 sFeatures.toLowerCase;
 s = new String;
 var iHeight = screen.height * .8;    //default to 4/5 screen height
 var iWidth = screen.width * .8;  //default to 4/5 screen width
 var iTop = 0;
 var iLeft = 0;
 
 //get rid of top if there
 if (sFeatures.indexOf("top") > 0)
 {
  s = sFeatures.substr(sFeatures.indexOf("top"));
  if (s.indexOf(",") > 0 && s.length > s.indexOf(","))
   s = s.substr(s.indexOf(",") + 1);
  else
   s = "";
  sFeatures = sFeatures.substr(0, sFeatures.indexOf("top"));
 }
 
 //get rid of left if there
 if (sFeatures.indexOf("left") > 0)
 {
  s = sFeatures.substr(sFeatures.indexOf("left"));
  if (s.indexOf(",") > 0 && s.length > s.indexOf(","))
   s = s.substr(s.indexOf(",") + 1);
  else
   s = "";
  sFeatures = sFeatures.substr(0, sFeatures.indexOf("left"));
 }
 
 //look up height if there
 if (sFeatures.indexOf("height=") > 0)
 {
  s = sFeatures.substr(sFeatures.indexOf("height=") + 7);
  if (s.indexOf(",") > 0) s = s.substr(0, s.indexOf(","));
  iHeight = s;
 }
 
 //look up width if there
 if (sFeatures.indexOf("width=") > 0)
 {
  s = sFeatures.substr(sFeatures.indexOf("width=") + 6);
  if (s.indexOf(",") > 0) s = s.substr(0, s.indexOf(","));
  iWidth = s;
 }
 
 //set iTop, iLeft
 iTop = (screen.availHeight - iHeight)/2 - screen.height/20;
 if (iTop < 0) iTop = 0;
 iLeft = (screen.width - iWidth)/2;
 if (iLeft < 0) iLeft = 0;
 
 //is there a popup already open?
	if (typeof(phWinPopup) != "undefined") {
	    if (!phWinPopup.closed) {
					    phWinPopup.close();
					}
	}

 //open the window 
 phWinPopup = window.open(theURL, winName, sFeatures + ",height=" + iHeight + ",width=" + iWidth + ",top=" + iTop + ",left=" + iLeft);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function resizePopup() {
    if (isNetscape()) {
		//adjust height
		if (innerHeight > document.height + 25) {
			top.resizeBy(0, document.height - innerHeight + 25);
		}
		else if (document.height > innerHeight) {
			if (document.height - innerHeight + outerHeight + screenY + 42 < screen.height) {
				top.resizeBy(0, document.height - innerHeight);
			}
			else {
				top.resizeBy(0, screen.height - screenY - outerHeight - 42);
			}
		}

		//adjust width
		if (innerWidth > document.width + 25) {
			top.resizeBy(document.width - innerWidth + 25, 0)
		}
		else if (document.width > innerWidth) {
			if (document.width - innerWidth + outerWidth + screenX + 20 < screen.width) {
				top.resizeBy(document.width - innerWidth, 0);
			}
			else {
				top.resizeBy(screen.width - screenX - outerWidth - 20, 0);
			}
		}
	}
	else {
        try{
			var iResizeX = 0;
			var iResizeY = 0;
			
            if (document.body.scrollWidth > document.body.clientWidth) {
                if (window.screenLeft + document.body.scrollWidth + 20 < screen.availWidth) {
                    iResizeX = document.body.scrollWidth - document.body.clientWidth;
                }
                else {
					iResizeX = screen.availWidth - document.body.clientWidth - window.screenLeft - 25;
                }
            }
            else if (document.body.scrollWidth < document.body.clientWidth) {
                iResizeX = document.body.scrollWidth - document.body.clientWidth;
            }
            if (document.body.scrollHeight > document.body.clientHeight) {
                if (window.screenTop + document.body.scrollHeight + 25 < screen.availHeight) {
                    iResizeY = document.body.scrollHeight - document.body.clientHeight;
                }
                else {
                    iResizeY = screen.availHeight - window.screenTop - document.body.clientHeight - 25;
                }
            }
            else if (document.body.scrollHeight < document.body.clientHeight) {
                iResizeY =  document.body.scrollHeight - document.body.clientHeight;
            }

            //will scrollbars be needed after resize? (it's important to set the scrollbars on/off first, then resize)
            if (document.body.scrollWidth <= (document.body.clientWidth + iResizeX) && document.body.scrollHeight <= (document.body.clientHeight + iResizeY)) {
				document.body.scroll = 'no';
			}
			else {
				document.body.scroll = 'yes';
			}
			
			//now resize the window
			top.resizeBy(iResizeX, iResizeY);

			//the next line, though seemingly useless, forces IE to redraw the page correctly and fixes a long standing, annoying bug in which the page shifts unaccountably once you start to use it
			document.body.innerHTML = document.body.innerHTML;
        }
        catch(err){}
    }
}