// rborkowski@coco-new-media.de
function launchCenter(url, name, height, width) {
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  str += ",scrollbars=1";
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  return window.open(url, name, str);
}

// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// cookie functions
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

// if !mz - no artikels in Merkzettel - bild blau
if (!mz) {         // if ! - no waren im Merkzettel
  var mz = 0;
}

// var the_date = new Date("December 31, 2023");

function setCookie(name, value, expire) {
   top.frames.unten.document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
   + "; path=/";
}

function getCookie(Name) {
   var search = Name + "="
   if (top.frames.unten.document.cookie.length > 0) { // if there are any cookies
      offset = top.frames.unten.document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = top.frames.unten.document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = top.frames.unten.document.cookie.length
         return unescape(top.frames.unten.document.cookie.substring(offset, end))
      } 
   }
   return "";
}

var sep_item 		= "~";
var sep_quantity	= "^";
var sep_st          = "§";
var sep_gz          = "°";
 
function to_merk (param,quantity,st_kar,gz) {
  if (!gz) gz = "-";

  if (!quantity) quantity = 1;
  var value 		= getCookie('mz');

  check = confirm(param + " in den Merkzettel legen?");
  if (check) {
    mz 		= 1;
    mOn		= new Image (110,34);
    mOn.src	= "img/merkzetton.gif";
    top.frames.unten.document.images["merkzettchen"].src = eval ("mOn.src");
	value = value + sep_item + param + sep_quantity + quantity + sep_st + st_kar + sep_gz + gz; 
	setCookie('mz',value);
  }
}

function get_merk () {
  var merkzettel;
  var mz_array	= new Array();
  merkzettel = getCookie('mz');
  if (merkzettel.length > 1) {
    mz_array 	 = merkzettel.split(sep_item);
	return mz_array;
  }
  return "";
}

function merk_off() {
    mOff		= new Image (110,34);
    mOff.src	= "img/merkzett.gif";
    top.frames.unten.document.images["merkzettchen"].src = eval ("mOff.src");
}

function merk_on() {
    mOn		= new Image (110,34);
    mOn.src	= "img/merkzetton.gif";
    top.frames.unten.document.images["merkzettchen"].src = eval ("mOn.src");
}
