var Features = new Hash({
	// FEATURES //
	fontSmall: function() { // CSS-Datei mit kleinen Schriftgrößen laden
	  this.activeFont = this.fontSmall;

		this.cleanCSS();
		this.css.elements.small = Asset.css(this.css.paths.small);

		this.cookies.fontSmall.write("true");
		this.cookies.fontBig.dispose();
	},

	fontNormal: function() { // CSS-Datei mit mittleren Schriftgrößen laden
	  this.activeFont = this.fontNormal;

    this.cleanCSS();
    this.css.elements.normal = Asset.css(this.css.paths.normal);

		this.cookies.fontSmall.dispose();
    this.cookies.fontBig.dispose();
  },

	fontBig: function() { // CSS-Datei mit großen Schriftgrößen laden
	  this.activeFont = this.fontBig;

    this.cleanCSS();
    this.css.elements.big = Asset.css(this.css.paths.big);

		this.cookies.fontSmall.dispose();
    this.cookies.fontBig.write("true");
  },

	images: function() { // Bilder togglen
    if (this.css.elements.clean) { // war bereits aktiv, entfernen
			this.css.elements.clean = this.clean(this.css.elements.clean);
			this.activeFont();
			this.cookies.images.dispose();
		} else { // Feature aktivieren
			this.css.elements.clean = Asset.css(this.css.paths.clean);
			this.cookies.images.write("true");
		}
	},

	contrast: function() {
    if (this.css.elements.contrast) { // war bereits aktiv, entfernen
      this.css.elements.contrast = this.clean(this.css.elements.contrast);
      this.activeFont();
			this.cookies.contrast.dispose();
    } else { // Feature aktivieren
      this.css.elements.contrast = Asset.css(this.css.paths.contrast);
			this.cookies.contrast.write("true");
    }
	},

  start: function() {
		window.addEvent("domready", function() {
			if (this.cookies.fontSmall.read() == "true") this.fontSmall();
			if (this.cookies.fontBig.read()   == "true") this.fontBig();
			if (this.cookies.images.read()    == "true") this.images();
			if (this.cookies.contrast.read()  == "true") this.contrast();
		}.bind(this));

		this.activeFont = this.fontNormal;
	},

  // INTERNES //
	activeFont:    null,

  css: {
    paths: {
      small:     "/extension/hm_corporate_design_ext/design/hm_corporate_design/stylesheets/haebmau_small.css",
      normal:    "/extension/hm_corporate_design_ext/design/hm_corporate_design/stylesheets/haebmau.css",
      big:       "/extension/hm_corporate_design_ext/design/hm_corporate_design/stylesheets/haebmau_big.css",
      clean:     "/extension/hm_corporate_design_ext/design/hm_corporate_design/stylesheets/haebmau_clean.css",
	    contrast:  "/extension/hm_corporate_design_ext/design/hm_corporate_design/stylesheets/haebmau_contrast.css"
    },
    elements: {
      small:     null,
      normal:    null,
      big:       null,
      clean:     null,
			contrast:  null
    }
  },

	cookies: {
		fontSmall:   new Cookie("feature_font_small", { path: "/"}),
		fontBig:     new Cookie("feature_font_big", { path: "/"}),
		images:      new Cookie("feature_images", { path: "/"}),
		contrast:    new Cookie("feature_contrast", { path: "/"})
	},

	cleanCSS: function() { // �berfl�ssige CSS-Files entfernen
		this.css.elements.small   = this.clean(this.css.elements.small);
		this.css.elements.big     = this.clean(this.css.elements.big);
		this.css.elements.normal  = this.clean(this.css.elements.normal);
	},

	clean: function(el) { // Element aus DOM und aus Hash entfernen, wenn existent
		if (el) el.dispose();

		return null;
	}
});

Features.start();

