// JavaScript Document

jQuery(document).ready(function() {
								
onClick = ".ajax"; //Effektausloeser
grafikClass = ".effect"; //Klasse der Slidegrafik
listId = "#mainMenu"; // ID des ul-Elements
easingTimeIN = 800; //easingtime für einsliden
easingTimeOUT = 500; //easingtime fuer aussliden
easing = "easeOutBack";
contentId = "#contentWrapper"; //Id des Contentcontainers
anhang = "_pressed";
imagePfad = "./images/navi/navi_";
pressed = "_pressed";

//Ajax Content Loading OLD
				
	/**$(onClick).each(
		function(i){
			$(this).click(
				function(){
					$(contentId).css("filter","alpha(opacity=1)")
					//$("#loader").css("left", 505).css("top", 205).fadeIn(100);
					$(contentId).animate({opacity: 0}, 0);
					link = $(this).attr("href");
					cache = $(this).children('img').attr("src");
					$('.pressed').each(function(){$(this).css('marginLeft','0px');});
					$(this).children('.pressed').css('marginLeft','-224px');
					$.ajax({
						type: "POST",
						url: link,
						dataType: "html",
						success: function(html){
						  var textinsert = $(html).find(contentId).html();
						  $(contentId).empty().append(textinsert).animate({opacity: 1.0}, 400, function(){
																				 if (jQuery.browser.msie){ 
																				    this.style.removeAttribute('filter');
																				 }
																				 });
																				
						  //$("#loader").css("left", -99999).fadeOut(0);
						}
				   });
				
				return false;
			});
	});**/
	

	//Ajax Content Loading NEW
	
	$(onClick).each(
		function(i){
			$(this).click(
				function(){
					//$("#loader").css("left", 505).css("top", 205).fadeIn(100);
					oldWidth = $(contentId).width();
					oldHeight = $(contentId).height();
					$(contentId).children().addClass('old');
					
					link = $(this).attr("href");
					
					$('.pressed').each(function(){$(this).css('marginLeft','0px');}); //anderen pressed Grafiken zuruecksetzen 
					
					$(this).children('.pressed').css('marginLeft','-224px'); //Pressed Grafik anzeigen
					
					$.ajax({
						type: "POST",
						url: link,
						dataType: "html",
						success: function(html){
						  //var htmlInsert = $(html).find(contentId).css('top', (-1 * oldHeight)).css('left', (-1 * oldWidth)).html();
						  var htmlInsert = $(html).find(contentId).html();
						  $(contentId).append(htmlInsert);
						  $(contentId).children().not('.old').css('top', (-1 * oldHeight)).css('left', (-1 * oldWidth));
						  $(contentId).children().not('.old').animate({left : '0px'}, 'slow');
						  $(contentId).children('.old').animate({left : oldWidth}, 'slow', function(){$(this).remove(); $(contentId).children().not('.old').css('top', '0px').css('left', '0px')});
						  $.getScript("./js/preloadEffects.js");
					    }
				   });
				
				return false;
			});
	});
	
});
