$(document).ready(function() {
	$(".panorama_image img").click(function() {
		var globalc = 0;
		$("#head_l img").hide();
		$("#head_l").attr("style","background-position: 0px 0px; background-image: url("+$(this).attr("src")+");");
		$("#head_r div").html("");
		$("#head_r div").append("<p><strong>"+$(this).parents("tbody").find(".panorama_headline").html()+"</strong></p>");
		$("#head_r div").append($(this).parents("tbody").find(".panorama_text").html());
		$(document).stopTime();
		$(document).everyTime(50,"hide", function(i) {
			globalc = globalc+2;
			$("#head_l").css("background-position",globalc+"px 0px");
		});
		if($(".panorama_left").length == 0)  {
			$("#head_l").append($('<div class="panorama_left"></div>').show().fadeTo(500,0.5));
			$("#head_l").append($('<div class="panorama_right"></div>').show().fadeTo(500,0.5));
			$(".panorama_left").mouseover(function() {
				var cssposi = $("#head_l").backgroundPosition();
				cssposi = cssposi.replace(/px 0px*/g, "");
				globalc = cssposi*1;
				$(document).stopTime();
				$(this).fadeTo(300,0.7);
				$(this).animate( { width:"25px" }, 300);
				$(this).css("cursor","pointer");
				$(document).everyTime(50,"hide", function(i) {
					globalc = globalc+6;
					$("#head_l").css("background-position",globalc+"px 0px");
				});
			});
			$(".panorama_right").mouseover(function() {
				var cssposi = $("#head_l").backgroundPosition();
				cssposi = cssposi.replace(/px 0px*/g, "");
				globalc = cssposi*1;
				$(document).stopTime();
				$(this).css("cursor","pointer");
				$(this).fadeTo(300,0.7);
				$(this).animate( { width:"25px" }, 300);
				$(document).everyTime(50,"hide", function(i) {
					globalc = globalc-6;
					$("#head_l").css("background-position",globalc+"px 0px");
				});
			});
			$(".panorama_left").mouseout(function() {
				$(this).animate( { width:"15px" }, 300);
				$(this).fadeTo(300,0.5);
				$(document).stopTime();
			});
			$(".panorama_right").mouseout(function() {
				$(this).animate( { width:"15px" }, 300);
				$(this).fadeTo(300,0.5);
				$(document).stopTime();
			});
		}
	})
});
(function($) {
jQuery.fn.backgroundPosition = function() {
  var p = $(this).css('background-position');
  if(typeof(p) === 'undefined') return $(this).css('background-position-x') + ' ' + $(this).css('background-position-y');
  else return p;
};
})(jQuery);


