if (typeof Array.prototype.push == 'undefined') {
  Array.prototype.push = ArrayPush;
  function ArrayPush(element) { this[this.length] = element; }
}
if(typeof Array.prototype.pop == 'undefined') {
  Array.prototype.pop = ArrayPop;
  function ArrayPop() {
    var last = this[ this.length - 1 ];
    this.length--;
    return last;
  }
}
Object.extend(Array.prototype, {
  maxHeight: function() {
    var h_max=0;
    var height_rule = (!navigator.appVersion.match(/\bMSIE\b/)) ? 'min-height' : 'height';
    this.each(function(node){
		  h = parseInt(node.getStyle('height') || node.clientHeight);
      if (h > h_max) { h_max=h; }
    });
    this.invoke('setStyle',{height_rule:h_max+'px'});
    return this;
  }
});
var SiteNavigation = Class.create();
SiteNavigation.prototype = {
  initialize: function(element){
    if (!(this.element = $(element))) { return false; }
    this.lists = $A(this.element.getElementsByTagName("UL"));
  },
  getListFromDepth: function(depth){
    if (depth == 0 && this.element.tagName.toLowerCase() == 'ul') {
      return this.element;
    }
    return this.lists[depth-1];
  }
};
Event.onDOMReady(function(){
  var navigation = new SiteNavigation("nav");
  var subnav = navigation.getListFromDepth(1);
  if ((container = $('sub-nav')) && subnav) {
    if ((sibling = container.firstChild)) { container.insertBefore(subnav, sibling); }
    else { container.appendChild(subnav); }
  }
  if(typeof sIFR == "function" && !sIFR.UA.bIsIEMac){
    sIFR.setup();
  	sIFR.replaceElement(".page h1", named({sFlashSrc: "/flash/myriadpro-bold.swf", sColor: "#000"}));
  };
});

var current_example = 1;

function retuschExamples() {
	$$(".retusch-container").each(function(a,i) {
		if(i != 0){
			Element.hide(a)
		}
	});
	
	$$("#retusch-nav a").each(function(a){
		var id_num;
		Event.observe(a, 'click', function(e){
			var id_num = a.href.match(/\#example\-(.*)/i)[1]
			if(current_example != id_num && $("example-"+id_num)) {
				Element.hide("example-"+current_example);
				Element.show("example-"+id_num);
				current_example = id_num;
			}
			Event.stop(e);
		});
	});
}

Event.onDOMReady(retuschExamples);
