$(document).ready(function(){
	
	// uebersichtsseite - beim drueberfahren eines Navipunktes hintergrundbild anzeigen
	$("#uebersicht_navi_aktuelles").hover(
		function () {
			$("#bg_aktuelles").css({left: "1px"});
		}, 
		function () {
			$("#bg_aktuelles").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_collection").hover(
		function () {
			$("#bg_collection").css({left: "1px"});
		}, 
		function () {
			$("#bg_collection").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_brand").hover(
		function () {
			$("#bg_brand").css({left: "1px"});
		}, 
		function () {
			$("#bg_brand").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_laden").hover(
		function () {
			$("#bg_laden").css({left: "1px"});
		}, 
		function () {
			$("#bg_laden").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_presse").hover(
		function () {
			$("#bg_presse").css({left: "1px"});
		}, 
		function () {
			$("#bg_presse").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_service").hover(
		function () {
			$("#bg_service").css({left: "1px"});
		}, 
		function () {
			$("#bg_service").css({left: "-3000px"});
		}
    );
	$("#uebersicht_navi_kontakt").hover(
		function () {
			$("#bg_kontakt").css({left: "1px"});
		}, 
		function () {
			$("#bg_kontakt").css({left: "-3000px"});
		}
    );
	//$("#uebersicht_navi_shop").hover(
		// function () {
			// $("#bg_shop").css({left: "1px"});
		// }, 
		// function () {
			// $("#bg_shop").css({left: "-3000px"});
		// }
    // );
	
	// ermittle die breite des inhaltsdivs anhand aller elemente die drin sind
	$("#contenttext_inner div.cel:last").css({"margin-right": 30});
	breite = 0;
	$("#contenttext_inner div.cel").each(function(){
		breite += $(this).width();
		breite += 5; // wegen margin-right pro element
	});
	//breite += 130; // wegen margin-right des letzten elements plus puffer
	
	// wenn breite > 819px, dann zeige pfeil
	if (breite > 849) {
		$("#contentpfeil_rechts").html('<img src="/files/img/layout/contentpfeil_vor.jpg" width="33" height="39" alt="" />');
	}
	
	$("#contentpfeil_rechts").click(function(){
		$("#wrapper").width(breite+130);
		$("#contentpfeil_links").html('<img src="/files/img/layout/contentpfeil_back.jpg" width="33" height="39" alt="" />');
		$("#contentpfeil_links").css({left: breite});
		$("#contentpfeil_rechts").html('');
		aktNaviPunkt();
    });
	
	$("#contentpfeil_links").click(function(){
		$("#wrapper").width(819);
		$("#contentpfeil_links").html('');
		$("#contentpfeil_rechts").html('<img src="/files/img/layout/contentpfeil_vor.jpg" width="33" height="39" alt="" />');
		aktNaviPunkt();
    });
	
	// top-navi aktueller navipunkt
	aktNaviPunkt();
	
	// top-navi rollovereffekt
	$("#top_navi_inner img").mouseover(function(){
		aktpos = $("#top_navi_highlight").position();
		aktpos = aktpos.left;
		var pos = $(this).position();
		var pfeilpos = (pos.left+$(this).attr('width')/2)-7;
		//alert(pfeilpos);
		$("#top_navi_highlight").css({left: pfeilpos});
		// switch ($(this).attr('alt')) {
			// case 'Aktuelles':
				// $("#top_navi_highlight").css({left: pfeilpos});
			// break;
		
		// }
    });
	$("#top_navi_inner img").mouseout(function(){
		$("#top_navi_highlight").css({left: aktpos});
	});
	
	// collection navi-rollovereffekt
	$("#navileft img").hover(
      function () {
		src = $(this).attr("src"); // alten bildpfad in variable packen
		active = $(this).attr("class"); // alten bildpfad in variable packen
		if(active !== 'imgactive') // mache es nur, wenn es nicht eh schon der aktive navipunkt ist
			this.src = src.replace(/([^.]*)\.(.*)/, "$1_on.$2"); // reg-exp - vor dem punkt wird "_on" eingefuegt, da die rollovergrafik von bspw. home.gif - home_on.gif ist
      }, 
      function () {
		if(active !== 'imgactive') 
			this.src = src; // bei mouseout alten bildpfad wieder zuweisen
      }
    );
	
	// startseite
	$("#intro").hover(
      function () {
		$("#intro_left img").attr('src','./files/logo_on.gif'); 
      }, 
      function () {
		$("#intro_left img").attr('src','./files/logo.gif'); 
      }
    );
	$("#intro").click(function(){
		location.href = '19-0-Uebersichtsseite.html';
	});
	
}); 

function aktNaviPunkt() {
	akttopnavi = '';
	akttopnavi = $("#aktnavi").attr('class');
	if (akttopnavi != '') {
		$("#top_navi_inner img").each(function(){ // jeden navipunkt durchgehen
		    if ($(this).attr('alt') == akttopnavi) {
				var pos = $(this).position();
				var pfeilpos = (pos.left+$(this).attr('width')/2)-7;
				$("#top_navi_highlight").css({left: pfeilpos});
			}
		});
	}
}

