
// USAGE
//
// function popup_show(id, drag_id, exit_id, position, x, y, position_id)
//
// id          - id of a popup window;
// drag_id     - id of an element within popup window intended for dragging it
// exit_id     - id of an element within popup window intended for hiding it
// position    - positioning type:
//               "screen-corner", "screen-center"
//               "mouse-corner" , "mouse-center"
//               "element-right", "element-bottom"
// x, y        - offset
// position_id - for the last two types of positioning popup window will be
//               positioned relative to this element

// Log In Pop Up
// ----- Variables -------------------------------------------------------------

var popup_dragging = false;
var popup_target;
var popup_mouseX;
var popup_mouseY;
var popup_mouseposX;
var popup_mouseposY;
var popup_oldfunction;

function popup_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- popup_mousedown -------------------------------------------------------

function popup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  popup_dragging = true;
  popup_target   = this['target'];
  popup_mouseX   = ie ? window.event.clientX : e.clientX;
  popup_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       popup_oldfunction      = document.onselectstart;
  else popup_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- popup_mousemove -------------------------------------------------------

function popup_mousemove(e)
{
  if (!popup_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-popup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-popup_mouseY)+'px';

  popup_mouseX = ie ? window.event.clientX : e.clientX;
  popup_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- popup_mouseup ---------------------------------------------------------

function popup_mouseup(e)
{
  if (!popup_dragging) return;
  popup_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);

  if (ie)
       document.onselectstart = popup_oldfunction;
  else document.onmousedown   = popup_oldfunction;
}

// ----- popup_exit ------------------------------------------------------------

function popup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(popup_target);

  popup_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- popup_show ------------------------------------------------------------

function popup_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+popup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +popup_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+popup_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +popup_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = popup_mousedown;

  exit_element.onclick     = popup_exit;
}

// ----- popup_mousepos --------------------------------------------------------

function popup_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  popup_mouseposX = ie ? window.event.clientX : e.clientX;
  popup_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', popup_mousepos);
else document.addEventListener('mousedown', popup_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', popup_mousemove);
else document.addEventListener('mousemove', popup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', popup_mouseup);
else document.addEventListener('mouseup', popup_mouseup, false);


//forgot password popup
// ----- Variables -------------------------------------------------------------

var fopup_dragging = false;
var fopup_target;
var fopup_mouseX;
var fopup_mouseY;
var fopup_mouseposX;
var fopup_mouseposY;
var fopup_oldfunction;

function fopup_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- fopup_mousedown -------------------------------------------------------

function fopup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  fopup_dragging = true;
  fopup_target   = this['target'];
  fopup_mouseX   = ie ? window.event.clientX : e.clientX;
  fopup_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       fopup_oldfunction      = document.onselectstart;
  else fopup_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- fopup_mousemove -------------------------------------------------------

function fopup_mousemove(e)
{
  if (!fopup_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(fopup_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-fopup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-fopup_mouseY)+'px';

  fopup_mouseX = ie ? window.event.clientX : e.clientX;
  fopup_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- fopup_mouseup ---------------------------------------------------------

function fopup_mouseup(e)
{
  if (!fopup_dragging) return;
  fopup_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(fopup_target);

  if (ie)
       document.onselectstart = fopup_oldfunction;
  else document.onmousedown   = fopup_oldfunction;
}

// ----- fopup_exit ------------------------------------------------------------

function fopup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(fopup_target);

  fopup_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- fopup_show ------------------------------------------------------------

function fopup_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+fopup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +fopup_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+fopup_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +fopup_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = fopup_mousedown;

  exit_element.onclick     = fopup_exit;
}

// ----- fopup_mousepos --------------------------------------------------------

function fopup_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  fopup_mouseposX = ie ? window.event.clientX : e.clientX;
  fopup_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', fopup_mousepos);
else document.addEventListener('mousedown', fopup_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', fopup_mousemove);
else document.addEventListener('mousemove', fopup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', fopup_mouseup);
else document.addEventListener('mouseup', fopup_mouseup, false);

//registration popup

// USAGE
//
// function ropup_show(id, drag_id, exit_id, position, x, y, position_id)
//
// id          - id of a ropup window;
// drag_id     - id of an element within ropup window intended for dragging it
// exit_id     - id of an element within ropup window intended for hiding it
// position    - positioning type:
//               "screen-corner", "screen-center"
//               "mouse-corner" , "mouse-center"
//               "element-right", "element-bottom"
// x, y        - offset
// position_id - for the last two types of positioning ropup window will be
//               positioned relative to this element


// ----- Variables -------------------------------------------------------------

var ropup_dragging = false;
var ropup_target;
var ropup_mouseX;
var ropup_mouseY;
var ropup_mouseposX;
var ropup_mouseposY;
var ropup_oldfunction;

function ropup_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- ropup_mousedown -------------------------------------------------------

function ropup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  ropup_dragging = true;
  ropup_target   = this['target'];
  ropup_mouseX   = ie ? window.event.clientX : e.clientX;
  ropup_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       ropup_oldfunction      = document.onselectstart;
  else ropup_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- ropup_mousemove -------------------------------------------------------

function ropup_mousemove(e)
{
  if (!ropup_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(ropup_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-ropup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-ropup_mouseY)+'px';

  ropup_mouseX = ie ? window.event.clientX : e.clientX;
  ropup_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- ropup_mouseup ---------------------------------------------------------

function ropup_mouseup(e)
{
  if (!ropup_dragging) return;
  ropup_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(ropup_target);

  if (ie)
       document.onselectstart = ropup_oldfunction;
  else document.onmousedown   = ropup_oldfunction;
}

// ----- ropup_exit ------------------------------------------------------------

function ropup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(ropup_target);

  ropup_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- ropup_show ------------------------------------------------------------

function ropup_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+ropup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +ropup_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+ropup_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +ropup_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = ropup_mousedown;

  exit_element.onclick     = ropup_exit;
}

// ----- ropup_mousepos --------------------------------------------------------

function ropup_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  ropup_mouseposX = ie ? window.event.clientX : e.clientX;
  ropup_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', ropup_mousepos);
else document.addEventListener('mousedown', ropup_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', ropup_mousemove);
else document.addEventListener('mousemove', ropup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', ropup_mouseup);
else document.addEventListener('mouseup', ropup_mouseup, false);


// USAGE
//
// function topup_show(id, drag_id, exit_id, position, x, y, position_id)
//
// id          - id of a topup window;
// drag_id     - id of an element within topup window intended for dragging it
// exit_id     - id of an element within topup window intended for hiding it
// position    - positioning type:
//               "screen-corner", "screen-center"
//               "mouse-corner" , "mouse-center"
//               "element-right", "element-bottom"
// x, y        - offset
// position_id - for the last two types of positioning topup window will be
//               positioned relative to this element


// ----- Variables -------------------------------------------------------------

var topup_dragging = false;
var topup_target;
var topup_mouseX;
var topup_mouseY;
var topup_mouseposX;
var topup_mouseposY;
var topup_oldfunction;

function topup_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- topup_mousedown -------------------------------------------------------

function topup_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  topup_dragging = true;
  topup_target   = this['target'];
  topup_mouseX   = ie ? window.event.clientX : e.clientX;
  topup_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       topup_oldfunction      = document.onselectstart;
  else topup_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- topup_mousemove -------------------------------------------------------

function topup_mousemove(e)
{
  if (!topup_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(topup_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-topup_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-topup_mouseY)+'px';

  topup_mouseX = ie ? window.event.clientX : e.clientX;
  topup_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- topup_mouseup ---------------------------------------------------------

function topup_mouseup(e)
{
  if (!topup_dragging) return;
  topup_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(topup_target);

  if (ie)
       document.onselectstart = topup_oldfunction;
  else document.onmousedown   = topup_oldfunction;
}

// ----- topup_exit ------------------------------------------------------------

function topup_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(topup_target);

  topup_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- topup_show ------------------------------------------------------------

function topup_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+topup_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +topup_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+topup_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +topup_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = topup_mousedown;

  exit_element.onclick     = topup_exit;
}

// ----- topup_mousepos --------------------------------------------------------

function topup_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  topup_mouseposX = ie ? window.event.clientX : e.clientX;
  topup_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', topup_mousepos);
else document.addEventListener('mousedown', topup_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', topup_mousemove);
else document.addEventListener('mousemove', topup_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', topup_mouseup);
else document.addEventListener('mouseup', topup_mouseup, false);


// USAGE
//
// function skuin_show(id, drag_id, exit_id, position, x, y, position_id)
//
// id          - id of a skuin window;
// drag_id     - id of an element within skuin window intended for dragging it
// exit_id     - id of an element within skuin window intended for hiding it
// position    - positioning type:
//               "screen-corner", "screen-center"
//               "mouse-corner" , "mouse-center"
//               "element-right", "element-bottom"
// x, y        - offset
// position_id - for the last two types of positioning skuin window will be
//               positioned relative to this element


// ----- Variables -------------------------------------------------------------

var skuin_dragging = false;
var skuin_target;
var skuin_mouseX;
var skuin_mouseY;
var skuin_mouseposX;
var skuin_mouseposY;
var skuin_oldfunction;

function skuin_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- skuin_mousedown -------------------------------------------------------

function skuin_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  skuin_dragging = true;
  skuin_target   = this['target'];
  skuin_mouseX   = ie ? window.event.clientX : e.clientX;
  skuin_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       skuin_oldfunction      = document.onselectstart;
  else skuin_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- skuin_mousemove -------------------------------------------------------

function skuin_mousemove(e)
{
  if (!skuin_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(skuin_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-skuin_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-skuin_mouseY)+'px';

  skuin_mouseX = ie ? window.event.clientX : e.clientX;
  skuin_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- skuin_mouseup ---------------------------------------------------------

function skuin_mouseup(e)
{
  if (!skuin_dragging) return;
  skuin_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(skuin_target);

  if (ie)
       document.onselectstart = skuin_oldfunction;
  else document.onmousedown   = skuin_oldfunction;
}

// ----- skuin_exit ------------------------------------------------------------

function skuin_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(skuin_target);

  skuin_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- skuin_show ------------------------------------------------------------

function skuin_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+skuin_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +skuin_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+skuin_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +skuin_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = skuin_mousedown;

  exit_element.onclick     = skuin_exit;
}

// ----- skuin_mousepos --------------------------------------------------------

function skuin_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  skuin_mouseposX = ie ? window.event.clientX : e.clientX;
  skuin_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', skuin_mousepos);
else document.addEventListener('mousedown', skuin_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', skuin_mousemove);
else document.addEventListener('mousemove', skuin_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', skuin_mouseup);
else document.addEventListener('mouseup', skuin_mouseup, false);


//E-Mail A Rug popup

// ----- Variables -------------------------------------------------------------

var dlreq_dragging = false;
var dlreq_target;
var dlreq_mouseX;
var dlreq_mouseY;
var dlreq_mouseposX;
var dlreq_mouseposY;
var dlreq_oldfunction;

function dlreq_display(x)
{
  var win = window.open();
  for (var i in x) win.document.write(i+' = '+x[i]+'<br>');
}

// ----- dlreq_mousedown -------------------------------------------------------

function dlreq_mousedown(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  if ( ie && window.event.button != 1) return;
  if (!ie && e.button            != 0) return;

  dlreq_dragging = true;
  dlreq_target   = this['target'];
  dlreq_mouseX   = ie ? window.event.clientX : e.clientX;
  dlreq_mouseY   = ie ? window.event.clientY : e.clientY;

  if (ie)
       dlreq_oldfunction      = document.onselectstart;
  else dlreq_oldfunction      = document.onmousedown;

  if (ie)
       document.onselectstart = new Function("return false;");
  else document.onmousedown   = new Function("return false;");
}

// ----- dlreq_mousemove -------------------------------------------------------

function dlreq_mousemove(e)
{
  if (!dlreq_dragging) return;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(dlreq_target);

  var mouseX = ie ? window.event.clientX : e.clientX;
  var mouseY = ie ? window.event.clientY : e.clientY;

  element.style.left = (element.offsetLeft+mouseX-dlreq_mouseX)+'px';
  element.style.top  = (element.offsetTop +mouseY-dlreq_mouseY)+'px';

  dlreq_mouseX = ie ? window.event.clientX : e.clientX;
  dlreq_mouseY = ie ? window.event.clientY : e.clientY;
}

// ----- dlreq_mouseup ---------------------------------------------------------

function dlreq_mouseup(e)
{
  if (!dlreq_dragging) return;
  dlreq_dragging = false;

  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(dlreq_target);

  if (ie)
       document.onselectstart = dlreq_oldfunction;
  else document.onmousedown   = dlreq_oldfunction;
}

// ----- dlreq_exit ------------------------------------------------------------

function dlreq_exit(e)
{
  var ie      = navigator.appName == "Microsoft Internet Explorer";
  var element = document.getElementById(dlreq_target);

  dlreq_mouseup(e);
  element.style.visibility = 'hidden';
  element.style.display    = 'none';
}


// ----- dlreq_show ------------------------------------------------------------

function dlreq_show(id, drag_id, exit_id, position, x, y, position_id)
{
  element      = document.getElementById(id);
  drag_element = document.getElementById(drag_id);
  exit_element = document.getElementById(exit_id);

  element.style.position   = "absolute";
  element.style.visibility = "visible";
  element.style.display    = "block";

  if (position == "screen-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +y)+'px';
  }

  if (position == "screen-center")
  {
    element.style.left = (document.documentElement.scrollLeft+(document.body.clientWidth -element.clientWidth )/2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +(document.body.clientHeight-element.clientHeight)/2+y)+'px';
  }

  if (position == "mouse-corner")
  {
    element.style.left = (document.documentElement.scrollLeft+dlreq_mouseposX+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +dlreq_mouseposY+y)+'px';
  }

  if (position == "mouse-center")
  {
    element.style.left = (document.documentElement.scrollLeft+dlreq_mouseposX-element.clientWidth /2+x)+'px';
    element.style.top  = (document.documentElement.scrollTop +dlreq_mouseposY-element.clientHeight/2+y)+'px';
  }

  if (position == "element-right" || position == "element-bottom")
  {
    var position_element = document.getElementById(position_id);

    for (var p = position_element; p; p = p.offsetParent)
      if (p.style.position != 'absolute')
      {
        x += p.offsetLeft;
        y += p.offsetTop ;
      }

    if (position == "element-right" ) x += position_element.clientWidth;
    if (position == "element-bottom") y += position_element.clientHeight;

    element.style.left = x+'px';
    element.style.top  = y+'px';
  }

  drag_element['target']   = id;
  drag_element.onmousedown = dlreq_mousedown;

  exit_element.onclick     = dlreq_exit;
}

// ----- dlreq_mousepos --------------------------------------------------------

function dlreq_mousepos(e)
{
  var ie = navigator.appName == "Microsoft Internet Explorer";

  dlreq_mouseposX = ie ? window.event.clientX : e.clientX;
  dlreq_mouseposY = ie ? window.event.clientY : e.clientY;
}

// ----- Attach Events ---------------------------------------------------------

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousedown', dlreq_mousepos);
else document.addEventListener('mousedown', dlreq_mousepos, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmousemove', dlreq_mousemove);
else document.addEventListener('mousemove', dlreq_mousemove, false);

if (navigator.appName == "Microsoft Internet Explorer")
     document.attachEvent('onmouseup', dlreq_mouseup);
else document.addEventListener('mouseup', dlreq_mouseup, false);
