$(document).ready(
	function() 
	{
		$("div.template_main_content>*").css("z-index", "0");
		$(".teaser_standard_orange_layer_left, .teaser_standard_orange_layer_right").css("z-index", "4");
		
		$(".overlay").click(
			function()
			{
				/* hide visibile overlays */
				$(".teaser_standard_orange_layer_left:visible, .teaser_standard_orange_layer_right:visible").removeClass("show").addClass("hide");
				
				// find the outer-overall-container
				objParent 	= $(this).parents().filter("div.teaser_standard_orange")[0];
				overlayId 	= "#" + objParent.id;
				overlayId 	= overlayId.replace("TeaserOverall", "Layer");

				// exit this function if something is wrong
				if($(overlayId) == null || $(overlayId) == 'undefined'){ return; }

				$(overlayId).removeClass("hide").addClass("show").css("z-index", "25");
				
				// get the parent object of the clicked element
				
				offsetParent 	= $(objParent).position();
				offsetVal 		= $(overlayId).position();
				
				if(jQuery.browser.msie && jQuery.browser.version < 7)
				{
					
					if($(overlayId).hasClass("teaser_standard_orange_layer_left"))
					{
						$(overlayId).css("position", "absolute").css("top", offsetParent.top + 25).css("left", offsetParent.left + 5);
					}
					else
					{
						$(overlayId).css("position", "absolute").css("top", offsetParent.top + 25).css("left", offsetParent.left - 195);
					}
					
					if(!$(this).hasClass("firstClick"))
					{
						$(this).addClass("firstClick");
						$(this).trigger('click', this);
					}
					
				}
				else
				{
					if($(overlayId).hasClass("teaser_standard_orange_layer_left"))
					{
						$(overlayId).css("top", -190).css("left", 5);
					}
					else
					{
						$(overlayId).css("top", -190).css("left", -195);
					}
				}
				
			}
		);
		
		$(".closelayer").click(
			function()
			{
				$(".teaser_standard_orange_layer_left:visible, .teaser_standard_orange_layer_right:visible").removeClass("show").addClass("hide").css("z-index", "-1");
			}
		);
	}
);

