<!--
/*
// divutils.js - Javascript utility functions for DHTML layers (div)
// Language    : Javascript 1.2
// Author      : Erwin Haantjes
// Project     : General
// Required    : sysutils.js
// Copyright   : Erwin Haantjes/Interurbia (c) 2005-2007 - All rights reserved
// Licensed to : Interurbia/Meneer Web/Unit Redd Creators/Unit Redd - and it's customers
// Developed   : 04-03-2007
// Last updated: 14-04-2007
//
// IMPORTANT NOTES:
// ----------------
// o This software is provided 'as-is', without any expressed or implied warranty.                                                             //
// o In no event will the author be held liable for any damages arising from the use of this software.
// o VERY IMPORTANT: DO NOT EDIT/CHANGE THIS FILE!

// WARNING - COPYRIGHTED MATERIAL:
// -------------------------------
// This code is being released as PAYware. This means that the code is copyrighted and only intented to be used on this site.
// The owner of the site does not own this piece of software but using it as a part of a license. You may not redistibute it
// or copy (chunks of it) to use it in another services or website or redistribute it over the internet. You may not rename it,
// remove this copyright text, using this software as a part of your code or saying that you wrote this software.
*/

var
 DU_ID_NAME  = "%idname%";
 DU_ID_LEFT  = "%left%";
 DU_ID_TOP   = "%top%";
 DU_ID_WIDTH = "%width%";
 DU_ID_HEIGHT = "%height%";
 DU_ID_ZINDEX = "%z-index%";
 DU_ID_CAPTION = "%caption%";
 DU_ID_CONTENT = "%content%";
 DU_ID_ACTION  = "%action%";

 DU_DIV_DIV    = '<div id="%idname%" name="%idname%" position:absolute; '+
                 'left:%left%; top:%top%; width:%width%; height:%height%; z-index:%z-index%;>'+
                 '<center>%content%</center></div>';
 DU_DIV_IFRAME = '<div id=%idname% name=%idname% position:absolute; '+
                 'left:%left%; top:%top%; width:%width%; height:%height%; z-index:%z-index%;>'+
                 '<iframe id="%idname%_iframe" name="%idname%_iframe" src="%link%" width=100% height=100%>'+
                 '</iframe></div>';
 DU_DIV_BUTTON = '<div class="du_div_button" id="%idname%" name="%idname%" position:absolute; '+
                 'left:0; top:0; width:0; height:0; z-index:%z-index%;>'+
                 '<center><a class="du_div_button_link" href="javascript:void(0);" '+
                 'OnClick="javascript:%action%;" title="%caption%">%caption%</a></center></div>';
 DU_DIV_BUTTONS = '<div class="du_div_win_buttons" id="%idname%" name="%idname%" style="position:absolute; width:100%; height:18px; z-index:%z-index%;">'+
                  '<table width="100%" height="12" border="0" cellspacing="0" cellpadding="0">'+
                  '<tr>'+
                  '<td width="100%">&nbsp;</td>'+
                  '<td class="du_div_win_button_min"><img src="lib/images/du_bt_win_minimize.gif"></td>'+
                  '<td class="du_div_win_button_max"><img src="lib/images/du_bt_win_maximize.gif"></td>'+
                  '<td class="du_div_win_button_close"><img src="lib/images/du_bt_win_close.gif"></td>'+
                  '</tr>'+
                  '</table>'+
                  '</div>';


function DU_WriteToDiv( idName, Value, bRewrite  )
// No netscape support!
{
 var o = SU_GetDiv( idName );

 if( o == null || !o.innerHTML )
  { return false; }

 if( bRewrite == undefined || !bRewrite )
  { o.innerHTML = o.innerHTML+Value; }
 else { o.innerHTML = Value; }

 return true;
}

function DU_ReadFromDiv( idName  )
// No netscape support!
{
 var o = SU_GetDiv( idName );

 if( o == null || !o.innerHTML )
  { return ""; }

 return o.innerHTML;
}

function DU_CreateDiv( idName, bVisible, iLeft, iTop, iWidth, iHeight, sHtml )
{
   if( !document || !document.createElement || !document.body || !document.body.appendChild )
    { return false; }

   var o = document.createElement( "div" );

   if( !o || !o.setAttribute )
    { return false; }

   o.setAttribute( "id", idName );
   o.setAttribute( "name", idName );

   if( o.style )
    {
      if( bVisible = undefined || bVisible )
       { o.style.visibility = "visible"; }
      else { o.style.visibility = "hidden"; }

      if( iLeft != undefined || iTop != undefined )
       {
         o.style.position = "absolute";

         if( iLeft != undefined )
          { o.style.left = iLeft; }

         if( iTop != undefined )
          { o.style.left = iTop; }
       }

      if( iWidth != undefined )
       { o.style.width = iWidth; }

      if( iHeight != undefined )
       { o.style.width = iHeight; }

      // o.style.background = "#00C";
      // o.style.border = "4px solid #000";
    }

   if( o.innerHTML && sHtml != undefined )
    { o.innerHTML = sHtml; }

   document.body.appendChild(o);

   return o;
}

function DU_DivRewrite( idName )
{
  var s = DU_ReadFromDiv( idName );
  if( s != "" )
   { DU_WriteToDiv( idName, s, true ); }
}

function DU_MoveDivUp( idName, yPosTo, yPosFrom, delay, incDelay )
{
 if( idName == undefined || yPosTo == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 if( yPosFrom == undefined )
  { var yPosFrom = SU_GetDivPos( idName )[1]; }

 if( yPosFrom <= yPosTo )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var y = ( yPosFrom + ( yPosTo - yPosFrom )*.1 );
  //alert( y );

 while( y > yPosTo )
 {
  setTimeout( "SU_SetDivTop( '"+idName+"', "+Math.round( y )+");", delay );
  delay = delay + incDelay;
  if((( yPosTo - y ) <= .5 ) && ( (yPosTo - y) >= -.5) )
  { y = yPosTo; }

  y = ( y + ( yPosTo - y )*.1 );
 }

 return true;
}

function DU_MoveDivLeft( idName, xPosTo, xPosFrom, delay, incDelay )
{
 if( idName == undefined || xPosTo == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 if( xPosFrom == undefined )
  { var xPosFrom = SU_GetDivPos( idName )[0]; }

 if( xPosFrom <= xPosTo )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( xPosFrom + ( xPosTo - xPosFrom )*.1 );

 while( x > xPosTo )
 {
  setTimeout( "SU_SetDivLeft( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;
  if((( xPosTo - x ) <= .5 ) && ( (xPosTo - x) >= -.5) )
  { x = xPosTo; }

  x = ( x + ( xPosTo - x )*.1 );
 }

 return true;
}

function DU_MoveDivDown( idName, yPosTo, yPosFrom, delay, incDelay )
{
 if( idName == undefined || yPosTo == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 if( yPosFrom == undefined )
  { var yPosFrom = SU_GetDivPos( idName )[1]; }

 if( yPosFrom >= yPosTo )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var y = ( yPosFrom + ( yPosTo - yPosFrom  )*.1 );

 while( y < yPosTo )
 {
  setTimeout( "SU_SetDivTop( '"+idName+"', "+Math.round( y )+");", delay );
  delay = delay + incDelay;

  if((( yPosTo - y ) <= .5 ) && ( (yPosTo - y) >= -.5) )
   { y = yPosTo; }

  y = ( y + ( yPosTo - y )*.1 );
 }

 return true;
}

function DU_MoveDivRight( idName, xPosTo, xPosFrom, delay, incDelay )
{
 if( idName == undefined || xPosTo == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 if( xPosFrom == undefined )
  { var xPosFrom = SU_GetDivPos( idName )[0]; }

 if( xPosFrom >= xPosTo )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( xPosFrom + ( xPosTo - xPosFrom  )*.1 );

 while( x < xPosTo )
 {
  setTimeout( "SU_SetDivLeft( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;

  if((( xPosTo - x ) <= .5 ) && ( (xPosTo - x) >= -.5) )
   { x = xPosTo; }

  x = ( x + ( xPosTo - x )*.1 );
 }

 return true;
}

function DU_MoveDivVertTo( idName, yPosTo, yPosFrom, delay, incDelay )
{
 if( idName == undefined || yPosTo == undefined )
  { return false; }

 if( yPosFrom == undefined )
  { var yPosFrom = SU_GetDivPos( idName )[1]; }

 if( yPosFrom > yPosTo )
  { return DU_MoveDivUp( idName, yPosTo, yPosFrom, delay, incDelay ); }
 else { return DU_MoveDivDown( idName, yPosTo, yPosFrom, delay, incDelay ); }
}

function DU_MoveDivHorzTo( idName, xPosTo, xPosFrom, delay, incDelay )
{
 if( idName == undefined || xPosTo == undefined )
  { return false; }

 if( xPosFrom == undefined )
  { var xPosFrom = SU_GetDivPos( idName )[0]; }

 if( xPosFrom > xPosTo )
  { return DU_MoveDivLeft( idName, xPosTo, xPosFrom, delay, incDelay ); }
 else { return DU_MoveDivRight( idName, xPosTo, xPosFrom, delay, incDelay ); }
}

function DU_MoveDivVertCenter( idName, bPageCentered, YCorr, delay, incDelay )
{
  var Size = SU_GetDivSize( idName );
  if( Size != undefined )
   {
     if( YCorr == undefined )
      { var YCorr = 0; }

     if( bPageCentered == undefined || bPageCentered == false )
      { var H = SU_GetWindowViewHeight(); }
     else { var H = SU_GetContentHeight(); }

     DU_MoveDivVertTo( idName, Math.round( ( H-Size[1]+YCorr ) / 2 ), VOID, delay, incDelay );
   }
  else return false;
}

function DU_MoveDivHorzCenter( idName, bPageCentered, XCorr, delay, incDelay )
{
  var Size = SU_GetDivSize( idName );
  if( Size != undefined )
   {
     if( XCorr == undefined )
      { var XCorr = 0; }

     if( bPageCentered == undefined || bPageCentered == false )
      { var W = SU_GetWindowViewWidth(); }
     else { var W = SU_GetContentWidth(); }

     DU_MoveDivHorzTo( idName, Math.round( ( W-Size[0]+XCorr ) / 2 ), VOID, delay, incDelay );
   }
  else return false;
}

function DU_MoveDivCenter( idName, bPageCenteredX, bPageCenteredY, XCorr, YCorr, delay, incDelay )
{
  var ResultX = DU_MoveDivHorzCenter( idName, bPageCenteredX, XCorr, delay, incDelay );
  var ResultY = DU_MoveDivVertCenter( idName, bPageCenteredY, YCorr, delay, incDelay );
  return ResultX && ResultY;
}

function DU_MoveDivTo( idName, X, Y, delay, incDelay )
{
  var ResultX = DU_MoveDivHorzTo( idName, X, VOID, delay, incDelay );
  var ResultY = DU_MoveDivVertTo( idName, Y, VOID, delay, incDelay );
  return ResultX && ResultY;
}

function DU_ShrinkDivWidth( idName, aWidth, delay, incDelay )
{
 if( idName == undefined || aWidth == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 var iCurrWidth = SU_GetDivSize( idName )[0];

 if( iCurrWidth <= aWidth )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( iCurrWidth + ( aWidth - iCurrWidth )*.1 );

 while( x > aWidth )
 {
  setTimeout( "SU_SetDivWidth( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;
  if((( aWidth - x ) <= .5 ) && ( (aWidth - x) >= -.5) )
  { x = aWidth; }

  x = ( x + ( aWidth - x )*.1 );
 }

 return true;
}

function DU_GrowDivWidth( idName, aWidth, delay, incDelay )
{
 if( idName == undefined || aWidth == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 var iCurrWidth = SU_GetDivSize( idName )[0];

 if( iCurrWidth >= aWidth )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( iCurrWidth + ( aWidth - iCurrWidth  )*.1 );

 while( x < aWidth )
 {
  setTimeout( "SU_SetDivWidth( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;

  if((( aWidth - x ) <= .5 ) && ( (aWidth - x) >= -.5) )
   { x = aWidth; }

  x = ( x + ( aWidth - x )*.1 );
 }

 return true;
}

function DU_SetDivWidth( idName, aWidth, delay, incDelay )
{
 if( idName == undefined || aWidth == undefined )
  { return false; }

 var iCurrWidth = SU_GetDivSize( idName )[0];

 if( iCurrWidth > aWidth )
  { return DU_ShrinkDivWidth( idName, aWidth, delay, incDelay ); }
 else { return DU_GrowDivWidth( idName, aWidth, delay, incDelay ); }
}

function DU_ShrinkDivHeight( idName, aHeight, delay, incDelay )
{
 if( idName == undefined || aHeight == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 var iCurrHeight = SU_GetDivSize( idName )[1];

 if( iCurrHeight <= aHeight )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( iCurrHeight + ( aHeight - iCurrHeight )*.1 );

 while( x > aHeight )
 {
  setTimeout( "SU_SetDivHeight( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;
  if((( aHeight - x ) <= .5 ) && ( (aHeight - x) >= -.5) )
  { x = aHeight; }

  x = ( x + ( aHeight - x )*.1 );
 }

 return true;
}

function DU_GrowDivHeight( idName, aHeight, delay, incDelay )
{
 if( idName == undefined || aHeight == undefined )
  { return false; }

 if( delay == undefined )
  { var delay = 250; }

 var iCurrHeight = SU_GetDivSize( idName )[1];

 if( iCurrHeight >= aHeight )
  { return false; }

 if( incDelay == undefined )
  { var incDelay = 40; }

 var x = ( iCurrHeight + ( aHeight - iCurrHeight  )*.1 );

 while( x < aHeight )
 {
  setTimeout( "SU_SetDivHeight( '"+idName+"', "+Math.round( x )+");", delay );
  delay = delay + incDelay;

  if((( aHeight - x ) <= .5 ) && ( (aHeight - x) >= -.5) )
   { x = aHeight; }

  x = ( x + ( aHeight - x )*.1 );
 }

 return true;
}

function DU_SetDivHeight( idName, aHeight, delay, incDelay )
{
 if( idName == undefined || aHeight == undefined )
  { return false; }

 var iCurrHeight = SU_GetDivSize( idName )[0];

 if( iCurrHeight > aHeight )
  { return DU_ShrinkDivHeight( idName, aHeight, delay, incDelay ); }
 else { return DU_GrowDivHeight( idName, aHeight, delay, incDelay ); }
}

function DU_ResizeDivTo( idName, aWidth, aHeight, delay, incDelay )
{
  var ResultX = DU_SetDivWidth( idName, aWidth, delay, incDelay );
  var ResultY = DU_SetDivHeight( idName, aHeight, delay, incDelay );
  return ResultX && ResultY;
}

function DU_ResizeAndCenterDivTo( idName, aWidth, aHeight, bPageCenteredX, bPageCenteredY, XCorr, YCorr, delay, incDelay )
{
  DU_SetDivWidth( idName, aWidth, delay, incDelay );
  setTimeout( "DU_SetDivHeight( '"+idName+"',"+aHeight+","+delay+","+incDelay+");", 800 );
  setTimeout( "DU_MoveDivCenter( '"+idName+"', "+bPageCenteredX+","+bPageCenteredY+","+XCorr+", "+YCorr+","+delay+","+incDelay+");", 800 );
  //return ResultX && ResultY && ResultC;
}

function DU_CreateDivButton( aTemplate, idName, idParentName, aCaption, aAction, aLeft, aTop, aWidth, aHeight )
{
 if( idName == undefined || !document || !document.getElementById )
  { return false; }

 var T  = (aTemplate == undefined) ? DU_DIV_BUTTON : aTemplate;
 var X  = (aLeft == undefined) ? 0 : aLeft;
 var Y  = (aTop == undefined) ? 0 : aTop;
 var W  = (aWidth == undefined) ? 20 : aWidth;
 var H  = (aHeight == undefined) ? 20 : aHeight;
 var C  = (aCaption == undefined || aCaption == "") ? "" : aCaption;
 var A  = (aAction == undefined || aAction == "") ? "void()" : aAction;

 if( idParentName == undefined )
  { var idParentName = ""; }

 var DivPropNames = new Array( DU_ID_NAME, DU_ID_ZINDEX, DU_ID_CAPTION, DU_ID_ACTION );

 if( idParentName != "" )
  { idName = idParentName+idName; }
 else { idName = idParentName+"_"+idName; }

 var DivProps = new Array( idName, SU_DivGetAllAbsolute().length+1, C, A );

 if( SU_DivExists( idName ))
  { SU_SetDivBounds( idName, aLeft, aTop, aWidth, aHeight ); }
 else { var s = str_replace( DivPropNames, DivProps, T );
        //alert( s );

        DU_WriteToDiv( idParentName, s );
        //SU_SetDivBounds( idName, X, Y, W, H  );
        SU_SetDivPos( idName, X, Y );
        SU_DivBringToFront( idName );
      }
}

function DU_AddWindowButtons( idName, bbtMinimize, bbtMaximize, bbtClose )
{
/* var T  = (aTemplate == undefined) ? DU_DIV_BUTTON : aTemplate;
 var X  = (aLeft == undefined) ? 0 : aLeft;
 var Y  = (aTop == undefined) ? 0 : aTop;
*/
}

function DU_MinimizeDivTo( idName, aWidth, aHeight, delay, incDelay )
{
  var ResultX = DU_SetDivWidth( idName, aWidth, delay, incDelay );
  var ResultY = DU_SetDivHeight( idName, aHeight, delay, incDelay );
  DU_CreateDivButton( DU_DIV_BUTTONS, "Button", idName, "X", "alert('hoi')" , 0, 0, 20, 20 );
  return ResultX && ResultY;
}

-->

