//************************************************************************************
// Copyright (C) 2006, Massimo Beatini
//
// This software is provided "as-is", without any express or implied warranty. In 
// no event will the authors be held liable for any damages arising from the use 
// of this software.
//
// Permission is granted to anyone to use this software for any purpose, including 
// commercial applications, and to alter it and redistribute it freely, subject to 
// the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not claim 
//    that you wrote the original software. If you use this software in a product, 
//    an acknowledgment in the product documentation would be appreciated but is 
//    not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be 
//    misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
//************************************************************************************

//
// global variables
//
var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;

function getDocHeight () {
    return (Math.max(document.getElementById('wrapper').offsetHeight, document.body.scrollHeight))+23;
}

//
// dinamically add a div to 
// dim all the page
//
function buildDimmerDiv()
{
    document.write('<div id="dimmer" class="dimmer" style="width:100%; height: ' + getDocHeight() +'px; "><img src="images/spacer.gif" width="100%" height="100%" /></div>');
}


//
//
//
function displayFloatingDiv(divId, title, width, height, left, top) 
{

	DivID = divId;
	document.getElementById('dimmer').style.height = getDocHeight() + ('px');
	document.getElementById('dimmer').style.visibility = "visible";

    document.getElementById(divId).style.width = width + 'px';
    document.getElementById(divId).style.height = height + 'px';
    document.getElementById(divId).style.left = left + 'px';
    document.getElementById(divId).style.top = top + 'px';
	
	var addHeader;
	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;
	
	addHeader = '<table style="width:' + width + 'px; height: 24px;" class="floatingHeader">' +
	            '<tr><td><p style="padding-left: 2px">' + title + '</p></td>' + 
	            '<td style="width:20px" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');void(0);">' + 
	            '<img alt="Bezárás..." title="Bezárás..." src="images/close.png" border="0" width="20" height="20"></a></td></tr></table>';
	
	            
    // add to your div an header	
	newDivHTML = originalDivHTML.replace(/!!PRODUCTNAME!!/g, title);
	document.getElementById(divId).innerHTML = addHeader + newDivHTML;
	
	
	document.getElementById(divId).className = 'dimming';
	document.getElementById(divId).style.visibility = "visible";


}


//
//
//
function hiddenFloatingDiv(divId) 
{
	document.getElementById(divId).innerHTML = originalDivHTML;
	document.getElementById(divId).style.visibility='hidden';
	document.getElementById('dimmer').style.visibility = 'hidden';
	document.getElementById('dimmer').style.height = '0px';
	
	DivID = "";
}

//
//
//
function init()
{
    // check browser
    isMozilla = (document.all) ? 0 : 1;

    // add the div
    // used to dim the page
	buildDimmerDiv();

}

// call init
init();

