function loadHtml(width,ajax) {
	document.getElementById("lightbox").innerHTML = "<span class='xWindow' style='margin-left: "+(width-30)+"px; pointer: cursor;' onclick='hideLightbox();'></span><div id='lightBoxContent'></div>";
	ajaxPageToContainer(ajax,'lightBoxContent');
}

function lightBox(width,height,ajax) {
	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=bodyWidth;}else{newWidth=screenWidth;}
	
		if (!(BrowserDetect.browser=="Explorer" && BrowserDetect.version <= 7)) {
			newdiv.style.marginLeft	= parseInt((newWidth/2)-(10/2)-15)+"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) {
		//alert("testing\n\r"+newWidth+"\n\r"+document.body.clientWidth+"\n\r"+width+"\n\r"+(parseInt((document.body.clientWidth / 2) - (width /2))));
		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);
	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 (document.all) {
		if (action=='show') {
			obj.style.position = "absolute";
			obj.style.top = "0";
			obj.style.height = overlayHeight+"px";
			obj.style.filter = "alpha(opacity=80)";
			loadHtml(width,ajax);
		} else {
			obj.style.height = "0px";
			obj.style.filter = "alpha(opacity=0)";
		}
	} else {
		if (action=='show'){
			$(obj).animate({
				"opacity": "0.8",
				"height": "100%"
			},500,function() {
				loadHtml(width,ajax);
			});
		} else {
			$(obj).animate({
				"opacity": "0.8",
				"height": "0px"
			},500);
		}
	}
}

function hideLightbox() {
	bodySheet('hide');
	if (document.getElementById('lightbox')) {
		document.getElementById('lightBoxContent').innerHTML = '';
		var screenWidth		= screen.width;
		$("#lightbox").animate({
			"marginLeft": (screenWidth/2),
			"width": 0,
			"height": 0
		},500,function() {removeBox(document.getElementById('lightbox'));})
	}
}

function removeBox(lightbox) {
	lightbox.style.left="-999em";
}
