// Drop down box
var dDopen = [];

function dropDown(e, wrap, did, wide, tall, callBack, linkPos, justify)
 {
  for(var i in dDopen)
    {
     $("#"+i).css({"z-index":"0"});
    }

  if(typeof(dDopen[did]) == 'undefined')
   {
    dDopen[did] = 0;
   }

  if(dDopen[did] == 0)
   {
    var off  = $(e).offset();
    var h    = $(e).height();
    var llen = $(e).width();

    // Add a blank div to the page with an ID
    $("#"+wrap).append('<div id="'+did+'"></div>');

    // Set the hieght
    if(tall > 0)
     {
      $("#"+did).height(tall);
     }

    // Get the content for the box.
    $("#"+did).html(callBack);

    // Do position last - get get widths for calculations
    // Left side of link, Right Justifty
    if(linkPos == "l" && justify == "r")
     {
      $("#"+did).css({top:off.top+h+1, left:off.left, position:"absolute", border:"1px solid #000", background:"#fff", "z-index":"2", "width":wide });
      $("#"+did).width(wide);
     }

    // Left side of link, Left Justifty  *
    if(linkPos == "l" && justify == "l")
     {
      $("#"+did).css({top:off.top+h+1, left:off.left, position:"absolute", border:"1px solid #000", background:"#fff", "z-index":"2", "width":wide });
      $("#"+did).width(wide);
     }

    // Right side of link, Right Justifty 
    if(linkPos == "r" && justify == "r")
     {
      $("#"+did).css({top:off.top+h+1, left:off.left+llen, position:"absolute", border:"1px solid #000", background:"#fff", "z-index":"2", "width":wide });
      $("#"+did).width(wide);
     }

    //alert('Link Off: '+off.left+' Link len: '+llen+' Right offset: '+(off.left+llen)+' Box width: '+wide);
    // Right side of link, Left Justifty *
    if(linkPos == "r" && justify == "l")
     {
      $("#"+did).css({top:off.top+h+1, left:(off.left+llen)-wide, position:"absolute", border:"1px solid #000", background:"#fff", "z-index":"2", "width":wide });
      $("#"+did).width(wide);
     }

    dDopen[did] = 1;
   }
  else if(dDopen[did] == 1)
   {
    $("#"+did).hide();
    dDopen[did] = 2;
   }
  else
   {
    $("#"+did).show();
    $("#"+did).css({"z-index":"2"});
    dDopen[did] = 1;
   }
 }