﻿var isMozilla;
var objDiv = null;
var originalDivHTML = "";
var DivID = "";
var over = false;

//
// dinamically add a div to 
// dim all the page
//
function buildDimmerDiv()
{   //window.screen.width  window.screen.height
    
}

function displayFloatingDiv(divId, title, width, height, left, top, color) 
{    
    var offsetWidth = document.body.offsetWidth
    document.write('<div id="dimmer" class="dimmer" style="width:'+ offsetWidth + 'px; height:' + document.body.offsetHeight +'px"></div>');
    DivID = divId;	    
    
    if(isMozilla)
    {
        var pageLength = parseFloat(document.body.offsetHeight) + 15 ;
        document.getElementById('dimmer').style.height = pageLength + 'px';
    }
    else
    {
        document.getElementById('dimmer').style.height = parseInt(document.body.scrollHeight) + parseInt(document.body.topMargin) ;
    }
        
    document.getElementById('dimmer').style.visibility = "visible";	
    document.getElementById('iframeIE6').style.display = "inline";	

    //document.getElementById(divId).style.width = width + 'px';
    //document.getElementById(divId).style.height = height + 'px';
    offsetWidth = (offsetWidth - width)/2 ;
    document.getElementById(divId).style.left =  offsetWidth + 'px';
    top += 10;
    document.getElementById(divId).style.top = top + 'px';
	
	var addHeader;
	
	if (originalDivHTML == "")
	    originalDivHTML = document.getElementById(divId).innerHTML;
	
	addHeader = '<table style="color:#ffffff;width:' + width + 'px;background-color:' + color + ';z-index:100000;">' +
	            '<tr><td ondblclick="void(0);" onmouseover="over=true;" onmouseout="over=false;" style="cursor:move;height:18px"><b>' + title + '</b></td>' + 
	            '<td style="width:18px" align="right"><a href="javascript:hiddenFloatingDiv(\'' + divId + '\');void(0);">' + 
	            '<img alt="Kapat..." title="Kapat..." src="Resources/images/exit.gif" border="0"></a></td></tr></table>';
    
	document.getElementById(divId).innerHTML = addHeader + originalDivHTML;
	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';
	
	DivID = "";
	
	document.getElementById('iframeIE6').style.display='none';
}

//
//
//
function MouseDown(e) 
{
    ScrollTop = document.documentElement.scrollTop; //document.body.scrollTop;
    if (over)
    {       
        if (isMozilla) {
            objDiv = document.getElementById(DivID);
            X = e.layerX;
            Y = e.layerY;
            return false;
        }
        else {        
            objDiv = document.getElementById(DivID);
            objDiv = objDiv.style;
            X = event.offsetX;
            Y = event.offsetY;
            return false;
        }
    }
}


//
//
//
function MouseMove(e) 
{
    if (objDiv) {
        if (isMozilla) {
        
            objDiv.style.top = (e.pageY-Y) + 'px';
            objDiv.style.left = (e.pageX-X) + 'px';            
            return false;
        }
        else 
        { 
            objDiv.pixelLeft = event.clientX-X + document.body.scrollLeft;
            objDiv.pixelTop = event.clientY-Y + ScrollTop;
            return false;
        }
    }
}

//
//
//
function MouseUp() 
{
    objDiv = null;
}


//
//
//
function init()
{
    // check browser
    isMozilla = (document.all) ? 0 : 1;


    if (isMozilla) 
    {
        document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
    }

    document.onmousedown = MouseDown;
    document.onmousemove = MouseMove;
    document.onmouseup = MouseUp;
   

    // add the div
    // used to dim the page
	//buildDimmerDiv();

}

// call init
init();
