$(document).ready(function() {
    $(".openDIV").click(function () { 
      
	      //--------------------------------------------------------------------------------------------------
	      
	      $(".turnierItem").children(".moredetails").hide(400);
	      $(".turnierItem").find(".pfeil").css('background-position','top left');
	      
	      //--------------------------------------------------------------------------------------------------
	      
	      $(this).find(".pfeil").css('background-position','bottom left');
	      $(this).parents(".turnierItem").find(".moredetails").toggle("fast");
	      
	      //--------------------------------------------------------------------------------------------------
	      
	      var href = $(this).parents(".turnierItem").find(".facebook").html();
	     
	     	if( href.indexOf( "iframe" ) == -1 )
	      {
		      $(this).parents(".turnierItem").find(".facebook").html('<iframe src="http://www.facebook.com/plugins/like.php?href=' + href +'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=60" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:60px;" allowTransparency="true"></iframe>');
	      }
	      
	      //--------------------------------------------------------------------------------------------------
	      
	      var anfahrt = $(this).parents(".turnierItem").find(".staticmap").html();
	      var anfahrt_encode = encodeURI(anfahrt);
	     
	     	if( anfahrt.indexOf( "iframe" ) == -1 )
	      {
		      $(this).parents(".turnierItem").find(".staticmap").html('<img src="http://maps.google.com/maps/api/staticmap?center=' + anfahrt_encode + '&zoom=15&size=470x300&sensor=false&markers=size:mid|color:red|' + anfahrt_encode + '" title="' + anfahrt + '" alt="Google Maps" />');
	      }
	      
	      //--------------------------------------------------------------------------------------------------

	     	$(this).parents(".turnierItem").find(".replaceBild").each(function (index, domEle) {
	     		
	     		if( $(this).html().indexOf( "img" ) == -1 )
      		{
	        		var dateiname = $(this).html();
	        		$(this).html('<img src="/media/.turnierbilder/small/'+ dateiname +'" rel="' + dateiname + '" class="pic" alt="" />');
	     		}
	     		
	      });
	      
	      $(this).parents(".turnierItem").find(".loading").hide();

	      //--------------------------------------------------------------------------------------------------
   
    });
    
    //--------------------------------------------------------------------------------------------------
    
    $(".staticmap").click(function () { 
    	
      var addresse = $(this).children("img").attr("title");
      $(this).html('<iframe src="http://maps.google.com/maps/?q='+ addresse + '&output=embed&oe=utf8&sensor=false&key=ABQIAAAAXH63MsPFlVLgmMorcA1J1RRn8SuMMD0-ubTvn8T7pJryaqYzoxTl-Wm_ZrNagRYjMF0K8jk8RmPWiw" width="100%" height="300" frameborder="0"></iframe>');
   
    });
    
    //--------------------------------------------------------------------------------------------------
   
    $(".tabs").tabs();
    
    //--------------------------------------------------------------------------------------------------
    
});

//--------------------------------------------------------------------------------------------------

function mycarousel_initCallback(carousel)
{
	
    jQuery('#controle a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });
	
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#headerteaser').jcarousel({
        auto: 2,
        wrap: 'last',
        animation: 1200,
        wrap: null,
        initCallback: mycarousel_initCallback
    });
});

//--------------------------------------------------------------------------------------------------
