function showAlertBox(header, body) {
	resizeAndCenterBox(400, 200);
	document.getElementById('divFloat').innerHTML = addCloseBox()+ 
		"<div id='divFloatTextHeader'>"+header+"</div>" +
		"<div id='divFloatTextBody'>"+body+"</div>";
	showBox();
}

function showWindowWithAjaxRequest(request, width, height) {
	resizeAndCenterBox(width, height);
	document.getElementById('divFloat').innerHTML = addCloseBox() +
	"<div id='divFloatTextBody'></div>";
	httpRequest(request, '', 'divFloatTextBody');
	showBox();
}

function xWindow(header, request, width, height,asynch) {
	//default values
	var query = '';
	width = typeof(width) != 'undefined' ? width : '400';
	height = typeof(height) != 'undefined' ? height : '450';
	asynch = typeof(asynch) != 'undefined' ? asynch : 'GET';
 	
	if( asynch == "POST" ){
		var array_str =request.split("?"); 
		request = array_str[0];
		query = array_str[1];
	} 
	
	resizeAndCenterBox2(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-80)+"px; width: "+(width-60)+"px'></div>";

	httpRequest(request, query, 'divFloatTextBody');
	showBox();
	document.body.style.overflow = "hidden";
}

function closeBox() {
	document.getElementById('frameFloatBackground').style.zIndex = -1;
	document.getElementById('frameFloatBackground').style.visibility = "hidden";
	document.getElementById('frameFloatBackground').style.width = "0px";
	document.getElementById('frameFloatBackground').style.height = "0px";
	document.getElementById('divFloatContainer').style.zIndex = -1;
	document.getElementById('divFloatContainer').style.visibility = "hidden";
	document.getElementById('divFloat').innerHTML = "";

	document.body.style.overflow = "auto";
}

function addCloseBox() {
	var html = "";
	var browserName=navigator.appName;
/*	if(browserName == "Microsoft Internet Explorer") {
		html="<div id='divFloatClose'><span  class='floatClose'><a href='javascript:closeBox();'>X</a></span></div>";
	} else {*/
		html="<div id='divFloatClose'><a href='javascript:closeBox();'>X</a></div>";
//	}
	return html;
}

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

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

function resizeAndCenterBox(width, height) {
	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';
	
	// Resize divFloat
	document.getElementById('divFloat').style.width = width+'px';
	document.getElementById('divFloat').style.height = height+'px';
}

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

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

/* function getWindowSize() {
        
     var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		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
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			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 = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}*/
