function setPopupBackground(){
	// detect Firefox 2 on Mac //

	function detectMacXFF2() {
		var userAgent = navigator.userAgent.toLowerCase();
		if (/firefox[\/\s](\d+\.\d+)/.test(userAgent)) {
    		var ffversion = new Number(RegExp.$1);
    		if (ffversion < 3 && userAgent.indexOf('mac') != -1) {
    			return true;
    		}
  		} return false;
	}
	// set shadow on Firefox 2 for Mac //
	
	var yourShade = document.getElementById('grayPopup');
 	var d = detectMacXFF2(); //note new detectMacXFF2 script above
	if (d) {
    	//osx ff css opacity + flash wmode transparent doesn't work
    	yourShade.style.backgroundImage= "url(moduleimages/151/popupgray.png)";
    	yourShade.style.backgroundRepeat="repeat";
  	} else {
    	yourShade.style.backgroundColor = "#000";
    	yourShade.style.MozOpacity = .75;
    	yourShade.style.opacity = .75;
    	yourShade.style.filter = "alpha(opacity=75)";
  	}
}

// Gets the dimensions of the user's window for many different browsers--
// Returns an array of pageWidth, pageHeight, windowWidth, and windowHeight
// by Lokesh Dhakar - http://www.lokeshdhakar.com
function getPageSize() {

	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) /* all but Explorer Mac */{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else /* Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari */ {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	var pageHeight, pageWidth;
	if (self.innerHeight) /* all except Explorer */ {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) /* Explorer 6 Strict Mode */ {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) /* other Explorers */ {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight)
		pageHeight = windowHeight;
	else
		pageHeight = yScroll;

	// for small pages with total width less then width of the viewport

	if (xScroll < windowWidth)
		pageWidth = windowWidth;
	else
		pageWidth = xScroll;

	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);

	return arrayPageSize;
}

// create popup //
	
function createDiv(url,frameWidth,frameHeight,scrollBar){

	// create gray field //

	var divTag1 = document.createElement("div");
	divTag1.id = "grayPopup";
 
	document.body.appendChild(divTag1);
	
	var g=document.getElementById("grayPopup");
	g.style.position="absolute";
	g.style.top="0";
	g.style.left="0";
	g.style.width=getPageSize()[0]+"px";
	g.style.height=getPageSize()[1]+"px";
	g.style.zIndex="9000";
	
	// create iframe //
	
	if (scrollBar) {
		var scrollingOption = "auto";
	} else {
		var scrollingOption = "no";
	}
	
	var divTag2 = document.createElement("div");
	divTag2.id = "popUpWindow";
	divTag2.innerHTML = "<iframe scrolling='"+scrollingOption+"' frameborder='0' id='popup' name='popup' marginheight='0' marginwidth='0' height='"+frameHeight+"px' width='"+frameWidth+"px'  src='"+url+"' />"
	;
 
	document.body.appendChild(divTag2);
	
	var popupLeft=Math.round(((getPageSize()[2])-frameWidth)/2);
	var popupTop=Math.round(((getPageSize()[3])-frameHeight)/2);
	
	var popupFrame=document.getElementById("popUpWindow");
	popupFrame.style.width=frameWidth+"px";
	popupFrame.style.height=frameHeight+"px";
	popupFrame.style.position="absolute";
	popupFrame.style.top=popupTop+"px";
	popupFrame.style.left=popupLeft+"px";
	popupFrame.style.zIndex="10000";
	popupFrame.style.border="#CCCCCC solid 1px";
	
	var divTag3 = document.createElement("div");
	divTag3.id = "popUpClose";
	divTag3.innerHTML = "<a href='javascript:removeDiv();'><img src='moduleimages/151/popupClose.gif' width='25' height='25' border='0' /></a>";
	
	document.body.appendChild(divTag3);
	
	var popupClose=document.getElementById("popUpClose");
	popupClose.style.width="25px";
	popupClose.style.height="25px";
	popupClose.style.position="absolute";
	popupClose.style.top=popupTop-28+"px";
	popupClose.style.left=popupLeft+frameWidth-23+"px";
	popupClose.style.zIndex="11000";

	setPopupBackground ();
}

// hide popup //

function removeDiv() {
	var gray=document.getElementById("grayPopup");
	document.body.removeChild(gray);
	
	var popup=document.getElementById("popUpWindow");
	document.body.removeChild(popup);
	
	var popupClose2=document.getElementById("popUpClose");
	document.body.removeChild(popupClose2);
}