function showAlertBox(header, body, width, height) {
	//default values
	width = typeof(width) != 'undefined' ? width : '400';
	height = typeof(height) != 'undefined' ? height : '150';	
	
	resizeAndCenterBox(width, height);
	document.getElementById('divFloat').innerHTML = 
		"<div id='divFloatClose'><a href='javascript:closeBox();' style='text-decoration:none;' >X</a></div>" +
		"<div id='divFloatTextHeader'>"+header+"</div>" +
		"<div id='divFloatTextBody'>"+body+"</div>";
	showBox();
}

function showWindowWithAjaxRequest(header, request, width, height) {
	//default values
	width = typeof(width) != 'undefined' ? width : '400';
	height = typeof(height) != 'undefined' ? height : '450';		
	
	resizeAndCenterBox(width, height);
	document.getElementById('divFloat').innerHTML = 
		"<div id='divFloatClose'><a href='javascript:closeBox();' style='text-decoration:none;'>X</a></div>" +
		"<div id='divFloatTextHeader'>"+header+"</div>" +
		"<div id='divFloatTextBody' style='height: "+(height-65)+"px; width: "+(width-60)+"px'></div>";
	httpRequest(request, '', 'divFloatTextBody');
	showBox();
}

function closeBox() {
	document.getElementById('frameFloatBackground').style.zIndex = -1;
	document.getElementById('frameFloatBackground').style.visibility = "hidden";
	document.getElementById('frameFloatBackground').style.display="none"; //fix for firefox, safari & opera 		
	document.getElementById('divFloatContainer').style.zIndex = -1;
	document.getElementById('divFloat').innerHTML = "";
	document.getElementById('divFloat').style.display = "none";
}

function showBox() {
	var pageSize = getWindowSize();

	document.getElementById('divFloat').style.display = "block";
	document.getElementById('frameFloatBackground').style.visibility = "visible";
	document.getElementById('frameFloatBackground').style.width = document.body.clientWidth+"px";
	document.getElementById('frameFloatBackground').style.height = pageSize[1] + "px";
	document.getElementById('frameFloatBackground').style.zIndex = 500;
	document.getElementById('frameFloatBackground').style.display="block";
	document.getElementById('divFloatContainer').style.zIndex = 1001;
}

function resizeAndCenterBox(width, height) {
//	var pageSize = getWindowSize();
//	var marginTop = (document.documentElement.clientHeight - height)/2;
//	var marginLeft = (document.documentElement.clientWidth - width)/2;

	var offset = getScrollOffset();
	var marginTop = offset[1] + (document.documentElement.clientHeight - height)/2;
	var marginLeft = offset[0] + (document.documentElement.clientWidth - width)/2;
	
	if (marginTop < 10)
		marginTop = 10;
	
	if (marginLeft < 10)
		marginLeft = 10;
	
	document.getElementById('divFloat').style.top = marginTop+'px';
	document.getElementById('divFloat').style.left = marginLeft+'px';
//	scroll(0,0);
	
	// Resize divFloat
	document.getElementById('divFloat').style.width = width+'px';
	document.getElementById('divFloat').style.height = height+'px';
}

function changeTab(link, tab, num) {
	httpRequest(link, tab+'='+num, 'divFloatTextBody');
}

function getWindowSize(){
	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 getScrollOffset() {
	return [window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop];
}
