// Stop flickering in IE6
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

function toggleLightBox(divtotoggle, display, visibility) {
	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){ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	var adjustedWidth, adjustedHeight;
	if(xScroll < windowWidth){	
		adjustedWidth = windowWidth;
	} else {
		adjustedWidth = xScroll;
	}
	if(yScroll < windowHeight){
		adjustedHeight = windowHeight;
	} else {		
		adjustedHeight = yScroll;
	}

	var overlay = $(divtotoggle);

	overlay.setStyle({
		opacity: 0.75,
		backgroundImage: 'url(images/black_50.png)',
		backgroundRepeat: 'repeat',
		height: adjustedHeight+'px',
		display: display,
		visibility: visibility
	});
}

function togglePopup(pDivToToggle, pDisplay, pVisibility, pURL)
{
	var popup = $(pDivToToggle);
	//alert(pURL)
	lightboxframe.location.href=pURL;
	popup.setStyle({
		display: pDisplay,
		visibility: pVisibility
	});	
	//Effect.Fade(popup, { duration: 2.0, from: 0, to: 1 });
}

function resizeLightboxDiv(divtotoggle, width, height) {
	var d = $(divtotoggle);

	d.setStyle({
		width: width+'px',
		height: height+'px'
	});
	var d = $('lightboxframe');
	d.setStyle({
		width: width+'px',
		height: height+'px'
	});
	d.setStyle({
		textalign: 'center',
		align: 'center'
	});


}
