window.addEvent('domready', function() {
  $$('.country').each(addMouseEvents);
  $('schweiz-submenu').setStyle('height','0px');
  $('schweiz').addEvent('click',subMenuEvents);
});

function addMouseEvents(item,index) {
  item.addEvent('mouseenter',function(){
  	this.getPrevious().getFirst().setStyle('margin-top','0px');
  });
  item.addEvent('mouseleave',function(){
  	this.getPrevious().getFirst().setStyle('margin-top','-30px');
  });
}

function subMenuEvents() {
  $('schweiz-submenu').set('morph',{'duration':600});
  if($('schweiz-submenu').getStyle('height').toInt() == 0) {
 	$('schweiz').getFirst().setStyles({
          'color': '#ffffff',
          'background-image': 'url(images/dispatch-arrow.gif)',
          'background-repeat': 'no-repeat',
          'padding-left': '8px'
	});
    $('schweiz-submenu').morph({'height':'44px'});
  }
  else {
    $('schweiz-submenu').morph({'height':'0px'});
 	$('schweiz').getFirst().setStyles({
          'color': '',
          'background-image': '',
          'background-repeat': '',
          'padding-left': ''
	});
  }
}

function navigateToLocale(newLocale){
    if(newLocale == null || newLocale == "")
	return;

    // Overwrite the Levi's locale cookie - next time the user gets to
    // an automatic dispatcher (eu.levi.com, 501.com) the choice will
    // be remembered
    document.cookie = "LEVIS_LOCALE=" + newLocale + ";path=/";

    window.location = "/" + newLocale;
}
