window.addEvent('domready', function(){
	/* hack menu */
	var menuclone = $('nav1').clone(true,true).inject('clone-container');
	menuclone.setProperty('id','nav2').removeClass('nav').addClass('nav2');
	
	var ghosts = menuclone.getChildren('li');
	ghosts.each(function(item){
		item.addClass('ghost');
		
		var parent_item = item.getProperty('id')
		item.setProperty('id','ghost-'+parent_item);
		item.addEvent('mouseenter',function() {
			$(parent_item).addClass('hover');
		});
		item.addEvent('mouseout',function() {
			$(parent_item).removeClass('hover');
		});
		
	});
	
	
});


var myAccordion;

var kspAccordion  = new Class({
  Extends: Accordion,

  initialize: function(container, toggler_class_name, element_class_name, options) { 
    this.parent(container, toggler_class_name, element_class_name, options);
    this.togglers.each(function(toggler, index){
      langTogglers = toggler.getElements('ul.flags a.lang-toggler');
      langTogglers.each(function(anchor, lIndex) {
        anchor.addEvent('click', this.toggleLang.bind(this, [anchor, toggler]));
      }, this);
    }, this);

  },

  toggleLang: function(anchor, toggler) {
    var reg = /a-(news-\d+)-(\w+)/;
    if (matches = anchor.id.match(reg)) {
      newsContainerCssId = matches[1];
      lang = matches[2];

      newsContainer = $(newsContainerCssId);
      if (!anchor.getParent().hasClass('on')) {
          anchor.getParent().getParent().getChildren('li').each(function(item){
              if ( anchor.getParent() == item ) {
                item.addClass('on');
              } else {
                item.removeClass('on');
              }
          });

          toggler.getElements('.title_lnk').each(function(item) {
            if (item.lang == lang) {
              item.removeClass('off');
            } else {
              item.addClass('off');
            }
          });


          elementToDisplay = $(newsContainer.id + '-' + lang);
          contentDiv = elementToDisplay.getFirst('div');
          if (contentDiv) {
            newHeight = contentDiv.getSize()['y']+40;
            fx = new Fx.Tween(newsContainer);
            fx.start('height', newHeight);
            $$('#' + newsContainer.id + ' .lang-container').each(function(item){
                if (item == elementToDisplay) {
                    item.removeClass('off');
                } else {
                    item.addClass('off');
                }
            });
          }
      } 
      
      if ($defined(idx = this.togglers.indexOf(toggler))) {
        if (idx != this.previous) {
          this.display(idx);
        }
      }

    }
    return false;
  }

});



function SwitchPressrel(container, eltfrom, eltto) {
//  $(eltfrom).fade(0);
$(eltfrom).addClass('hid-me');
//  $(eltto).fade(1);
$(eltto).removeClass('hid-me');
}

