function init() {

	if (browserMinimal) {
	}
	else {
	  $$(".jsdontshow").setStyle("display", "none");
    
      if ($$('.thin-col a.box') ) {
          init_positioning();
      
          if ($E('.details-col') && (!$('hidden'))) {
              // no fade in
          }
          else {
              init_fadeIn();
          }
      } 
    }
    if ($$(".slideshow_div")) {
        
        $$(".slideshow_div").each(function(slideshow_div) {
            var x = new Slideshow(slideshow_div);
        });
    }
    
	
}		

var Slideshow = new Class({
    initialize: function(slideshow_div) {
        this.slideshow_div = slideshow_div;
        this.slideshow_i = 0;
        this.images = $ES("a.slideshow", slideshow_div);
        
        var nextlink = new Element("a");
          nextlink.addEvent('click', this.slideshow_shownext.bind(this) );
          nextlink.href = '#slideshow_div';
          nextlink.setHTML("next");
          nextlink.addClass("slideshow_next");

        var prevlink = new Element("a");
          prevlink.addEvent('click', this.slideshow_showprev.bind(this) );
          prevlink.href = '#slideshow_div';
          prevlink.setHTML("prev");
          prevlink.addClass("slideshow_prev");

        this.slideshow_div.adopt(nextlink).adopt(prevlink); 
        this.nextlink = nextlink;
        this.prevlink = prevlink;
        this.slideshow_show(0);
    },
    
    slideshow_display_nextprev: function() {
      if (this.slideshow_i + 1 < this.images.length) {
        this.nextlink.setStyle("display", "block");   
      }
      else {
        this.nextlink.setStyle("display", "none");   
      }

      if (this.slideshow_i > 0){
        this.prevlink.setStyle("display", "block");   
      }
      else {
        this.prevlink.setStyle("display", "none");         
      }
    },
    
    slideshow_shownext: function() {
        if (this.slideshow_i + 1 >= this.images.length)  return true;
        return this.slideshow_show(this.slideshow_i+1);
    },
    slideshow_showprev: function () {
        if (this.slideshow_i - 1 < 0) return true;
        return this.slideshow_show(this.slideshow_i-1);
    },
    slideshow_show: function(new_i) {
      if (browserMinimal) return true;
      if (!this.images.length) return true;
      
      this.slideshow_i = new_i;
      this.slideshow_display_nextprev();

      this.images.setStyle("display", "none");
      this.images[new_i].setStyle("display", "block");      
      
      return false;
    }
    
});





function init_fadeIn() {
  $$('.thin-col a.box').setStyle('display','none');
  
  var i = 0;
  $$('.thin-col a.box, .thin-col h1').each(function (box) {
    box.setStyle.pass(['display','block'],box).delay(i*500);
    i = i+1;
  });
}

function init_positioning() {
  body_padding_top = $E('body').getStyle('padding-top').toInt();

  
  if ($E('.thin-col a.box')) {
    var el;
    // if (!$chk(clicked_id) || clicked_id == 0) {
    
    el = $($E('.thin-col a.box').getProperty("id")+"d");
  
      // generate image "block" for the visual connection effect
    if (el)  {
        el.adopt(
          new Element('img').setProperty('src',"/images/layout/block.gif")
                        .setProperty('class','block')
          );
      }
  }
  // initial positioning
 
  if (($$('.thin-col a.box').length == 1)  && ($E('.details-col') && (!$('hidden')))) {
      posDetails($E('.thin-col a.box'));
  }

  // binding with the onclick event
  $$('.thin-col a.box').each(function (box) {
    box.onclick = posDetails.pass(box).bindWithEvent(box);
  });
  
  if ($$('.thin-col a.box').length == 1) posDetails($E('.thin-col a.box'));
}


var body_padding_top;
var details_col_margin_top;

function posDetails (el) {
  var clicker = $(el);
  var selectedDetail = $(clicker.id + 'd');

  if (!$chk(selectedDetail)) return true;
  
  if ($('hidden')) {
    $$('#col2 *').remove();
    var children = $('hidden').getChildren();
    for (var i = 0; i<children.length; i++) {
     $('col2').adopt(children[i]); 
    }
    if ($('col2').hasClass('thin-col')) {
     $('col2').removeClass("thin-col");
     $('col2').addClass('wide-col').addClass('details-col'); 
    }
    $('hidden').remove();
  }
  
  if ($$('.thin-col a.box').length > 1) {
    $$('.details-col div.detailsbox').setStyle('display','none');  
  }
  
  /*each(function (box) {
    if (box != selectedDetail)  {
      box.setStyle('display','none');
    }
  });*/  
  
  var offset = clicker.getCoordinates().top - body_padding_top - $E('.details-col').getStyle('margin-top').toInt();
  if (offset >= 0) {
    // moving the div and adding the block img and positioning it
      if ($chk(selectedDetail)) {
        selectedDetail.setStyle('margin-top', offset + "px" )
                  .setStyle('padding-top', '20px');
        if (selectedDetail.getParent().id == "col2") {        
                  selectedDetail.adopt(
                      $E('img.block').setStyle('top', offset + "px")
                                     .setStyle('display', 'block')
                  );
        }
      }
  }
  // display the div
  if ($chk(selectedDetail)) {
    selectedDetail.setStyle('display', 'block');
  }

  
  return false;
}