function showbeetoolspopup(title, href, content, width, height, left, top, scrollbar)
{
	var thedate = new Date();
	
	var popupele = document.createElement('DIV');
	if (width != '')
	{
		popupele.style.width = (parseFloat(width) + 40) + 'px';
	}
	if (height != '')
	{
		popupele.style.height = (parseFloat(height) + 40) + 'px';
	}
	
	var uniqid = new Date().getMilliseconds();
	popupele.style.position = 'absolute';
	popupele.className = 'beetoolspopup';
	popupele.id = 'beetoolspopup' + uniqid;
		
	var popuptop = document.createElement('DIV');
	popuptop.className = 'top';
	popupele.appendChild(popuptop);
	
	var popuptopleft = document.createElement('DIV');
	popuptopleft.className = 'topleft';
	popuptop.appendChild(popuptopleft);
	
	var popuptopmiddle = document.createElement('DIV');
	popuptopmiddle.className = 'topmiddle';
	popuptop.appendChild(popuptopmiddle);
	
	var popuptopmiddlelbl = document.createElement('LABEL');
	popuptopmiddlelbl.className = 'topmiddlelbl';
	popuptopmiddle.appendChild(popuptopmiddlelbl);

	var popuptopmiddleinput = document.createElement('A');
	popuptopmiddleinput.href = 'javascript: void(0);';
	popuptopmiddleinput.className = 'beetoolspopupclose';
	popuptopmiddleinput.id = 'beetoolspopupclose' + uniqid;
	popuptopmiddleinput.innerHTML = decodetext(fotext['btpopup-close']);
	popuptopmiddle.appendChild(popuptopmiddleinput);
	
	var popuptopright = document.createElement('DIV');
	popuptopright.className = 'topright';
	popuptop.appendChild(popuptopright);
	
	var popupmiddle = document.createElement('DIV');
	popupmiddle.className = 'middle';
	popupele.appendChild(popupmiddle);
	
	var popupmiddleleft = document.createElement('DIV');
	popupmiddleleft.className = 'middleleft';
	popupmiddle.appendChild(popupmiddleleft);

	var popupmiddlemiddle = document.createElement('DIV');
	popupmiddlemiddle.className = 'middlemiddle';
	popupmiddle.appendChild(popupmiddlemiddle);
	if (width != '')
	{
		popupmiddlemiddle.style.width = width + 'px';
	}
	if (height != '')
	{
		popupmiddlemiddle.style.height = height + 'px';
	}
	
	if (href != '')
	{
		if (href.indexOf(PATH_PROJECT_HTTP) > -1)
		{
			if (href.substr(href.length - 1) == '/')
			{
				href = href + 'index.php?popupview=true';
			}
			else if (href.substr(href.length - 9) == 'index.php')
			{
				href = href + '&popupview=true';
			}
		}
		
		var popupiframe = document.createElement('IFRAME');
		popupiframe.className = 'beetoolspopupiframe';
		if (width != '')
		{
			popupiframe.style.width = width + 'px';
		}
		if (height != '')
		{
			popupiframe.style.height = height + 'px';
		}
		popupiframe.style.borderStyle = 'none';
		popupiframe.style.borderWidth = '0px';
		popupiframe.frameBorder = '0';
		popupiframe.src = href;
		
		if (scrollbar == 'yes')
		{
			popupiframe.style.overflow = 'auto';
			popupiframe.scrolling = 'auto';
		}
		else
		{
			popupiframe.style.overflow = 'none';
			popupiframe.scrolling = 'no';
		}
		
		popupmiddlemiddle.appendChild(popupiframe);
	}
	else if (content != '')
	{
		var popupcontent = document.createElement('DIV');
		popupcontent.className = 'beetoolspopupcontent';
		popupcontent.innerHTML = content;
		if (scrollbar == 'yes')
		{
			popupcontent.style.overflow = 'auto';
		}
		else
		{
			popupcontent.style.overflow = 'none';
		}
		
		popupmiddlemiddle.appendChild(popupcontent);
	}
	
	var popupmiddleright = document.createElement('DIV');
	popupmiddleright.className = 'middleright';
	popupmiddle.appendChild(popupmiddleright);
	
	var popupbottom = document.createElement('DIV');
	popupbottom.className = 'bottom';
	popupele.appendChild(popupbottom);
	
	var popupbottomleft = document.createElement('DIV');
	popupbottomleft.className = 'bottomleft';
	popupbottom.appendChild(popupbottomleft);
	
	var popupbottommiddle = document.createElement('DIV');
	popupbottommiddle.className = 'bottommiddle';
	popupbottom.appendChild(popupbottommiddle);
	
	var popupbottomright = document.createElement('DIV');
	popupbottomright.className = 'bottomright';
	popupbottom.appendChild(popupbottomright);
	
	document.getElementsByTagName('BODY')[0].appendChild(popupele);	
	
	arrayPageSize = getbeetoolsPageSize();
	arrayPageScroll = getbeetoolsPageScroll();

	if (left == null || left == '')
	{
		left = (((arrayPageSize[0] - 20 - document.getElementById('beetoolspopup' + uniqid).offsetWidth) / 2));
	}
	if (top == null || top == '')
	{
		top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - document.getElementById('beetoolspopup' + uniqid).offsetHeight) / 2));
	}
	document.getElementById('beetoolspopup' + uniqid).style.left = left + 'px';
	document.getElementById('beetoolspopup' + uniqid).style.top = top + 'px';
	
	if (title != null)
	{
		var alllabels = document.getElementById('beetoolspopup' + uniqid).getElementsByTagName('LABEL');
		for (var i = 0; i < alllabels.length; i++)
		{
			if (alllabels[i].className == 'topmiddlelbl')
			{
				alllabels[i].innerHTML = title;
			}
		}
	}
	
	if (document.getElementById('beetoolspopupclose' + uniqid).attachEvent)
	{
		document.getElementById('beetoolspopupclose' + uniqid).attachEvent("onclick", closepopup);
	}
	else
	{
		document.getElementById('beetoolspopupclose' + uniqid).addEventListener("click", closepopup, true);
	}
	
	
}

function closepopup(e)
{
	if (e.srcElement)
	{
		var button = e.srcElement;
	}
	else
	{
		var button = e.target;
	}
	
	button.parentNode.parentNode.parentNode.parentNode.removeChild(button.parentNode.parentNode.parentNode);
}

function getbeetoolsPageSize(){
	
	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;
	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;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getbeetoolsPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}
