/*-----------------------------------------------------------
    to start functions
    ---------------------------------------------------------*/

// jQuery SmoothScroll | Version 10-04-30
jQuery(document).ready(function() {
$('a[href*=#]').click(function() {

   // duration in ms
   var duration=1000;

   // easing values: swing | linear
   var easing='swing';

   // get / set parameters
   var newHash=this.hash;
   var target=$(this.hash).offset().top;
   var oldLocation=window.location.href.replace(window.location.hash, '');
   var newLocation=this;

   // make sure it's the same location      
   if(oldLocation+newHash==newLocation)
   {
      // animate to target and set the hash to the window.location after the animation
      $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

         // add new hash to the browser location
         window.location.href=newLocation;
		 $("#content-sidebar a.top").fadeOut();
      });

      // cancel default click action
      return false;
   }
});
});

/*--- fancy-bilder alt-Text in a-title eintragen ------------------------------------*/
jQuery(document).ready(function() {
	$("a.fancy").each(function() {
		var altText = $(this).children().attr("alt");
		$(this).attr("title", altText);
	});
	$("a.fancy2").each(function() {
		var altText = $(this).children().attr("alt");
		$(this).attr("title", altText);
	});
});

/*--- fancybox ------------------------------------*/

		jQuery(document).ready(function() {
			jQuery("a[rel=fancy], a[rel=fancy1], a[rel=fancy2], a[rel=fancy3], a[rel=fancy4], a[rel=fancy5], a[rel=fancy6], a[rel=sfancy]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'overlayOpacity'	:	0.5,
				'overlayColor'		:	'#000',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					// return '<span id="fancybox-title-over">Bei mehreren Fotos kann mit Klick auf den linken bzw. rechten Bildteil gewechselt werden.</span>';
					return '<span id="fancybox-title-over"><strong>Bild ' + (currentIndex + 1) + ' von ' + currentArray.length + ':' + (title.length ? '&nbsp;' + title : '') + '</strong></span>';
				}
			});
			
						jQuery("a.iframe").fancybox({
				'easingIn, easingOut': true,
				'frameWidth':610,
				'frameHeight':700,
				'overlayOpacity'	:	0.3,
				'overlayColor'		:	'#cccccc'
			});
																			

		});
		
/*--- mailto-link ------------------------------------*/

		jQuery(document).ready(function() {
			$('#footer-content-adress2 span').click(function() {
				alert('Handler for .click() called.');
			});
			$(function(){
				var spt = $('#footer span.mail');
				var at = / at /;
				var dot = / dot /g;
				var addr = $(spt).text().replace(at,"@").replace(dot,".");
				$(spt).after('<a href="mailto:'+addr+'" title="E-Mail an info@breloer.de">'+ addr +'</a>')
				.hover(function(){window.status="E-Mail an info@breloer.de";}, function(){window.status="";});
				$(spt).remove();
			});
			$(function(){
				var spt = $('#content-main span.mail');
				var at = / at /;
				var dot = / dot /g;
				var addr = $(spt).text().replace(at,"@").replace(dot,".");
				$(spt).after('<a href="mailto:'+addr+'" title="E-Mail an info@breloer.de">'+ addr +'</a>')
				.hover(function(){window.status="E-Mail an info@breloer.de";}, function(){window.status="";});
				$(spt).remove();
			});
		});
		


/*--- stickyfloat ------------------------------------*/

jQuery(document).ready(function() {
	$("#content-sidebar a.top").fadeOut();
});


/*
			 * stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
			 * 
			 * Example: jQuery('#menu').stickyfloat({duration: 400});
			 * parameters:
			 * 		duration 	- the duration of the animation
			 *		startOffset - the amount of scroll offset after it the animations kicks in
			 *		offsetY		- the offset from the top when the object is animated
			 *		lockBottom	- 'true' by default, set to false if you don't want your floating box to stop at parent's bottom
			 * $Version: 05.16.2009 r1
			 * Copyright (c) 2009 Yair Even-Or
			 * vsync.design@gmail.com
			 */

			/**$.fn.stickyfloat = function(options, lockBottom) {
				var $obj 				= this;
				var parentPaddingTop 	= parseInt($obj.parent().css('padding-top'));
				var startOffset 		= $obj.parent().offset().top;
				var opts 				= $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom:true }, options);
				
				$obj.css({ position: 'absolute' });
				
				if(opts.lockBottom){
					var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
					if( bottomPos < 0 )
						bottomPos = 0;
				}
				
				$(window).scroll(function () { 
					$obj.stop(); // stop all calculations on scroll event

					var pastStartOffset			= $(document).scrollTop() > opts.startOffset;	// check if the window was scrolled down more than the start offset declared.
					var objFartherThanTopPos	= $obj.offset().top > startOffset;	// check if the object is at it's top position (starting point)
					var objBiggerThanWindow 	= $obj.outerHeight() < $(window).height();	// if the window size is smaller than the Obj size, then do not animate.
					
					// if window scrolled down more than startOffset OR obj position is greater than
					// the top position possible (+ offsetY) AND window size must be bigger than Obj size
					if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow ){ 
						var newpos = ($(document).scrollTop() -startOffset + opts.offsetY );
						if ( newpos > bottomPos )
							newpos = bottomPos;
						if ( $(document).scrollTop() < opts.startOffset ) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
							newpos = parentPaddingTop;
			
						$obj.animate({ top: newpos }, opts.duration );
						$("#content-sidebar a.top").fadeIn();
					} else {
						$("#content-sidebar a.top").fadeOut();
					}
				});
			};

jQuery(document).ready(function() {
			$("#content-sidebar").has("ul").stickyfloat({ duration: 700 });
})**/


/** Mindesthöhe für Conten-Main **/

jQuery(document).ready(function() {
			var minHeightCM = $("#content-sidebar").height();
			$("#content-main").css("min-height", minHeightCM);
})


/** Formular Fax-Feld verstecken **/

jQuery(document).ready(function() {
			$("#fax").css("display", "none");
			$("#fax").prev().css("display", "none");
			$("#fax").next().css("display", "none");
})


/** Navi-Effekt **/

hundepensionIMG = new Image();  
hundepensionIMG.src = "http://www.breloer.de/templates/breloer/images/bg-container-hundepension.jpg";

hundeschuleIMG = new Image();  
hundeschuleIMG.src = "http://www.breloer.de/templates/breloer/images/bg-container-hundeschule.jpg";

schulungszentrumIMG = new Image();  
schulungszentrumIMG.src = "http://www.breloer.de/templates/breloer/images/bg-container-schulungszentrum.jpg";

jQuery(document).ready(function() {
			$(".hundepension").hover(function() {
				$("#container").css("background", "url(" + hundepensionIMG.src + ") no-repeat center 0");
			}, function() {
				$("#container").css("background", "url(http://www.breloer.de/templates/breloer/images/bg-container.jpg) no-repeat center 0");
			});
			
			$(".hundeschule").hover(function() {
				$("#container").css("background", "url(" + hundeschuleIMG.src + ") no-repeat center 0");
			}, function() {
				$("#container").css("background", "url(http://www.breloer.de/templates/breloer/images/bg-container.jpg) no-repeat center 0");
			});
			
			$(".schulungszentrum").hover(function() {
				$("#container").css("background", "url(" + schulungszentrumIMG.src + ") no-repeat center 0");
			}, function() {
				$("#container").css("background", "url(http://www.breloer.de/templates/breloer/images/bg-container.jpg) no-repeat center 0");
			});
})
