$(document).ready(function() {

    	$("#datepicker_von").datepicker({	showOn: "button",
						buttonImage: "__TEMPLATES/buchen/images/calendar.gif",
						buttonImageOnly: true,
						buttonText: "Kalendar zeigen",
						monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
				       	dateFormat: 'dd.mm.yy',
				       	dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerst ag','Freitag','Samstag'],
				       	dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
				       	dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','<span style="color:red;font-size:13pt">Sa</span>'],
				       	firstDay: 6,
				       	minDate: 0, 
				       	gotoCurrent: true,
				       	navigationAsDateFormat: true
				    	});


    	$("#datepicker_bis").datepicker({	showOn: "button",
						buttonImage: "__TEMPLATES/buchen/images/calendar.gif",
						buttonImageOnly: true,
						buttonText: "Kalendar zeigen",
						monthNames: ['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],
				       	dateFormat: 'dd.mm.yy',
				       	dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerst ag','Freitag','Samstag'],
				       	dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
				       	dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','<span style="color:red;font-size:13pt">Sa</span>'],
				       	firstDay: 6,
				       	minDate: 0, 
				       	gotoCurrent: true,
				       	navigationAsDateFormat: true
				    	});



	$(".hide_panel").click(function(){
	    $('#hidden_panel').slideUp('slow', function() {
	    });
	});

	$(".show_panel").click(function(){
	    $('#hidden_panel').slideDown('slow', function() {
	    });
	});

	//Scroller für Anchor setzen
	$("#main").localScroll();

	/*
	 * stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
	 * 
	 * Example: jQuery('#side_info').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 	= 260;		// parseInt($obj.parent().css('padding-top'));
		var startOffset 		= 1;		// $obj.parent().offset().top;
		var opts 			= $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 400, lockBottom:false }, 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	= 1; //$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 );
			}
		});
	};

	$('#side_info').stickyfloat({ duration: 400, offsetY: 250, startOffset: 250, lockBottom:false });


	//*** Eigenen Style definieren ***
	$.fn.qtip.styles.mystyle = // Last part is the name of the style
	{ 
		width: 300,
		background: '#424242',
		color: 'white',
		textAlign: 'left',
		
		border: {
			width: 10,
			radius: 10,
			color: '#424242'				
		},
					   
		tip: false
	}

	$(".show_fastenleiter").each(function() 
	{
		$(this).qtip(
		{
		  style: 	{ name: 'mystyle' },
		  position: 	{ corner: { target: 'topMiddle', tooltip: 'bottomMiddle' }},
		  content: 	{ url: 'jqueryhelper.php', data: { type: "show_fastenleiter", id: $(this).attr("data-userid") }, method: 'get' },
		  show: 	{ solo: true, ready: false, when: 'mouseover'},
		  hide: 	'mouseout'
		})
	});



});

