function GetWindowInnerWidth()
{
    var w;
    if (self.innerHeight) // all except Explorer
    {
        w = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
        // Explorer 6 Strict Mode
        w = document.documentElement.clientWidth;
    }
    else if (document.body) // other Explorers
    {
        w = document.body.clientWidth;
    }
    return w;
}

function GetWindowInnerHeight()
{
    var h;
    if (self.innerHeight) // all except Explorer
    {
        h = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    {
        // Explorer 6 Strict Mode
        h = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        h = document.body.clientHeight;
    }
    return h;
}

function SmartSpeechBubble(icon, header, message, targetControl) 
{
    SmartSpeechBubble(icon, header, message, targetControl, '' );
}

function SmartSpeechBubble(icon, header, message, targetControl, imageRoot) 
{
    var target              = null;
    if( targetControl != null )
    {
        //target = document.getElementById( targetControl );
    }
	var speechBubble        = document.getElementById("speechbubble");
	var speechBubbleShadow  = document.getElementById("speechbubbleShadow");
	document.getElementById("speechHeader").innerHTML = header;
	document.getElementById("speechMessage").innerHTML = message;
	document.getElementById("speechIconSrc").src = imageRoot + icon + '.gif';
	
	if( target )
	{
	    speechBubble.style.left         = target.style.left + target.style.width;// - 244;
	    speechBubbleShadow.style.left   = target.style.left + target.style.width;;// - 244;
	    speechBubble.style.top          = target.style.top + target.style.height;//; - 30;
	    speechBubbleShadow.style.top    = target.style.top + target.style.height;//; - 30;
	}
	else
	{
	    speechBubble.style.left         = GetWindowInnerWidth() - 244;
	    speechBubbleShadow.style.left   = GetWindowInnerWidth() - 244;
	    speechBubble.style.top          = GetWindowInnerHeight() - 90;
	    speechBubbleShadow.style.top    = GetWindowInnerHeight() - 90;
	}
    
    speechBubble.style.visibility = 'visible';
	speechBubbleShadow.style.visibility = 'visible';
	SmartSpeechBubbleShow(0);
}

function SmartSpeechBubbleShow(opacity) 
{
	document.getElementById("speechbubble").style.filter = 'Alpha(Opacity=' + opacity + ')';
	document.getElementById("speechbubbleShadow").style.filter = 'Alpha(Opacity=' + parseInt(opacity/2) + ')';		
	opacity = parseInt(opacity)+10;
	if (opacity < 101) 
	{
		setTimeout("SmartSpeechBubbleShow(" + opacity + ");", 50);
    }
	else 
	{
		setTimeout("SmartSpeechBubbleHide(100);", 5000);
	}
}

function SmartSpeechBubbleHide(opacity) 
{
	document.getElementById("speechbubble").style.filter = 'Alpha(Opacity=' + opacity + ')';
	document.getElementById("speechbubbleShadow").style.filter = 'Alpha(Opacity=' + parseInt(opacity/2) + ')';

	opacity = parseInt(opacity)-10;
	if (opacity > 1)
	{
		setTimeout("SmartSpeechBubbleHide(" + opacity + ");", 50);
	}
	else 
	{
		document.getElementById("speechbubble").style.visibility = 'hidden';
		document.getElementById("speechbubbleShadow").style.visibility = 'hidden'
	}
}

function resizePage() 
{
   	var clientHeight = self.innerHeight; 
	if (clientHeight == null) {
		clientHeight = (document.compatMode=="CSS1Compat")?document.documentElement.clientHeight : document.body.clientHeight;
	}
	
	var clientHeight = clientHeight-50;
	var clientWidth = document.body.clientWidth;
	var leftWidth = parseInt(clientWidth*0.28);
	var rightWidth = clientWidth - leftWidth - 20 // parseInt(clientWidth*0.65);
	
	// vi justerer venstre-siden med træ og app-dock (som pr. default skal fylde 25% af skærmen width)		
	resizeGuiWindow("treeWindow", leftWidth, parseInt(clientHeight)-165)
	resizeGuiWindow("PlaceHolderAppIcons", leftWidth, 130)
	
	document.getElementById('right').style.width = (rightWidth-8) +"px";
	document.getElementById('right').style.height = (clientHeight-25) + "px";
}

function resizeGuiWindow(windowName, newWidth, newHeight, window) 
{
	resizePanelTo(windowName, false, newWidth, newHeight);
	}

function resizeGuiWindowWithTabs(windowName, newWidth, newHeight) 
{


	right.document.all[windowName+"ContainerTable"].width = newWidth+22
	right.document.all[windowName+"ContainerTableSpacer"].width = newWidth
	right.document.all[windowName+"Bottom"].width = newWidth+12
	right.document.all[windowName+"BottomSpacer"].width = newWidth
	right.document.all[windowName].style.width = newWidth


	// Der skal forskellig størrelse på højden afhængig af om vinduet har en label i bunden
	if (right.document.all[windowName+'BottomLabel']) {
		right.document.all[windowName+"ContainerTable"].height = newHeight-13;
		right.document.all[windowName].style.height = newHeight-13;
	} else {
		right.document.all[windowName+"ContainerTable"].height = newHeight+3;
		right.document.all[windowName].style.height = newHeight+3;
	}
}

function openDialog(windowName, diaDoc, dwidth, dheight)
{
      var win;
      strFeatures = "width=" + dwidth + "px,height=" + dheight + "px,border=no,scrollbars=yes,center=yes,help=no,status=yes,resizable=yes"
      win = window.open(diaDoc, windowName, strFeatures);
      win.focus();
      return false;
}
function openModalDialog(dialogArgs, dialogSource, dwidth, dheight)
{
      window.status = "";
      strFeatures = "dialogWidth=" + dwidth + "px;dialogHeight=" + dheight + "px;"
			        + "scrollbars=no;center=yes;help=no;status=no;edge=raised;border=no;"
      strTitle = window.showModalDialog(dialogSource, dialogArgs, strFeatures);
      return strTitle;
}

function getSelection(targetControl, dialogTitle, dialogSource, dialogWidth, dialogHeight )
{
	var tbx 		= document.getElementById(targetControl);
	var returnValue	= openModalDialog(dialogTitle, dialogSource, dialogWidth, dialogHeight );
	tbx.value       = returnValue;
}

function confirmDialog( message ) 
{
    if (confirm( message )) 
    {
        return true;
    }
    else
    {
        return false;
    }
}


