var
 eg_selectionMenu = null;

function eg_objSelectionMenu() {
/*********************************************************************************
/ 
/********************************************************************************/
 this.copeScroll = function() {
  if (this.thePanel) {
   this.divContainer.style.left = this.thePanel.divContainer.offsetLeft + "px"; //this.thePanel.divContainer.offsetLeft + ((this.thePanel.divContainer.clientWidth - this.divContainer.offsetWidth) / 2) + "px";
   this.divContainer.style.top = this.thePanel.divContainer.offsetTop + (this.thePanel.divContainer.clientHeight - 30) + "px";
   this.divContainer.style.width = this.thePanel.divContainer.clientWidth + "px";
   this.divContainer.style.height = "17px";
  }
 }
 this.show = function(aPanel) {
  if (aPanel)
    this.thePanel = aPanel;
  this.copeScroll();
  if (eg_prepareSelectionMenu) {
   var HTMLStr = eg_prepareSelectionMenu(this.divContainer, this.thePanel);
   this.divContainer.innerHTML = HTMLStr;
  }
  this.divContainer.style.visibility = "visible";
 }
 this.hide = function() {
  this.divContainer.style.visibility = "hidden";
 }
 this.checkOverMe = function(ev) {
  var o = ev.target;
  while (o != null) {
   if (o.id == this.myId)
    break;
   o = o.parentNode;
  }
  return (o != null ? true : false);
 }
 this.thePanel = null;
 this.myId = "EgSeMe";
 this.divContainer = document.getElementById(this.myId);
 if (!this.divContainer) {
  var el = document.createElement("div");
  el.id = this.myId;
  document.body.appendChild(el);
  var css = el.style;
  css.visibility = "hidden";
  css.position = "absolute";
  css.overflow = "hidden";
  css.zIndex = "2";
  css.opacity = "1";
  css.backgroundColor = "#052655";
  this.divContainer = document.getElementById(this.myId);
 }
}

function eg_prepareSelectionMenu(divContainer,thePanel) {
 if (thePanel.displayTyp == "COVER")
  return "<div style='font-family:arial,helvetica,sans-serif; color:white; font-size:12px; text-align:center'><a href='javascript:eg_atmc(1);'>Add To Films</a> | <a href='javascript:eg_atmc();'>Add To Covers</a></div>"
 else
  return "<div style='font-family:arial,helvetica,sans-serif; font-size:12px; text-align:center'><a href='javascript:eg_atmc();'>Add To My Collection</a></div>";
}

function eg_httpQuickGet(url){
 this.httpReq = new XMLHttpRequest();
 if (this.httpReq) {
  var self = this;
  this.httpReq.open('GET', url, false);
  this.httpReq.onreadystatechange = function() {
   if (self.httpReq.readyState == 4) {
    self.httpReq = null;
   } 
  }
  this.httpReq.send(null);
 }
}

function eg_atmc(whatType) {
 var cLst = eg_imgSelections.getDBKeys("COVER");
 var sLst = eg_imgSelections.getDBKeys("SHOT");
 if (cLst) {
  if (whatType && whatType == 1)
   new eg_httpQuickGet("/act/fx/myorg/stuff.act?fx=ADDFILMS&fxlist=" + cLst)
  else
   new eg_httpQuickGet("/act/fx/myorg/stuff.act?fx=ADDCOVERS&fxlist=" + cLst);
 }
 if (sLst)
  new eg_httpQuickGet("/act/fx/myorg/stuff.act?fx=ADDSHOTS&fxlist=" + sLst);
 eg_imgSelections.clear();
}

