$(document).ready(functions_allgemein);

/***********************************************
***********************************************/

function removeField(id) {

	$(id).remove();


}
function functions_allgemein() 
{


    /* E-Mails umwandeln: <a href="mailto:box [at-no-spam] server.tld">title</a> */
    $('a[@href^=mailto]').each(function(){
        var to_replace = '=at-no-spam=';
        var link       = $(this).attr('href').replace(to_replace, '@');
        var address    = $(this).html().replace(to_replace, '@');
        $(this).html(address);
        $(this).attr('href', link);
    });
   /*$("ul.nav").superfish({
	hoverClass	: "active",
	delay		: 0,
	animation	: {opacity:"show", height:"show"},
	speed		: "normal"
	});
   */
   $("div#slider1").codaSlider();

   $('button.add_item').click(function() {
        var id          =  document.getElementById("id").value;
        var $parent     =  $(this).parent();
        var $clone      =  $('#field0');
        var $new_field  =  "field"+id;
        var $del_button = $("<button class='remove_item' type='button' onClick='removeField(\"#field" + id + "\"); return false;'>Teilnehmer entfernen</button>");

        $clone.clone(true).hide().fadeIn("slow").insertAfter($parent).attr("id",$new_field);
        $('#'+$new_field + 'legend').insertBefore(id + '.');
        $('#'+$new_field).append($del_button);

        $('#'+$new_field+' input').attr('name', function(index) { return this.name + id; });
        $('#'+$new_field+' input').attr('id', function(index) { return this.id + id; });
        $('#'+$new_field+' input').each(function(){
             $(this).attr('value','');
        });
        
	id = (id - 1) + 2;
	document.getElementById("id").value = id;
        return false;
   });
  $('#reiseablauf> div.content_ra').hide();
  $('#reiseablauf> div.content_ra:first').fadeIn('slow');
  $('#reiseablauf> h4').click(function() {
	var $nextDiv         = $(this).next();
        var $parent          = $(this).parent();
	var $visibleSiblings = $nextDiv.siblings('div:visible');
        
	if ($visibleSiblings.length) {
	    $visibleSiblings.slideUp('fast', function() {
		$nextDiv.slideToggle('normal');
	    });
        }
        
  });
  $('.close_it').click(function(){
       var $parent = $(this).parent();
       $parent.slideUp('slow');
  });
  $('.a').click(function(){
       $('#main').css('font-size','100%');
  });
  $('.ap').click(function(){
       $('#main').css('font-size','113%');
  });
  $('.app').click(function(){
       $('#main').css('font-size','116%');
  });
}