function floatcam_init()
{
  var C = document.cookie;
  var p, x, y;

  // make DIV mobile (draggable)
  SET_DHTML( "divfloatcam"+CURSOR_MOVE );
  dd.elements.divfloatcam.setDropFunc( floatcam_update_cookie );

/*
  //SET_DHTML( "template_wrapdiv" );
  E = document.getElementById("template_wrapdiv");
  E.style.margin = "";
  E.style.left = "0px";
*/


  var fcWidth = 180; //dd.elements.divfloatcam.w;
  var fcHeight = 180; //dd.elements.divfloatcam.h;


  if (self.innerHeight) // all except Explorer
  {
    MaxX = self.innerWidth;
    MaxY = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
  {
    MaxX = document.documentElement.clientWidth;
    MaxY = document.documentElement.clientHeight;
  }


  var MaxX = MaxX - fcWidth - 20 /* Scrollbars */; 
  var MaxY = MaxY - fcHeight - 20;

//alert( MaxX + " " + MaxY + " " + fcWidth + " " + fcHeight + " " + document.getElementById("divfloatcam").style.width );

  // restore position of DIV
  if (C)
  {
    // extract floatcam cookie
    p = C.indexOf("floatcampos");  // find start
    if (p >= 0)                    // cookie already existing?
    {
      C = C.substr(p + 12);        // cut off everything before

      p = C.indexOf(".");          // find end of cookie
      C = C.substr( 0, p );        // cut off ending dot and possible remainder

      p = C.indexOf("|");
      x = C.substr( 0, p-2 );
      y = C.substr( p+1 );
      y = y.substr(0, y.length - 2);

      if (x > MaxX) x = MaxX;
      if (y > MaxY) y = MaxY;

      dd.elements.divfloatcam.moveTo(x, y);
    }
  }
}

function floatcam_update_cookie()
{
  var E = document.getElementById("divfloatcam");
  var x = E.style.left;
  var y = E.style.top;

  document.cookie = "floatcampos=" + x + "|" + y + ".";

  dd.elements.divfloatcam.setZ(0);
}

