function loadHtml(width,ajax) {
	document.getElementById("lightbox").innerHTML = "<span class='xWindow' style='pointer: cursor;'><a href='#none' style='display:block;width:100%;height:100%;' onclick='hideLightbox();'>&nbsp;</a></span><div id='lightBoxContent'></div>";
	if (ajax.indexOf("iframe:")==0) {
		var url = ajax.substr(7)
		document.getElementById("lightBoxContent").innerHTML = "<iframe width='100%' height='100%' frameborder='0' src='"+url+"'></iframe>";
	} else {
		ajaxPageToContainer(ajax,'lightBoxContent');
	}
	correctPNG();
}
function lightBox(width,height,ajax) {
	GLOBAL_SLIDESHOW_ON = false;
	if (!width){width=800;}
	if (!height){height=400;}
	if (!document.getElementById('lightbox')) {
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', 'lightbox');
		newdiv.className 		= 'floatingDiv';
	
		var bodyWidth 		= document.body.clientWidth;
		var screenWidth		= screen.width;
		if (bodyWidth>screenWidth){newWidth=screenWidth;}else{newWidth=bodyWidth;}
	
		if (!(BrowserDetect.browser=="Explorer" && BrowserDetect.version <= 7)) {
			newdiv.style.marginLeft	= parseInt((newWidth/2)-20)+"px";
		}
		document.body.appendChild(newdiv);
	}
	var obj = document.getElementById('lightbox');
	var yScroll 		= parseInt(document.body.scrollTop)|| parseInt(document.documentElement.scrollTop);
	obj.style.top 		= 80+parseInt(yScroll)+"px";
	obj.style.left		= 'auto';
	if (BrowserDetect.browser=="Explorer" && BrowserDetect.version <= 7) {
		obj.style.left		= (parseInt((document.body.clientWidth / 2) - (width /2)))+'px';
		obj.style.marginLeft= '0'; obj.style.marginRight= '0'; obj.style.marginTop= '0'; obj.style.marginBottom= '0';
	}
	if (document.all) { // Internet Explorer
		var screenWidth = document.body.clientWidth;
		var screenHeight = document.body.clientHeight;
	} else { // FF, Opera etc.
		var screenWidth = window.innerWidth;
		var screenHeight = window.innerHeight;
	}
	var newScreenWidth 	= parseInt((screenWidth/2) -(width/2));
	if (BrowserDetect.browser=="Explorer" && BrowserDetect.version <= 7) {
		newScreenWidth = 15;
	}
	//alert(newScreenWidth+"\n\r");
	$("#lightbox").animate({
		"width": width,
		"height": height,
		"marginLeft": (newScreenWidth-15)
	},500,function(){loadHtml(width,ajax);});
	bodySheet('show',width,ajax);
}

function bodySheet(action,width,ajax) {
	if (!document.getElementById('bodySheet')) {
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id', 'bodySheet');
		document.body.appendChild(newdiv);
	}
	var bodyHeight 		= document.body.clientHeight;
	var screenHeight	= screen.height;
	if (bodyHeight > screenHeight) {
		overlayHeight = bodyHeight;
	} else {
		overlayHeight = screenHeight;
	}
	var obj = document.getElementById('bodySheet');
		if (action=='show') {
			obj.style.top = "0";
			obj.style.height = overlayHeight+"px";
			obj.style.left	 = "auto";
			//loadHtml(width,ajax);
		} else {
			obj.style.height = "0px";
			obj.style.left	 = "-999em";
		}
}

function hideLightbox() {
	bodySheet('hide');
	if (document.getElementById('lightbox')) {
		document.getElementById('lightBoxContent').innerHTML = '';
		var bodyWidth 		= document.body.clientWidth;
		var screenWidth		= screen.width;
		if (bodyWidth>screenWidth){newWidth=screenWidth;}else{newWidth=bodyWidth;}
		$("#lightbox").animate({
			"marginLeft": (newWidth/2),
			"width": 0,
			"height": 0
		},500,function() {removeBox(document.getElementById('lightbox'));})
	}
}

function removeBox(lightbox) {
	lightbox.parentNode.removeChild(lightbox);
	//lightbox.style.left="-999em";
	GLOBAL_SLIDESHOW_ON = true;
}
