
function eg_httpQuickGet(url){
 this.httpReq = new XMLHttpRequest();
 if (this.httpReq) {
  var that = this;
  this.httpReq.open('GET', url, false);
  this.httpReq.onreadystatechange = function() {
   if (that.httpReq.readyState == 4) {
    res = that.httpReq.responseText;
    that.httpReq = null;
   } 
  }
  this.httpReq.send(null);
 }
}

function eg_objSelectedImg(theImg) {
/*********************************************************************************
/ 
/********************************************************************************/
 function findPos(obj) {
 	var curleft = curtop = 0;
  if (obj.offsetParent) {
   do {
 		 curleft += obj.offsetLeft;
 		 curtop += obj.offsetTop;
   } while (obj = obj.offsetParent);   
  }
  return [curleft,curtop];
 }  

 var that = this;
 this.copeScroll = function() {
  this.divContainer.style.left = (findPos(this.theImg)[0] + 1) + "px";
  this.divContainer.style.top = (findPos(this.theImg)[1] + 1) + "px";
  this.divContainer.style.width = this.theImg.width + "px"; 
  this.divContainer.style.height = this.theImg.height + "px"; 
 }
 this.show = function() {
  this.divContainer.style.visibility = "visible";
  if (typeof( window[ 'eg_selectionMenu' ] ) != "undefined")
   this.divContainer.addEventListener("mouseover", eg_imgSelections.mouseOver, false);
 }
 this.hide = function() {
  if (typeof( window[ 'eg_selectionMenu' ] ) != "undefined") {
   if (eg_selectionMenu && (eg_selectionMenu.thePanel == that))
    eg_selectionMenu.hide();
  }
  this.divContainer.style.visibility = "hidden";
  if (typeof( window[ 'eg_selectionMenu' ] ) != "undefined")
 		this.divContainer.removeEventListener("mouseover", eg_imgSelections.mouseOver, false);
}
 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.theImg = theImg;
 this.idStr = this.theImg.id;
 if (this.idStr.search(/^cover\:[0-9]+|^shot\:[0-9]+\,[0-9]+/i) != -1) {
  this.args = this.idStr.split(/:|,/);
  this.displayTyp = this.args[0];
  this.artikelCode = this.args[1];
  this.idx = (this.args.length > 2 ? this.args[2] : "0");
  switch (this.displayTyp) {
   case "SHOT":
    this.dbKey = this.artikelCode + "|" + this.idx;
    break;
   case "COVER":
   case "FILM":
    this.dbKey = this.artikelCode;
    break;
  }
  this.myId = "EgImSe" + this.artikelCode + this.idx;
  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 = "1";
   css.opacity = ".7";
   css.backgroundColor = "#0099ff";
   this.divContainer = document.getElementById(this.myId);
  }
  this.copeScroll();
 }
}

/*********************************************************************************
/ sicArray (selectedImg-Collection)
/********************************************************************************/
var
  sicArray = function() {
   var that = this;
   this.click = function(ev) { 
    if (ev.button != 0)
     return;
    if (ev.ctrlKey || ev.altKey || ev.shiftKey || ev.metaKey)
     return;
    for (var i = 0; i < that.length; i++) {
     if (that[i].checkOverMe(ev)) {
      that.remove(i);
      return;
     }
    }
    if ((ev.target.tagName == "IMG") && (ev.target.id.search(/^cover\:[0-9]+|^shot\:[0-9]+\,[0-9]+/i) != -1)) {
     that.add( new eg_objSelectedImg( ev.target ) );
    }
   }
   this.scroll = function(ev){
    for (var i = 0; i < that.length; i++) {
     that[i].copeScroll(); 
    }
   }
   this.mouseOver = function(ev){
    for (var i = 0; i < that.length; i++) {
     if (that[i].checkOverMe(ev)) {
      if (eg_selectionMenu == null)
       eg_selectionMenu = new eg_objSelectionMenu();
      if (eg_selectionMenu && (eg_selectionMenu.thePanel != that[i]))
       eg_selectionMenu.show(that[i]);
      break;
     }  
    }
   }
   this.onChange = function(cbType,imgIndex){};
  }
  sicArray.prototype = new Array;
  sicArray.prototype.refresh = function() {
   for (var i=0; i<this.length; i++) {
    this[i].hide();
    if (this[i].theImg.id == this[i].idStr)
     this[i].show();
   }
  }
  sicArray.prototype.clear = function() {
   while (this.length > 0) {
    this[0].hide();
    this.splice(0,1);
   }
  }
  sicArray.prototype.add = function(item) {
   this.push(item);
   this[this.length-1].show();
   this.onChange("ADD",this.length-1);
  }
  sicArray.prototype.remove = function(index) {
   this[index].hide();
   this.splice(index,1);
   this.onChange("REMOVE",index);
  }
  sicArray.prototype.getDBKeys = function(displayTyp) {
   var lst = "";
   for (var i=0; i<this.length; i++) {
    if (!displayTyp || (this[i].displayTyp == displayTyp))
     lst += (lst == "" ? "" : ",") + this[i].dbKey;
   }
   return lst;
  }
  
function eg_getCookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function eg_init() {
 if ((eg_getCookie("myo") == "230765") && (eg_getCookie("ASID").length == 56)) {
  eg_imgSelections = new sicArray; //eg_objSelectedImgCollection();
  document.addEventListener("click", eg_imgSelections.click, false);
  window.addEventListener("resize", eg_imgSelections.scroll, false);
 }
}

var
 eg_imgSelections = null;

//only allow Firefox 2+ for now...
if (window.Iterator)
 eg_init();

