function doLightBox(url, dl, dl_url) { // pass the url and if its a download, flag the dl to true (dl = true), pass the download url to the function if we are downloading
	// create grayed out div for underneath lightbox
	lbop = document.createElement("div");
	lbop.id = "OpacityLB";
	lbop.className = "grayOpacity";
	
	// create the lightboxcont layer
	lbc = document.createElement("div");
	lbc.id = "LightBoxCont";
	lbc.className = "lightBoxCont";
	
	// create the lightbox layer
	lb = document.createElement("div");
	lb.id = "LightBox";
	lb.className = "lightBox";
	
	//add the lightbox to lightboxcont layer
	lbc.appendChild(lb);
	// add the opacity to the document
	document.body.appendChild(lbop);
	// add lightbox to the document
	document.body.appendChild(lbc);
	// call the page that will populate the light box trough an AHAH call
	getContent(url, "GET", "LightBox");
	// do the call to show the lightbox
	showLightBox();
	// are we downloading a song?
	if (dl != null && dl == true) {
		getContent(dl_url, "POST");
	}
	return false;
}

function showLightBox() {
	var scrollTop = 0;
	
	// resize the gray opacity layer to the full width and height that is scollable in the browser
	lbop = document.getElementById("OpacityLB");
	if (lbop != null) {
		lbop.style.width = document.documentElement.scrollWidth + "px";
		lbop.style.height = document.documentElement.scrollHeight + "px";
	}
	
	// resize the lightbox layer to the width and height to the client area that is viewable/visible
	lbc = document.getElementById("LightBoxCont");
	if (lbc != null) {
		lbc.style.width = document.documentElement.clientWidth + "px";
		lbc.style.height = document.documentElement.clientHeight + "px";
		// move the lightbox layer off the client viewable area
		lbc.style.left = document.documentElement.clientWidth + "px";
	}
	
	if (lbop != null) {
		// display the gray opacity layer on the page
		lbop.style.display = "block";
	}
	
	if (lbc != null) {
		// move the lightbox layer at the top left corner, change its size, and then display it
		lbc.style.left = "0px";
		lbc.style.display = "block";
	}
	
	lb = document.getElementById("LightBox");
	if (lb != null) {
		if (window.pageYOffset) {
			scrollTop = window.pageYOffset;
		} else {
			scrollTop = document.documentElement.scrollTop;
		}
		
		if (lb.offsetHeight <= document.documentElement.clientHeight) {
			lb.style.top = (((document.documentElement.clientHeight - lb.offsetHeight) / 2) + parseInt(scrollTop)) + "px";
			//alert(document.documentElement.clientHeight);
			//alert(lb.offsetHeight);
			//alert(document.documentElement.clientHeight - lb.offsetHeight)
			//alert((document.documentElement.clientHeight - lb.offsetHeight) / 2);
			//alert(parseInt(scrollTop));
		} else {
			lb.style.top =  parseInt(scrollTop) +"px";
		}
	}
	
	lastScrollTop = scrollTop;
	
	// add events to window
	if (window.addEventListener) { // FF
		window.addEventListener("scroll", scrolled, false);
	} else if (window.attachEvent) { // IE
		window.attachEvent("onscroll", scrolled);
	}
	
	return false;
}

var lastScrollTop = 0;

function scrolled() {
	var scrollTop = 0;
	var moveLightbox = true;
	var lb = null;
	
	// get the lightbox
	lb = document.getElementById("LightBox");
	if (lb != null) {
		if (window.pageYOffset) {
			scrollTop = window.pageYOffset;
		} else {
			scrollTop = document.documentElement.scrollTop;
		}
		if (parseInt(scrollTop) > parseInt(lastScrollTop)) {
			// Scrolling down...
			if (lb.offsetHeight <= parseInt(document.documentElement.clientHeight)) {
				// center vertically
				position = ((document.documentElement.clientHeight - lb.offsetHeight) / 2) + parseInt(scrollTop);
			} else if ((parseInt(getNumericPart(lb.style.top)) + lb.offsetHeight) < (parseInt(scrollTop) + parseInt(document.documentElement.clientHeight))) {
				// align bottom to bottom
				position = parseInt(scrollTop) + document.documentElement.clientHeight - lb.offsetHeight;
			} else {
				// don't move
				moveLightbox = false;
			}
		} else if (parseInt(scrollTop) < parseInt(lastScrollTop)) {
			// Scrolling up...
			if (lb.offsetHeight <= parseInt(document.documentElement.clientHeight)) {
				// center vertically
				position = ((document.documentElement.clientHeight - lb.offsetHeight) / 2) + parseInt(scrollTop);
			} else if (parseInt(scrollTop) <= parseInt(getNumericPart(lb.style.top))) {
				// align top to top
				position = parseInt(scrollTop);
			} else {
				// don't move
				moveLightbox = false;
			}
		} else {
			// No scrolling...
			moveLightbox = false;
		}
		if (moveLightbox) {
			lb.style.top = position + "px";
			lastScrollTop = scrollTop;
		}
	}
	return false;
}

function hideLightBox() {
	hideElement("LightBoxCont");
	hideElement("OpacityLB");
	document.getElementById('LightBox').innerHTML = '';
	
	if (window.removeEventListener) {
		window.removeEventListener("scroll", scrolled, false);
	} else if (window.detachEvent) {
		window.detachEvent("onscroll", scrolled);
	}
	return false;
}