var langHelper = {
	printDownload : 'Bild in Druckqualit&auml;t herunterladen'
	
}
$(document).ready(function(){
  
  // Lightbox
 
  $("a.fancybox").fancybox({
    'speedIn' : 400,
    'speedOut' : 300,
	'overlayColor' : '#96A0AA',
	'transitionIn' : 'elastic',
	'transitionOut' : 'elastic',
	'padding' : '16',
	'titleShow' : true,
	'titlePosition' : 'inside',
	'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
						if(currentArray.length > 1)
							return '<span id="fancybox-title"><b>' + (currentIndex + 1) + ' / ' + currentArray.length + '</b>' +(title.length ? '&nbsp;&middot;&nbsp;' + title : '') + '</span>';
						else
							return '<span id="fancybox-title">' +(title.length ? title : '') + '</span>';
					}
  });
  
  
  // Lightbox für Pressebilder
  
  $("a.fancybox_p").fancybox({
    'speedIn' : 400,
    'speedOut' : 300,
	'overlayColor' : '#96A0AA',
	'transitionIn' : 'elastic',
	'transitionOut' : 'elastic',
	'padding' : '16',
	'titleShow' : true,
	'titlePosition' : 'inside',
	'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
						var link = $(this.orig[0]).parent().attr('ref');
						if(currentArray.length > 1)
							return '<span id="fancybox-title" class="fti_with_download"><b>' + (currentIndex + 1) + ' / ' + currentArray.length + '</b>' +(title.length ? '&nbsp;&middot;&nbsp;' + title : '') + '</span><a class="download_image" href="'+link+'" target="_blank">'+langHelper.printDownload+'</a>';
						else
							return '<span id="fancybox-title" class="fti_with_download">' +(title.length ? title : '') + '</span><a class="download_image" href="'+link+'" target="_blank">'+langHelper.printDownload+'</a>';
						}

  });
  
  
  // Autosubmit
  
   $('.change_submit').change(function(){
    this.form.submit();
   });
  
  
  // Kontaktinformationen - Aufklappen
  
  $('.box_add_content').hide();
    
  $('.show_more, .contact_person img').click(function() {
  	if($(this).hasClass('show_more'))
		var baseParent =$(this).parent().parent();
	else
		var baseParent =$(this).parent();
	 $(baseParent).find('.show_more').toggleClass('hide_it');
	 $(baseParent).find('.box_add_content').slideToggle(400, function() {});
	  
  });
  
  
  // Slideshow
  if ($(document).slides) {
  	$("#slideshow").slides({
  		preload: true,
  		hoverPause: true,
  		effect: 'fade',
  		fadeSpeed: 800,
  		crossfade: true,
  		play: 8000,
  		pause: 1000,
  		pagination: true,
  		generatePagination: true
  	});
  }  
  
  
  // Vertical Carousel - Navigation Preisträger/Preisvergabe
  
  if ($(document).jcarousel) {
  	$('#vertical_carousel').jcarousel({
  		vertical: true,
  		scroll: 1,
		animation: 800
  	});
  }
  
//Karte
  
  if ($.browser.msie && $.browser.version == 6.0) {
  		// Verhindert IE6 Bug
  }
  else {   

  	$('#map_area_1').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_8');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);  		
  	}).click(function(){
		fade(1);
  	});
  	
  	$('#map_area_2').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_6');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(2);
  	});
  	
  	$('#map_area_3').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_5');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(3);
  	});
  	
  	$('#map_area_4').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_4');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(4);
  	});
  	
  	$('#map_area_5').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_9');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(5);
  	});
  	
  	$('#map_area_6').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_7');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(6);
  	});
  	
  	$('#map_area_7').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_3');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(7);
  	});
  	
  	$('#map_area_8').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_1');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(8);
  	});
  	
  	$('#map_area_9').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_2');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(9);
  	});
	
	$('#map_area_10').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_10');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(10);
  	});
	
	$('#map_area_11').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_11');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(11);
  	});
	
	$('#map_area_12').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_12');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(12);
  	});
	
	$('#map_area_13').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_13');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(13);
  	});
	
	$('#map_area_14').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_14');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(14);
  	});
	
	$('#map_area_15').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_15');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(15);
  	});
	
	$('#map_area_16').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_16');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(16);
  	});

	$('#map_area_17').mouseover(function(){
  		$('#map_hover').attr('class', 'mh_17');
  		$('#map_hover').stop(true, true).fadeIn(500);
  	}).mouseleave(function(){
  		$('#map_hover').stop(true, true).fadeOut(500);
  	}).click(function(){
		fade(17);
  	});
	
  }
  
  function fade(country) {
  if($('#marginalie').find('.map_info').length>0)
    $('#marginalie').find('article').stop(true, true).fadeOut(0);
	for (i=1; i<= 17;i++) {
		if (i==country) {
			$('#map'+i).stop(true, true).fadeIn(500);
		} else {
			//$('#map'+i).stop(true, true).fadeOut(0);
		}
	}
  }
  
});
