(function($) {
	$.fn.vAlign = function() {
		return this.each(function(i) {

			var h = $(this).height();
			var oh = $(this).outerHeight();

			var mt = (h + (oh - h)) / 2;

			mt = mt + 40;

			var win = ($(window).height()) - 80;
			//trace("win" + $(window).height() + "-h" + h + "-80");

			var scrollvar = (($(window).height())) - h - 80;
			//trace("scrollvar= " + scrollvar);

			if (scrollvar <= 0) {
				scrollvar = -(scrollvar);

				$(this).css("padding-bottom", 81 + "px");
			} else {
				$(this).css("padding-bottom", 0 + "px");
			}

			if (win - h < 11) {
				mt = 10;
				$(this).css("margin-top", mt + "px");
				$(this).css("top", "0%");
				$(this).css("position", "absolute");

			} else {
				$(this).css("margin-top", "-" + mt + "px");
				$(this).css("top", "50%");
				$(this).css("position", "absolute");
			}
			
			$(this).css("display", "inline");

		});
	};
})(jQuery);

(function($) {
	$.fn.hAlign = function() {
		return this.each(function(i) {

			var h = $(this).width();
			var oh = $(this).outerWidth();

			var mt = (h + (oh - h)) / 2;
			var win = ($(window).width());
			var scrollvar = (($(window).height())) - h;
			
			var seite = win -1135;
			// trace ("weite" + seite);
			/*
			 * if (scrollvar <= 0) { scrollvar = -(scrollvar);
			 * 
			 * $(this).css("padding-left", 81 + "px"); } else {
			 * $(this).css("padding-bottom", 0 + "px"); }
			 */

			if (win - h < 11) {
				mt = 10;
				$(this).css("margin-left", mt + "px");
				$(this).css("left", "0%");
				$(this).css("position", "absolute");

			} else {
				$(this).css("margin-left", "-" + mt + "px");
				$(this).css("left", "50%");
				$(this).css("position", "absolute");
			}
			
			$(this).css("display", "inline");

		});
	};
})(jQuery);

//---------------------------------------------------------------------------------------------

/*
(function($) {
	$.fn.vAlignPimp = function() {
		return this.each(function(i) {

			var h = $(this).height();
			var oh = $(this).outerHeight();

			var mt = (h + (oh - h)) / 2;

			mt = mt + 40;

			var win = ($(window).height()) - 80;
			//trace("win" + $(window).height() + "-h" + h + "-80");

			var scrollvar = (($(window).height())) - h - 80;
			//trace("scrollvar= " + scrollvar);

			if (scrollvar <= 0) {
				scrollvar = -(scrollvar);

				$(this).css("padding-bottom", 81 + "px");
			} else {
				$(this).css("padding-bottom", 0 + "px");
			}

			if (win - h < 11) {
				mt = 10;
				$(this).css("margin-top", mt + "px");
				$(this).css("top", "0%");
				$(this).css("position", "absolute");

			} else {
				$(this).css("margin-top", "-" + mt + "px");
				$(this).css("top", "50%");
				$(this).css("position", "absolute");
			}			
			$(this).css("display", "inline");
		});
	};
})(jQuery);


(function($) {
	$.fn.hAlignPimp = function() {
		return this.each(function(i) {

			var h = $(this).width();
			var oh = $(this).outerWidth();

			var mt = (h + (oh - h)) / 2;
			var win = ($(window).width());
			var scrollvar = (($(window).height())) - h;

			/*
			 * if (scrollvar <= 0) { scrollvar = -(scrollvar);
			 * 
			 * $(this).css("padding-left", 81 + "px"); } else {
			 * $(this).css("padding-bottom", 0 + "px"); }
			 */
/*
			if (win - h < 11) {
				mt = 0;
				$(this).css("margin-left", mt + "px");
				$(this).css("left", "0%");
				$(this).css("position", "absolute");
			} else {
				mt = 0;
				$(this).css("margin-left", "-" + mt + "px");
				$(this).css("left", "0%");
				$(this).css("position", "absolute");
			}
			$(this).css("display", "inline");
		});
	};
})(jQuery);
*/

(function($) {
	$.fn.vAlignPimp = function() {
		return this.each(function(i) {

			var h = $(this).height();
			var oh = $(this).outerHeight();

			var mt = (h + (oh - h)) / 2;

			mt = mt + 40;

			var win = ($(window).height()) - 80;
		

			//var position = $("#iframe_sleigh").offset();
			
			var scrollvar = (($(window).height())) - h - 80;
		

			if (scrollvar <= 0) {
				scrollvar = -(scrollvar);

				$(this).css("padding-bottom", 81 + "px");
			} else {
				$(this).css("padding-bottom", 0 + "px");
			}

			if (win - h < 11) {
				mt = 10;
				$(this).css("margin-top", mt + "px");
				$(this).css("top", "0%");
				$(this).css("position", "absolute");
			} else {
				$(this).css("margin-top", "-" + mt + "px");
				$(this).css("top", "50%");
				$(this).css("position", "absolute");
			}
			
			$(this).css("display", "inline");

			// Weisser Block unten
			
			var whiteBoxHeight = $(document).height() - ( $(this).offset().top  + 81 +668);
			
			 
			//var whiteBoxTop =  $(this).offset().top + 20 + 81 +652;
			// var whiteBoxTop =  $(this).offset().top +668;

   
			var lr = ($(window).width() -1135)/2 ;
					
					if (whiteBoxHeight >0){							
					    $("#whiteBox").css("left", "-" + lr + "px");
						$('#whiteBox').css("height", whiteBoxHeight);
						$('#whiteBox').css("width", $(window).width());
					}

		});
	};
})(jQuery);

(function($) {
	$.fn.hAlignPimp = function() {
		return this.each(function(i) {

			var h = $(this).width();
			var oh = $(this).outerWidth();

			var mt = (h + (oh - h)) / 2;
			var win = ($(window).width());
			var scrollvar = (($(window).height())) - h;
			
			//trace ("weite" + seite);
			
			/*
			 * if (scrollvar <= 0) { scrollvar = -(scrollvar);
			 * 
			 * $(this).css("padding-left", 81 + "px"); } else {
			 * $(this).css("padding-bottom", 0 + "px"); }
			 */

			var seite = win -1135;
			var lr = (seite/ 2); 
			
			var breite = $('#container').width();		
			
			
			if (win - h < 1) {
				mt = 0;
				$("#leftBox").css("width" , "0px");
				$("#rightBox").css("width" , "0px");
							
				$(this).css("margin-left", mt + "px");
				$(this).css("margin-right", mt + "px");
				
				$(this).css("left", "0%");
				$(this).css("position", "absolute");

			} else {
				
				$("#leftBox").css("left", "-" + lr + "px");
				$("#leftBox").css("width", lr + "px");
				
				$("#rightBox").css("right", "-" + lr + "px");
				$("#rightBox").css("width", lr + "px");
				

				$(this).css("margin-left", "-" + mt + "px");
				$(this).css("left", "50%");
				$(this).css("position", "absolute");
			}
			
			$(this).css("display", "inline");

		});
	};
})(jQuery);

