$(function(){
//	$('.jScrollArrowUp').each(function(i, up){ console.log(up); up.parentNode.parentNode.insertBefore(up, up.parentNode); });
//	$('.jScrollArrowDown').each(function(i, up){ up.parentNode.parentNode.insertBefore(up, up.parentNode.nextSibling); });
	var acclabelsAll = {
		'de': {'open': 'mehr', 'close': 'zurück', 'city':'Stadt auswählen'},		// Deutsch
		'en': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Englisch
		'es': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Spanisch
		'fr': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Französisch
		'it': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Italienisch
		'nl': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Niederländisch
		'sl': {'open': 'open', 'close': 'close', 'city':'Choose city'},		// Slowakisch
		'cz': {'open': 'open', 'close': 'close', 'city':'Choose city'}		// Tschechisch
		// ...
	};
   
   var acclabels	= acclabelsAll[$('html').attr('lang')] || acclabelsAll.de;
	$('div.accordion span.open').each(function(i, o){ $(o).html(acclabels.open); });
	$('div.accordion span.close').each(function(i, c){ $(c).html(acclabels.close); });
	$('#content').accordion({
      obj: 'div',
      objID: '#acc',
      wrapper: 'div', 
      el: '.h', 
      head: 'h1', 
      next: 'div',
      standardExpansible: true,
      callbackOnShow: function() { 
         $('.jScrollArrowUp').remove();
         $('.jScrollArrowDown').remove();
         $('div.text').jScrollPane({'scrollbarOnLeft':'true', 'showArrows':'true'});
         if( $(this).parent().parent().attr('id') == 'acc' ) {
            //$('div.text')[0].scrollTo( '#'+$(this).parent().find('h1:first').attr('id') );
         }
         return true;
      },
      callbackOnHide: function() { 
         $('.jScrollArrowUp').remove();
         $('.jScrollArrowDown').remove();
         $('div.text').jScrollPane({'scrollbarOnLeft':'true', 'showArrows':'true'});
         if( $(this).parent().parent().attr('id') == 'acc' ) {
            //$('div.text')[0].scrollTo( 0 );
         }
      }
    });
   
	if( $('*').is('div#content') ) { 
      off = $('div#content div:last').offset();
      if( (off.top+$('div#content div:last').height()) < $('#main-wrap').height() ) {
         $('div#content').css('min-height', '270px');
      }
   }
   
   if( $('*').is('div#acc') ) { 
      //if( $('#content').height() >= $('#main-wrap').height() ) {
         if( $('div.text').length > 0 ) {
            $('div.new:last').css('margin-bottom', '0');
            $('div.text').jScrollPane({'scrollbarOnLeft':'true', 'showArrows':'true'});
            if( $('.jScrollArrowDown').length ) {
               $('div.text')[0].scrollTo(0);
            }
         }
      //}
   }
   
   $('select[name=city] option:first').val( acclabels.city ).html( acclabels.city );
   
});

jQuery.fn.jScrollPane.defaults.outerArrows = true;


