$(document).ready(function() {
  
  //Magazine Teaser Switcher
  $(".main_teaser .block").show(); //Show Banner
  $(".main_teaser .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
  
  $(".image_thumb li:first").addClass('active'); //Add the active class (highlights the very first list item by default)
  $(".image_thumb li").hover(function(){
    //Set Variables
    var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
    var imgTitle = $(this).find('a').attr("name"); //Get Main Image URL
    var articleURL = $(this).find('a').attr("href"); //Get Main Image URL
    var imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
    var imgDescHeight = $(".main_teaser").find('.block').height(); //Find the height of the "block"

    if ($(this).is(".active")) {  //If the list item is active/selected, then...
        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
    } else { //If not active then...
        //Animate the Description
        $(".main_teaser .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { //Pull the block down (negative bottom margin of its own height)
            $(".main_teaser .block").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
            $('.main_teaser img').fadeOut(100, function() {
            	$(this).attr({ src: imgTitle , alt: imgAlt}); //Switch the main image (URL + alt tag)
            	$('.main_teaser img').fadeIn('slow');
            });
            $(".main_teaser a").attr({ href: articleURL}); //Switch the main image Link
        });
    }
    //Show active list-item
    $(".image_thumb li").removeClass('active'); //Remove class of 'active' on all list-items
    $(this).addClass('active');  //Add class of 'active' on the selected list
    return false;

}) .hover(function(){ //Hover effects on list-item
    $(this).addClass('hover'); //Add class "hover" on hover
    }, function() {
    $(this).removeClass('hover'); //Remove class "hover" on hover out
});

if ($('#coda-slider-1').length) {

//Magazine photo slider
$('#coda-slider-1').codaSlider({
           dynamicArrows: false,
           dynamicTabs: false
       });
    }
       
/* Form enhancement */       

// if placeholder isn't supported:
    if (!Modernizr.input.placeholder){
    }
    else
    {
    	$('label').css('display','none');
    	$('label.visible').css('display','block');
    }
    
$("#form").validate({
	messages: {
     lastname: "Bitte geben Sie Ihren Nachnamen ein.",
     anrede: "Bitte wählen Sie eine Anrede aus.",
     email: {
       required: "Bitte geben Sie Ihre Emailadresse ein.",
       email: "Ihre Email muss im Format name@domain.com eingegeben werden"
     }
   }
});


});

/* Google Maps */
function initialize() {
  	var geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 16,
      center: new google.maps.LatLng(-33, 151),
      mapTypeControl: false,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    
    
    
    var image = '/-/img/stierblut_map_icon.png';
    var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
    var address = 'Sendlingerstrasse 37, 80331 Munich, Germany';
    var outlet = 'Sendlingerstrasse 46, 80331 Munich, Germany';
    var outlet_icon = '/-/img/stierblut_map_icon_outlet.png';
    var woman = 'Sendlingerstrasse 35, 80331 Munich, Germany';
    var woman_icon = '/-/img/stierblut_map_icon_woman.png';
    
        geocoder.geocode( { 'address': outlet}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        var stierblutOutletMarker = new google.maps.Marker({
      		position: results[0].geometry.location,
      		map: map,
      		animation: google.maps.Animation.DROP,
      		title:"Stierblut Outlet",
      		icon: outlet_icon
  			});

      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
	geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var stierblutMarker = new google.maps.Marker({
      		position: results[0].geometry.location,
      		map: map,
      		animation: google.maps.Animation.DROP,
      		title:"Stierblut Men München",
      		icon: image
  			});

      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
    
    geocoder.geocode( { 'address': woman}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var stierblutWomanMarker = new google.maps.Marker({
      		position: results[0].geometry.location,
      		map: map,
      		animation: google.maps.Animation.DROP,
      		title:"Stierblut München",
      		icon: woman_icon
  			});

      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
    

    
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
 }
 
if ($("body").hasClass("ss-video")) {
initialize();
	 	

     }
