//MICRO SITE - AJAX MANAGER
function AjaxManager()
{
	var ajaxmanagerobject=this;
	var last_template="";
	var current_template="";
	var last_template_level=0;
	var current_template_level=0;
	var loadingTimer, loadingFrame = 1;
	this.last_click=undefined;
	this.last_last_click=undefined;

	//var running_hide_animation=0;

	//Ajax Link Bounding
	this.addLink=function(elements, template)
	{
		var load=template.load;
		var load_options=template.load_options;
		var hide=template.hide;
		var show=template.show;
		var change_css_class=template.change_css_class;
		var content_details=template.content_details;

		Core(elements).livequery(function(){
alert("livequery");
			Core.AjaxifyDebug = false;
			Core(this).ajaxify({
				tagToload: load,
				debug: true,
				loading_fn:function(){},
				loadHash:'attr:href',
				onStart: function(ajaxify_object){
					o=ajaxify_object;
					ajaxmanagerobject.last_last_click=ajaxmanagerobject.last_click;
					ajaxmanagerobject.last_click=o.object;
alert("ajax onstart");

					//cache carbage collector

					//console.info("************************ cache content ************************");
					//var popup = window.open('',"popup",'width=800,height=500,resizable=yes');
					//var table=Core(self.popup).find("body").append("<div style=\"height:500px;overflow:auto;\"><table></table></div>").find("table:last");

					//var head_table=table.html("<tr></tr>").find("tr:last");
					//head_table.append("<th>ID</th>");

					var i=0, ie=0, d=0;
					for(var n in Core.cache)
					{

				        //delete empty objects
				        var noElements = true;
				        var o = $.cache[n];

				        for (var z in o)
				        {
				            noElements = false;

							//console.debug(Core.cache[n]);
							//console.debug("=> "+typeof(Core.cache[n]['fxqueue']));

							if(typeof(Core.cache[n]['fxqueue']) == "object" && Core.cache[n]['fxqueue'].length == 0)
							{
								noElements=true;
							}

							//var table_row=table.append("<tr></tr>").find("tr:last");
							//table_row.append("<td>"+n+"</td>");

					        for (var z in Core.cache[n])
					        {
					        	ie++;
								//table_row.append("<td>"+Core.cache[n][z]+"</td>");
								//console.debug(" + "+Core.cache[n][z]);
					        }

				            break;
				        }

				        if (noElements)
				        {
							//var table_row=table.append("<tr></tr>").find("tr:last");
							//table_row.append("<td>"+n+"</td>");
				        	//table_row.append("<th>DELETED</th>");
				            delete $.cache[n];
							d++;
				        }

						i++;
					}

					//var table_row=table.append("<tr></tr>").find("tr:last");
					//table_row.append("<td>Gesamt</td>");
					//table_row.append("<td>"+i+"</td>");
					//alert("cache has "+i+" entries with a total of "+ie+" items. Deleted entries: "+d);

					/*
					 if(events)
					 {
					 	$.each(function(){
					 		$(selector).unbind(events[i]);
					 	});
					 }

					 for (var n in $.cache)
					 {
				        var noElements = true;
				        var o = $.cache[n];

				        for (var z in o)
				        {
				            noElements = false;
				            break;
				        }

				        if (noElements)
				        {
				            delete $.cache[n];
				        }
					 }
					*/



					//something funny
					//Core.cache={};
					//CoreX.cache={};

					var i=0, ie=0, d=0;
					for(var n in Core.cache)
					{
				        var o = $.cache[n];

						//console.info("cache element:");
						//console.debug(o);

						if(o['handle'])
						{
							core_element=Core(o['handle']['elem']);

							if(core_element.parents(".right_content").size()>0)
							{
								Core(o['handle']['elem']).unbind().remove();
							}
						}



/*
				        for (var z in o)
				        {
					        var element=o[z];

							console.debug(element);
					        //element.unbind().remove();
					    }*/

				        //delete $.cache[n];
					}

					//set current template
					current_template=template.name;
					current_template_level=template.level;
//alert("."+CoreX(load[e]).attr("class")+" #"+CoreX(load[e]).attr("id"));
					//process content detail manipulation
					/*
					for(var e in content_details)
					{
						processContentDetailsManipulation(o, content_details[e]);
					}*/

					/*if(template.name=="content_details")
					{*/
						//processContentDetailsManipulation(ajaxify_object);
					//}

					/*
					if(template.name=="content_details" && CoreX("#content_details_container").size()<=0)
					{
						CoreX("#content_container_value").append("<div id=\"content_details_container\"><div id=\"content_details_container_value\"></div></div>")
					}*/

					//fade out changing content
					for(var e in load)
					{
						//unbind event handler
						//CoreX("*").unbind();

						hideContent(load[e], load_options[e]);
					}

					//hide animation
					for(var i=0; i<hide.length; i++)
					{
						if(hide[i]['time']!="post")
						{
							hideContent(hide[i]['target'], hide[i]);
						}
					}

					//show animation
					for(var i=0; i<show.length; i++)
					{
						if(show[i]['time']=="pre")
						{
							showContent(show[i]['target'], show[i]);
						}
					}

				},
				onComplete: function(o){


/*
					if($.browser.mozilla && $.browser.version.substr(0,3) == "1.8" && (o.object.hasClass("intern_lightbox_link") || o.object.parent().hasClass("gallery_image_list") || o.object.parent().hasClass("prev_image_button") || o.object.parent().hasClass("next_image_button")))
					{
						CoreX.ajax({
							async: false,
							url: o.object.attr("href"),
							type: "GET",
							dataType: "html",
							success: function(html){
								CoreX(".lightbox", html).parent().appendTo("#ajax_lightbox_content_temp");
							}
						});
					}

					// search/show lightbox
					if(Core("#ajax_lightbox_content_temp").is(":not(:empty)"))
					{
						//if not exists: create lightbox container
						var lightbox_container=Core("body > #lightbox");
						if(Core("body > #lightbox").length<1)
						{
							lightbox_container=Core("<div id=\"lightbox\"></div>").appendTo("body");
						}

						//create and fill lightbox container
						lightbox_container.html(Core("#ajax_lightbox_content_temp").find("#lightbox").html())
						.fadeIn(0, function(){
							//clean temp
							Core("#ajax_lightbox_content_temp").html("");

							//Resizing
							if(CoreX(window).height()<=650)
							{
								CoreX("#site").css("top", "0px").css("margin-top", "0px");
							}
							else
							{
								CoreX("#site").css("top", "").css("margin-top", "");
							}

							lightbox_height=CoreX(".lightbox").height();

							if(CoreX(window).height()<=lightbox_height)
							{
								CoreX(".lightbox").css("top", "0px").css("margin-top", "0px");
							}
							else
							{
								CoreX(".lightbox").css("top", "").css("margin-top", "");
							}

							//initiate lightbox functions
							hotspot_lightbox_js();
							gallery_lightbox_js();
						});
					}
					else
					{
						//remove lightbox
						CoreX("#lightbox").fadeOut(400, function(){
							CoreX(this).remove();
						});
					}
*/
					//insert css
					/*if(Core("#ajax_head_content_temp").is(":not(:empty)"))
					{
						Core("head style, head link").remove();
						Core("link, style", "#ajax_head_content_temp").appendTo("head");
						Core("#ajax_head_content_temp").empty();
					}*/

					// search/change title
/*
					if(Core("#ajax_head_content_temp").find("title").length>0)
					{
						document.title = Core("#ajax_head_content_temp").find("title").text();
					}
*/
					//fade new content in
					for(var e in load)
					{
						showContent(load[e], load_options[e]);
					}

//alert("!");
					//hide animation
					for(var i=0; i<hide.length; i++)
					{
						if(hide[i]['time']=="post")
						{
							hideContent(hide[i]['target'], hide[i]);
						}
					}

					//show animation
					for(var i=0; i<show.length; i++)
					{
						if(show[i]['time']!="pre")
						{
							showContent(show[i]['target'], show[i]);
						}
					}

					//css changes
					for(var i=0; i<change_css_class.length; i++)
					{
						CoreX(change_css_class[i]['element']).addClass(change_css_class[i]['add']).removeClass(change_css_class[i]['remove']);
					}

					//hide loader layer
					/*showAnimationCallback();
					Core(".right_content_bg_clone, .target_container_bg_clone").animate({
						opacity: 0/*,
						'-moz-opacity': 0,
						filter: 'alpha(opacity=0)'*/
						/*}, 1000, "swing", function(){
							//$(".fancy_loading").hide();
							Core(this).remove();
						});*/

					//site type flag
					/* todo: funktioniert noch nicht
					if(template.name=="content")
					{
						CoreX("body").attr("class", "intern_link_site");
					}*/
					/*
					if(template.name=="dialog")
					{
						if(CoreX("body").is(".intern_link_site"))
						{
							CoreX("#lightbox_content_container_value .lightbox_close a").attr("href", "").attr("class", "");
						}
					}*/

					/*
					if(template.name=="content" && CoreX(".mod_list_navigation").hasClass("first_entry_click"))
					{
						if(CoreX(".mod_list_navigation").hasClass("textflip"))
						{
							CoreX(".mod_list_navigation .mod_list_navigation_entry_container").slideUp(0);
						}

						CoreX(".mod_list_navigation .mod_list_navigation_entry_div.active").removeClass("active");
						CoreX(".mod_list_navigation .mod_list_navigation_entry_div:first").addClass("active");

						CoreX("#content_details_container").empty();
						CoreX.ajax({
							async: true,
							url: CoreX(".mod_list_navigation .mod_list_navigation_entry_div_a:first").attr("href"),
							type: "GET",
							dataType: "html",
							success: function(html){
								CoreX("#content_details_container_value", html).appendTo("#content_details_container").fadeIn();
								Core(".mod_list_navigation").removeClass("first_entry_click").parent().jScrollPane(jscrollpane_settings);

								if(CoreX(".mod_list_navigation").hasClass("textflip"))
								{
									CoreX(".mod_list_navigation .mod_list_navigation_entry_div:first").find(".mod_list_navigation_entry_container").show("slow", function(){
										CoreX(".mod_list_navigation").parent()[0].scrollTo(".mod_list_navigation_entry_div:first");
									});
								}
							}
						});
					}*/
					/*
					var $mod_list_navigation=CoreX("#content_container_value div.mod_list_navigation");
					var $navigation_entry_divs=$mod_list_navigation.find("div.mod_list_navigation_entry_div");

					if($mod_list_navigation.hasClass("first_entry_click") /*&& CoreX("#content_details_container_value:empty").length>0*//*)
					{

						if(CoreX("#content_details_container").size()<=0)
						{
							CoreX("#content_container_value").append("<div id=\"content_details_container\"><div id=\"content_details_container_value\"></div></div>");
						}

						$navigation_entry_divs.filter(".active").removeClass("active");
						$navigation_entry_divs.filter(":first").addClass("active");

						CoreX("#content_details_container").empty();
						CoreX.ajax({
							async: false,
							url: $mod_list_navigation.find(".mod_list_navigation_entry_div_a:first").attr("href"),
							type: "GET",
							dataType: "html",
							success: function(html){

								if($mod_list_navigation.hasClass("textflip"))
								{
									$navigation_entry_divs.not(":first").find(".mod_list_navigation_entry_container").slideUp(0);

									$navigation_entry_divs.filter(":first").find(".mod_list_navigation_entry_container").show(0);
									Core(".site_layer .scroll, .start_layer .scroll").jScrollPane(jscrollpane_settings);
								}

								CoreX("#content_details_container_value", html).appendTo("#content_details_container");//.fadeIn();

								Core("#content_container_value div.mod_list_navigation").removeClass("first_entry_click");//.parent().jScrollPane(jscrollpane_settings);
								//Core(".scroll").jScrollPane(jscrollpane_settings);

								if($.browser.msie && CoreX("#lightbg, #darkbg").find("img").height() != 0)
								{
									CoreX("#lightbg, #darkbg").css("height", CoreX("#lightbg, #darkbg").find("img").height()+"px");
								}

								Core(".site_layer .scroll, .start_layer .scroll").jScrollPane(jscrollpane_settings);
							}
						});
					}
					else if($mod_list_navigation.hasClass("first_entry_click") && CoreX("#content_details_container_value:empty").length==0)
					{
						var url = window.location.href.replace("http://"+window.location.host, "").replace(window.location.hash, "");

						if($mod_list_navigation.hasClass("textflip"))
						{
							$navigation_entry_divs.find(".mod_list_navigation_entry_container").slideUp(0);

							$navigation_entry_divs.filter(":has(.mod_list_navigation_entry_div_a[href='"+url+"'])").find(".mod_list_navigation_entry_container").show("slow", function(){
								//$mod_list_navigation.parent()[0].scrollTo(".mod_list_navigation_entry_div:has(.mod_list_navigation_entry_div_a[href='"+url+"'])");
								Core(".site_layer .scroll, .start_layer .scroll").jScrollPane(jscrollpane_settings);
							});
						}
						else
						{
							//$mod_list_navigation.parent()[0].scrollTo(".mod_list_navigation_entry_div:has(.mod_list_navigation_entry_div_a[href='"+url+"'])");
							Core(".site_layer .scroll, .start_layer .scroll").jScrollPane(jscrollpane_settings);
						}
					}

					var $bg=CoreX("#lightbg, #darkbg");
					if($.browser.msie && $bg.find("img").height() != 0)
					{
						$bg.css("height", $bg.find("img").height()+"px");
					}*/


					//set last template
					last_template=current_template;
					last_template_level=current_template_level;
				}
			});

		});
	}

	//Ajax target wrapping
	this.addContainerWrapByClass=function(class_name, hide, to)
	{
		if(CoreX("#"+class_name).length<1)
		{
			//create element if not exist
			if(CoreX("."+class_name).length<1)
			{
				if(to==undefined)
				{
					to=".content";
				}

				CoreX(to).append("<div class=\""+class_name+"\" style=\"display:none;\"></div>");
			}

			//create wrap element
			var element=CoreX("<div id=\""+class_name+"\"></div>");

			if(hide)
			{
				element.css("display", "none");
			}

			//wrap
			CoreX("."+class_name).wrap(element);
		}
	}
	this.addContainer=function(class_name, to, hide)
	{
		if(to==undefined)
		{
			to=".content";
		}

		var style="";
		if(hide || hide == undefined)
		{
			style=" style=\"display:none;\"";
		}

		CoreX(to).append("<div class=\""+class_name+"\""+style+"></div>");
	}
	this.addIdContainer=function(id_name, to, hide)
	{
		if(to==undefined)
		{
			to=".content";
		}

		var style="";
		if(hide || hide == undefined)
		{
			style=" style=\"display:none;\"";
		}

		CoreX(to).append("<div id=\""+id_name+"\""+style+"></div>");
	}

	//hide content
	var hideContent=function(element, options)
	{
		if(options['noanimation'])
		{
			return;
		}

		//templates have to be different
		if(options['on_every_template_change'])
		{
			if(last_template == current_template)
			{
				return;
			}
		}


		//templates have to be different at the same level
		if(options['on_template_change'])
		{
			if(last_template == current_template && last_template_level != current_template_level)
			{
				return;
			}
		}

		//wait switch
		if(options['nohide'])
		{
			//console.debug("animation hide stopped");
			return;
		}

		var speed=300;

		if(options['speed']!="" && options['speed']!=undefined)
		{
			speed=options['speed'];
		}

		var jquery_element=Core(element);

		if(options['effect']!="" && options['effect']!=undefined)
		{
			//console.debug("animation hide effect");
			jquery_element.hide(options['effect'], {}, speed, hideAnimationCallback);
		}
		else if(options['animation']=="hide")
		{
			//console.debug("animation hide hide");
			jquery_element.hide(0, hideAnimationCallback);
			//jquery_element.css("visibility", "hidden");
		}
		else if(options['animation']=="show")
		{
			//console.debug("animation hide show");
			jquery_element.show(0, hideAnimationCallback);
			//jquery_element.css("visibility", "visible");
		}
		else if(options['animation']=="slideDown")
		{
			//console.debug("animation hide slideDown");
			jquery_element.slideDown(speed, hideAnimationCallback);
		}
		else if(options['animation']=="slideUp")
		{
			//console.debug("animation hide slideUp");
			jquery_element.slideUp(speed, hideAnimationCallback);
		}
		else if(options['animation']=="fadeOut")
		{
			//console.debug("animation hide fadeOut");
			jquery_element.fadeOut(speed, hideAnimationCallback);
		}
		else
		{
			if(options['bglayerforanimation'] != "" && options['bglayerforanimation'] != undefined && CoreX("."+options['bglayerforanimation']+"_clone").size() < 1)
			{
				CoreX("."+options['bglayerforanimation']+":not(."+options['bglayerforanimation']+"_clone"+")")
				.clone()
				.addClass(options['bglayerforanimation']+"_clone")
				.appendTo(Core("."+options['bglayerforanimation']).parent())
				.html("<div class=\"ajaxify_fancy_loading\" id=\"ajaxify_fancy_loading\"><div></div></div>")
				.css("opacity", "0")
				.css("filter", "alpha(opacity=0)")
				.css("z-index", "2")
				.animate({
					opacity: 1,
					'-moz-opacity': 1,
					filter: 'alpha(opacity=100)'
					}, 100, "swing", function(){
						//showLoading(CoreX("."+options['bglayerforanimation']).innerWidth(), CoreX("."+options['bglayerforanimation']).innerHeight());
					});

			}
			else
			{
				jquery_element.fadeOut(speed, showAnimationCallback);
			}

			//jquery_element.append("<div class=\"ajaxify_load_layer\" style=\"width:100%;height:100%;position:absolute;top:0px;left:0px;background-color:#000000;\"></div>");
		}

		//running_hide_animation+=1;
	}

	//show content
	var showContent=function(element, options, wait_switch_call)
	{
		var jquery_element=Core(element);

		if(options['noanimation'])
		{
			scrollReinitiate(jquery_element);
			showAnimationCallback();
			return;
		}

		//templates have to be different
		if(options['on_every_template_change'])
		{
			if(last_template == current_template)
			{
				return;
			}
		}

		//templates have to be different at the same level
		if(options['on_template_change'])
		{
			if(last_template == current_template && last_template_level != current_template_level)
			{
				return;
			}
		}

		//wait switch
		if(options['animationwait'] && !wait_switch_call)
		{
			//console.debug("animation wait is activated");
			var wait = setTimeout(function(){
				showContent(element, options, true);
			}, 300);

			return;
		}

		//console.debug("animation is starting");

		//animation speed calculation
		var speed=300;

		if(options['speed']!="" && options['speed']!=undefined)
		{
			speed=options['speed'];
		}

		//scrollpane reinitiate (content have to be visible for css calculation): content details change
		/*if(jquery_element.parents(".main_container_navi").find(".scroll").length>0)
		{
			jquery_element.css("display", "");
			scrollReinitiate(jquery_element.parents(".content"));
			jquery_element.css("display", "none");

			jquery_element.parents(".main_container_navi").find(".scroll").each(function(){
				this.scrollTo(".main_container_navi_links_div");
			});
		}*/

		//scrollpane reinitiate (content have to be visible for css calculation): template change

		if(jquery_element.find(".scroll").length>0)
		{
			jquery_element.css("display", "").css("display", "");
			scrollReinitiate(jquery_element);
			jquery_element.css("display", "none");
		}

		if(!wait_switch_call)
		{
			//console.debug("animation will stop");
			stopAnimations(jquery_element);
		}

		//animation type switch
		if(options['effect']!="" && options['effect']!=undefined)
		{
			//console.debug("animation effect");
			jquery_element.show(options['effect'], {}, speed, showAnimationCallback);
		}
		else if(options['animation']=="show")
		{
			//console.debug("animation show");
			jquery_element.show(0, showAnimationCallback);
			//jquery_element.css("visibility", "visible");
		}
		else if(options['animation']=="hide")
		{
			//console.debug("animation hide");
			jquery_element.hide(0, showAnimationCallback);
			//jquery_element.css("visibility", "hidden");
		}
		else if(options['animation']=="slideUp")
		{
			//console.debug("animation slideUp");
			jquery_element.slideUp(speed, showAnimationCallback);
		}
		else if(options['animation']=="slideDown")
		{
			//console.debug("animation slideDown");
			jquery_element.slideDown(speed, showAnimationCallback);
		}
		else if(options['animation']=="fadeIn")
		{
			//console.debug("animation fade in");
			jquery_element.fadeIn(speed, showAnimationCallback);
		}
		else
		{
			//show data (hide overlayer will be removed)
			var bg_layer_clone=CoreX("."+options['bglayerforanimation']+"_clone");
			if(options['bglayerforanimation'] != "" && options['bglayerforanimation'] != undefined && bg_layer_clone.is(":visible"))
			{
				//initiate data (size & positions will be calculated)
				jquery_element.show(0);

				showAnimationCallback();

				bg_layer_clone.animate({
					opacity: 0/*,
					'-moz-opacity': 0,
					filter: 'alpha(opacity=0)'*/
					}, 1000, "swing", function(){
						//$(".fancy_loading").hide();
						Core(this).remove();
					});
			}
			else
			{
				jquery_element.fadeIn(speed, showAnimationCallback);
			}
		}
	}

	var animateLoading = function() {
		if (!CoreX("#ajaxify_fancy_loading").is(':visible')){
			clearInterval(loadingTimer);
			return;
		}

		CoreX("#ajaxify_fancy_loading > div").css('top', (loadingFrame * -40) + 'px');

		loadingFrame = (loadingFrame + 1) % 12;
	};

	var showLoading = function(width, height) {
		clearInterval(loadingTimer);

		var pos = new Array(4);
		pos[0]=0;
		pos[1]=0;
		pos[2]=width;
		pos[3]=height;

		var left=(pos[2]/2)-20;
		var top=(pos[3]/2)-20;

		CoreX("#ajaxify_fancy_loading").css({'left': left, 'top': top}).show();

		loadingTimer = setInterval(animateLoading, 66);
	};

	var stopAnimations=function(jquery_element)
	{
		if(last_template_level == 1 && current_template_level == 1)
		{
			return;
		}

		jquery_element.stop().fadeTo(0, 1);
		//jquery_element.delay(300);

		//running_hide_animation-=1;
	}

	var scrollReinitiate=function(element)
	{
		Core(".site_layer .scroll, .start_layer .scroll").jScrollPane(jscrollpane_settings);
	}

	var hideAnimationCallback=function()
	{
		//running_hide_animation-=1;
	}

	var showAnimationCallback=function()
	{
		if($.browser.msie && CoreX("#lightbg, #darkbg").find("img").height() != 0)
		{
			CoreX("#lightbg, #darkbg").css("height", CoreX("#lightbg, #darkbg").find("img").height()+"px");
		}

		//IE AJAX THORN BUG HACK
		if($.browser.msie && $.browser.version.charAt(0) == "6")
		{
		/*
			//Construct 1
			$(".construct1_scrolling_text").find("h1, h2, h3, h4, h5, h6, p").each(function(){$(this).css("width", $(this).parent().css("width"));});
			$(".construct1_scrolling_text").css("width", ($(".construct1_scrolling_text").parent().width()-20)+"px");
			$(".construct1_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 2
			$(".construct2_scrolling_text").find("h1, h2, h3, h4, h5, h6, p").each(function(){$(this).css("width", $(this).parent().css("width"));});
			$(".construct2_scrolling_text").css("width", ($(".construct2_scrolling_text").parent().width()-20)+"px");
			$(".construct2_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 3
			$(".construct3_scrolling_text").css("width", ($(".construct3_scrolling_text").parent().width()-20)+"px");
			$(".construct3_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 4
			$(".construct_4 .scroll").jScrollPane(jscrollpane_settings);

			//Construct 5
			$(".construct5 .construct5_image").css("top", "16px").css("left", "-1px").parent().find(".jScrollPaneContainer").css("top", "45px");
			$(".construct5_scrolling_text").css("width", ($(".construct5_scrolling_text").parent().width()-20)+"px");
			$(".construct5_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 6
			$(".c6_scroll_bar_design_hack").css("right", "0px");
			$(".construct6_linklist").css("width", ($(".construct6_linklist").parent().width()-20)+"px");
			$(".construct6_linklist.scroll").jScrollPane(jscrollpane_settings);
			$(".construct6_scrolling_text").css("width", ($(".construct6_scrolling_text").parent().width()-20)+"px");
			$(".construct6_scrolling_text.scroll").jScrollPane(jscrollpane_settings);

			//Construct 7
			$(".construct7_linklist").css("width", ($(".construct7_linklist").parent().width()-20)+"px");
			$(".construct7_linklist.scroll").jScrollPane(jscrollpane_settings);

			//Construct 8
			$(".construct8_description .scroll").css("width", ($(".construct8_description .scroll").parent().width()-20)+"px");
			$(".construct8_description .scroll").jScrollPane(jscrollpane_settings);

			//Construct 9
			$(".construct9_left .scroll").jScrollPane(jscrollpane_settings);

			//Construct 10
			$(".construct10_scrolling_text").appendTo("c10_head").find(".scroll").jScrollPane(jscrollpane_settings);
			*/
			$(".jScrollPaneContainer").css("z-index", "1");

			//GLOBAL - H1, H2, H3, H4, H5, H6, P
			$("h1, h2, h3, h4, h5, h6, p").each(function(){
				$(this).css("width", $(this).parent().css("width"));
			});
		}

		if($.browser.msie && $.browser.version.charAt(0) == "7")
		{
			/*
			//Base Layout - Navigation Black Bar
			$(".scroll_bar_hide_design_hack").css("bottom", "0px");

			//Base Layout - Orange Popups
			$(".left_content_popup").css("bottom", "0px");
			$(".left_content_popup .content_popup_select_options").css("bottom", "-5px")

			//Base Layout - Language Link List
			$(".language_options").css("bottom", "0px");

			//Construct 1
			$(".construct1_scrolling_text").find("h1, h2, h3, h4, h5, h6, p").each(function(){$(this).css("width", $(this).parent().css("width"));});
			$(".construct1_scrolling_text").css("width", ($(".construct1_scrolling_text").parent().width()-20)+"px");
			$(".construct1_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 2
			$(".construct2_image").css("top", "-16px")
				.parent().find(".scroll").jScrollPane(jscrollpane_settings)
				.parents(".right_content").find(".scroll_bar_design_hack").css("top", "60px");

			//Construct 3
			$(".construct3_scrolling_text").css("width", ($(".construct3_scrolling_text").parent().width()-20)+"px");
			$(".construct3_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 4
			$(".construct_4 .scroll").jScrollPane(jscrollpane_settings);

			//Construct 5
			$(".construct5 .construct5_image").css("top", "-16px").css("left", "-1px").parent().find(".jScrollPaneContainer").css("top", "20px");
			$(".construct5_scrolling_text").css("width", ($(".construct5_scrolling_text").parent().width()-20)+"px");
			$(".construct5_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 6
			$(".construct6_left").css("margin-left", "-15px").find(".scroll").jScrollPane(jscrollpane_settings);
			$(".construct6_right").css("right", "0px").find(".scroll").jScrollPane(jscrollpane_settings);
			$(".c6_scroll_bar_design_hack").css("right", "0px");

			//Construct 7
			$(".construct7_left").css("margin-left", "-15px").find(".scroll").jScrollPane(jscrollpane_settings);
			$(".c7_link_right").css("position", "absolute").css("right", "15px");

			$(".construct7_right a").each(function(){
				$(this).css("height", $(".c7_link_img", this).height()+$(".c7_link_arrow", this).innerHeight())
				.find(".c7_link_right").css("height", $(".c7_link_img", this).height()+$(".c7_link_arrow", this).innerHeight());
			});

			$(".construct7_left").parent().find("#content_target_container .scroll").jScrollPane(jscrollpane_settings);

			//javascript:alert($(".construct7_right a").each(function(){$(this).css("height", $(".c7_link_img", this).height()+$(".c7_link_arrow", this).innerHeight());})+$(".construct7_left").parent().find("#content_target_container .scroll").jScrollPane(jscrollpane_settings)+$(".c7_scroll_bar_design_hack").css("right", "0px")+CoreX(".c7_scroll_bar_design_hack").parent().find(".jScrollPaneContainer").css("z-index", "0"));

			//Construct 8
			$(".construct8_left").css("margin-left", "-15px").find(".scroll").jScrollPane(jscrollpane_settings);
			$(".construct8_right .c8_link_left").css("margin-right", "37px");

			//Construct 9
			$(".construct9_left").css("margin-left", "-15px").find(".scroll").jScrollPane(jscrollpane_settings);
			$(".construct9_right .c9_link_left").css("margin-right", "6px");

			//Construct 10
			$(".construct10_scrolling_text").appendTo("c10_head").find(".scroll").jScrollPane(jscrollpane_settings);

			//Image Gallery
			if($(".lightbox_gallery").size()>0 && CoreX(window).height()>lightbox_height)
			{
				$(".lightbox_gallery").parent().css("top", "50%");

				//var top=$(".lightbox_gallery").parent().css("top");
				//$(".lightbox_gallery").parent().css("top", (parseInt(top.substr(0, top.length-2))+30)+"px");

				//$(".lightbox_gallery").parent().css("top", ($(".lightbox").position().top+3)+"px");
			}
			*/
			$(".jScrollPaneContainer").css("z-index", "1");

			//GLOBAL - H1, H2, H3, H4, H5, H6, P
			$("h1, h2, h3, h4, h5, h6, p").each(function(){
				$(this).css("width", $(this).parent().css("width"));
			});
		}

		if($.browser.msie && $.browser.version.charAt(0) == "8")
		{
			/*
			//Construct 1
			$(".construct1_scrolling_text").find("h1, h2, h3, h4, h5, h6, p").each(function(){$(this).css("width", $(this).parent().css("width"));});
			$(".construct1_scrolling_text").css("width", ($(".construct1_scrolling_text").parent().width()-20)+"px");
			$(".construct1_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 2
			$(".construct2_scrolling_text").find("h1, h2, h3, h4, h5, h6, p").each(function(){$(this).css("width", $(this).parent().css("width"));});
			$(".construct2_scrolling_text").css("width", ($(".construct2_scrolling_text").parent().width()-20)+"px");
			$(".construct2_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 3
			$(".construct3_scrolling_text").css("width", ($(".construct3_scrolling_text").parent().width()-20)+"px");
			$(".construct3_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 4
			$(".construct_4 .scroll").jScrollPane(jscrollpane_settings);

			//Construct 5
			$(".construct5 .construct5_image").css("top", "-16px").css("left", "-1px").parent().find(".jScrollPaneContainer").css("top", "0px");
			$(".construct5_scrolling_text").css("width", ($(".construct5_scrolling_text").parent().width()-20)+"px");
			$(".construct5_scrolling_text.scroll").jScrollPane(jscrollpane_settings);
			$(".jScrollPaneContainer").css("z-index", "1");

			//Construct 6
			$(".c6_scroll_bar_design_hack").css("right", "0px");
			$(".construct6_linklist").css("width", ($(".construct6_linklist").parent().width()-20)+"px");
			$(".construct6_linklist.scroll").jScrollPane(jscrollpane_settings);
			$(".construct6_scrolling_text").css("width", ($(".construct6_scrolling_text").parent().width()-20)+"px");
			$(".construct6_scrolling_text.scroll").jScrollPane(jscrollpane_settings);

			//Construct 7
			$(".construct7_linklist").css("width", ($(".construct7_linklist").parent().width()-20)+"px");
			$(".construct7_linklist.scroll").jScrollPane(jscrollpane_settings);
			$(".construct7_left").parent().find("#content_target_container .scroll").jScrollPane(jscrollpane_settings);
			$(".c7_link_right").css("position", "absolute").css("right", "15px");

			//Construct 8
			$(".construct8_description .scroll").css("width", ($(".construct8_description .scroll").parent().width()-20)+"px");
			$(".construct8_description .scroll").jScrollPane(jscrollpane_settings);

			//Construct 9
			$(".construct9_left .scroll").jScrollPane(jscrollpane_settings);

			//Construct 10
			$(".construct10_scrolling_text").appendTo("c10_head").find(".scroll").jScrollPane(jscrollpane_settings);
			*/
			$(".jScrollPaneContainer").css("z-index", "1");

			//GLOBAL - H1, H2, H3, H4, H5, H6, P
			$("h1, h2, h3, h4, h5, h6, p").each(function(){
				$(this).css("width", $(this).parent().css("width"));
			});
		}

		//MICROSITE - FLASH CONTROL
		if(getFlashVersion()=="0,0,0")
		{
			//background
			//CoreX(".site_bg object, .site_bg embed").hide();
			//CoreX(".site_bg .flash_alternative_image").show();

			//constructs
			CoreX("img.flash_alternative_image").each(function(){
				CoreX(this).show().parent().find("object, embed").hide();
			});
		}
	}

	var getFlashVersion=function() {
		// ie
		try {
			try {
				// avoid fp6 minor version lookup issues
				// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
				var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
				try { axo.AllowScriptAccess = 'always';	}
				catch(e) { return '6,0,0'; }
			} catch(e) {}
			return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
		// other browsers
		} catch(e) {
			try {
				if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
					return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
				}
			} catch(e) {}
		}
		return '0,0,0';
	};

	var processContentDetailsManipulation=function(ajaxify)
	{
	/*
alert(Core(".mod_list_navigation").hasClass("first_entry_click"));
		if(Core(".mod_list_navigation").hasClass("first_entry_click"))
		{
			Core(".mod_list_navigation").removeClass("first_entry_click");
			Core(".mod_list_navigation .mod_list_navigation_entry_div_a:first").click();
		}*/

		//get clicked element
		var $element=CoreX(ajaxify.object);
		var $navigation=$element.parent().parent();

		CoreX("#content_container_value div.mod_list_navigation div.mod_list_navigation_entry_div.active").removeClass("active");
		$element.parent().filter(".mod_list_navigation_entry_div").addClass("active");

		if($navigation.hasClass("textflip") && !$navigation.hasClass("first_entry_click"))
		{
			var entry_containers=$navigation.find("div.mod_list_navigation_entry_container");
			var new_visible_entry_container=$element.parent().find("div.mod_list_navigation_entry_container");
			var unvisible_containers=entry_containers.not(new_visible_entry_container[0]);

			unvisible_containers.slideUp("slow", function(){
				new_visible_entry_container.slideDown("slow", function(){
					//$navigation.parent()[0].scrollTo(".mod_list_navigation_entry_div:eq("+($navigation.find(".mod_list_navigation_entry_div").index($element.parent()))+")");
					Core(".scroll").jScrollPane(jscrollpane_settings);
				});
			});
		}

		var $bg=CoreX("#lightbg, #darkbg");
		if($.browser.msie && $bg.find("img").height() != 0)
		{
			$bg.css("height", $bg.find("img").height()+"px");
		}

/*
		//get active element
		var old_element=element.parent().find(".main_container_navi_links_div");
		var old_url=old_element.find("a").attr("href");
		var old_name=old_element.find("a").text();

		//fade out old element content and replace it with a normal anchor
		/*old_element.find("#main_container_navi_links_p").hide(0, function(){*/
/*			old_element.replaceWith("<a href=\""+old_url+"\">"+old_name+"</a>");
		/*});*/
/*
		//replace new link with a expanded link
		element.addClass("main_container_navi_links_div_a")
			   .wrap("<div class=\"main_container_navi_links_div\"></div>")
			   .after("<div id=\"main_container_navi_links_p\" style=\"display:none;\"></div>");
*/
	}
}

//MICRO SITE - TEMPLATE MANAGER
function TemplateManager()
{
	this.templates=new Array();
	this.levels=new function()
	{
		this.main=0; //default
		this.sub=1;
		this.details=2;
	}

	this.add=function(template)
	{
		this.templates[this.templates.length]=template;
	}

	this.get=function(template_name)
	{
		for(var i=0; i<this.templates.length; i++)
		{
			if(this.templates[i].name==template_name)
			{
				return this.templates[i];
			}
		}
	}
}

//MICRO SITE - TEMPLATE
function Template(name, level)
{
	if(level==undefined)
	{
		level=0 //default
	}

	this.name=name;
	this.level=level;
	this.hide=new Array();
	this.show=new Array();
	this.load={};
	this.load_options={};
	this.change_css_class=new Array();
	this.content_details=new Array();

	/*
		mode:
			+ hide
				options:
					- target	//targeted element
					- time	//pre/post: before or after request
					- on_template_change //template change at the same level
					- on_every_template_change //template change between every levels
					- animation //animation type: show, hide, slideUp, slideDown, fade in (default)
					- effect //effect replace existing animation
					- speed //animation speed
					- nohide //(only for hide animations)
			+ show
				options:
					- same options as hide mode
			+ load
				options:
					- contentsource	//source element
					- target	//targeted element wrap(!)
					- noanimation //true/false(default) just ajax
					- hide/show options: all animation options..
			+ change_css_class
				options:
					- element
					- add
					- remove
			+ content_details //special, creates & removes html code + load mode
				options:
					- contentsource	//source element
					- target	//targeted element wrap(!)
					- noanimation //true/false(default) just ajax
					- hide/show options: all animation options..
	*/
	this.addDirective=function(mode, options)
	{

		if(mode=="load"){
			this.load[options.contentsource]=options.target;
			this.load_options[options.contentsource]=options;
		}
		else if(mode=="hide"){
			this.hide[this.hide.length]=options;
		}
		else if(mode=="show"){
			this.show[this.show.length]=options;
		}
		else if(mode=="change_css_class"){
			this.change_css_class[this.change_css_class.length]=options;
		}
		else if(mode=="content_details"){
			this.content_details[this.content_details.length]=options;
			this.load[options.contentsource]=options.target;
			this.load_options[options.contentsource]=options;
		}
	}
}

//MICRO SITE - TEMPLATE Levels