var activeStyle = 'default';
var show_basket = false;

/* lightbox CONF */
var fileLoadingImage = "/skins/default/bilder/lightbox/loading.gif";		
var fileBottomNavCloseImage = "/skins/default/bilder/lightbox/closelabel.gif";

var Fenster = {
  fertig : false,

  init : function() {
    this.fertig = true;
    this.controlContentWidth();
    this.externalLinks();
    YAHOO.util.Event.addListener( 'fibo', 'click', this.gohome );
    YAHOO.util.Event.addListener( window, 'resize', this.controlContentWidth );
    SpecialFrame.init();
    if (show_basket) SpecialFrame.launch();
  },

  gohome : function() {
    top.location.href = '/';
  },

  externalLinks : function () {
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
      var anker = anchors[i];
      if (anker.getAttribute("href") && anker.getAttribute("rel") == "external") {
        anker.target = "_blank";
        var titel = anker.getAttribute("title");
        if ( (titel == null) || (titel == '') ) titel = anker.getAttribute("href");
        anker.setAttribute("title", "externer Link: " + titel);
        anker.setAttribute("class", "external");
      } else if (anker.getAttribute("href") && anker.getAttribute("rel") == "download") {
        anker.target = "_blank";
      }
    }
  },

  controlContentWidth : function () {
   	var theWidth = getBrowserWidth();
  	if ( theWidth > 950 ) document.getElementById('content').style.width = '525px';
  	else if ( theWidth < 900 ) document.getElementById('content').style.width = '385px';
  	return true;
  },

  debug : function() {
    if ( arguments.length > 0 ) document.debug.ausgabe.value = arguments[0];
  }

}

/* PopUpFrame */
var SpecialFrame = {
  effect : null,
  sichtbar : false,
  iFenster : Object,
  Rahmen : Object,
  RahmenStil : Object,
  theTop : null,

  init : function() {
 		if (Fenster.fertig) this.iFenster = document.getElementById('Special');

    this.Rahmen = document.getElementById('SpecialsFrame');
    if ( navigator.appName != "Microsoft Internet Explorer"  ) this.Rahmen.style.position = 'fixed';
  },

  launch : function() {
  	if (Fenster.fertig) {
      var jetzt = new Date(); // Controller
      var addition = '';
      if (arguments.length > 0) addition += '?FiboSession=' + arguments[0];
      if (arguments.length > 1) addition += '&add=' + arguments[1];
  		
      if (this.iFenster.src) this.iFenster.src = '/popups/basket.php' + addition;
      else window.Special.location.href = '/popups/basket.php' + addition;

  		if ( this.effect == null ) {
        this.effect = Effect.Appear('SpecialsFrame');
  			this.sichtbar = true;
  		} else if ( ( this.sichtbar == false ) && ( ( jetzt.getTime() - this.effect.finishOn ) > 0 ) ) {
        this.effect = Effect.Appear('SpecialsFrame');
  			this.sichtbar = true;
  		}

  		return false;

  	} else return true;

  },

  schliessen : function () {
  	this.sichtbar = false;
  	this.effect = Effect.Fade('SpecialsFrame');
  	return false;
  }

}

getBrowserWidth = function () {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth != 0) return document.documentElement.clientWidth;
	else if (document.body) return document.body.clientWidth;
	else return 0;
}

