var zIndex = 0;

/**
 * 
 */
function openbox(element, addZIndex) 
{
	try
	{
		element = $(element);	
	    element.style.position = 'absolute';
	    /*if (addZIndex) {
	    	setOverlay(); 
	    	zIndex++;
			element.style.zIndex = zIndex;
	    	window.alert('panel:' + zIndex);
		}*/
    }
	catch(e)
	{
        window.alert('noelement');
        return false;
    }

    var my_width  = 0;
    var my_height = 0;

    if ( typeof( window.innerWidth ) == 'number' ) 
    {
        my_width  = window.innerWidth;
        my_height = window.innerHeight;
    } 
    else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        my_width  = document.documentElement.clientWidth;
        my_height = document.documentElement.clientHeight;
    } 
    else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    {
        my_width  = document.body.clientWidth;
        my_height = document.body.clientHeight;
    }

    var scrollY = 0;

    if ( document.documentElement && document.documentElement.scrollTop )
    {
        scrollY = document.documentElement.scrollTop;
    }
    else if ( document.body && document.body.scrollTop )
    {
        scrollY = document.body.scrollTop;
    }
    else if ( window.pageYOffset )
    {
        scrollY = window.pageYOffset;
    }
    else if ( window.scrollY )
    {
        scrollY = window.scrollY;
    }

    var elementDimensions = element.getDimensions(element);

    var setX = ( my_width  - elementDimensions.width  ) / 2;
    var setY = ( my_height - elementDimensions.height ) / 2 + scrollY;

    setX = ( setX < 0 ) ? 0 : setX;
    setY = ( setY < 0 ) ? 0 : setY;

    element.style.left = setX + "px";
    element.style.top  = setY + "px";

    element.style.display  = 'block';
}

/**
 * 
 */
function setOverlay()
{
   zIndex++;
   var is = new Is();
   var Element = document.createElement("DIV");
   if (is.moz) 
   {
		with (Element) {
			setAttribute("id", "overlay_" + zIndex);
			setAttribute("class", "Overlay");	
			setAttribute("style", "z-index: " + zIndex + "; display: block; height: " + (window.innerHeight + window.scrollMaxY) + "px");		
		}
	  element = document.body.appendChild(Element);
	  window.alert('overlay:' + zIndex);
   } 
   else 
   {
	   window.alert("no");
	   /*$(Element).style.height = (document.documentElement.scrollHeight) + 'px';
	   $(Element).style.display = 'block';  
	   $(Element).style.zIndex = zIndex;*/
   }
}

/**
 * 
 */
function resetOverlay(Element)
{
	$(Element).style.display = 'none';  
	$(Element).style.height = 0;
	$(Element).style.zIndex = 0;
}
