function goToItem(index){
  var next = $('#content'+index);
  var contentSlider = next.parent();
  var active = contentSlider.find('.contents.active');
  var activeButton = contentSlider.find('.button.active');

  active.removeClass('active').fadeOut(600, function () {
      activeButton.removeClass('active');
      next.addClass('active').fadeIn(600);
      $('#goto'+index).addClass('active');
      contentSlider.find('.active');

  });
}

function nextItem(contentSlider){
  var currentId = contentSlider.find('.contents.active').attr('id').substr(7);
  var anz = contentSlider.find('.contents').size();
  var newId = 1;
  if(currentId < anz) newId = parseInt(currentId)+1;
  goToItem(newId);
}

function prevItem(contentSlider){
  var currentId = contentSlider.find('.contents.active').attr('id').substr(7);
  var newId = currentId-1;
  if(currentId == 0){
        newId = contentSlider.find('.contents').size();
  }
  goToItem(newId);

}

$(document).ready(function(){
	$('.menu > ul > li').hover(function() {
        
        if ($(this).is(":animated")) {
            $(this).stop();
        }
        
        if ($(this).children("ul").size() > 0) {
            var height = $(this).children("ul").height() + 50;
        } else {
            var height = 70;
        }
        
        $(this).children("ul").css("display", "block");
        $(this).animate({
                height: height
            },500,function () {
                    
        });
	}, function(){
        
        if ($(this).is(":animated")) {
            $(this).children("ul").css("display", "none");
            $(this).stop();
        }
        
        
        if ($(this).hasClass("active")) {
            var height = "70px";
        } else {
            var height = "50px"; 
        }
        
        $(this).animate({
            height: height
        },500,function() {
            $(this).children("ul").css("display", "none");
        });
	});
    
    setInterval("nextItem($('.ContentSlider'))",5000);
});

function mt(name,domain,subject,body){
	location.href = "mailto:"+name+"@"+domain+'?subject='+subject+'&body='+body;
}


