$(document).ready(function(){
	var mainWidthElem = 0;
	var baseDir = "http://www.cenotes.de/wordpress_ronix/";
	var localPath = window.location.pathname;
	var localPathArray = new Array();
	localPathArray = localPath.split("/");

	// fixe fehlerhafte Anzeige transparenter .png-Grafiken im IE6
	$.ifixpng(baseDir + "wp-content/themes/ronix/bilder/blank.gif");
	$("img").ifixpng();

	// init unternavigation
	$("#main-menu li a").each(function(){
		if ($(this).attr("title").toLowerCase().replace(" / ", "-") == localPathArray[2])
			$(this).parent().addClass("current_page_item");
		else
			$(this).parent().removeClass("current_page_item");
	});

	$(".text table thead tr td").each(function(){
		var theadVal = $(this).attr("innerHTML");
		$(this).attr("innerHTML", theadVal.replace("[", "<br />["));		
	});

	$("#inhalt div.image img").fadeIn(1200);
	
	$("#imageGallery").cycle({ 
		prev:			"#prev-image",
		next:			"#next-image",
		timeout:	5000,
		speed:		800,
		containerResize: 0
	});

	$("#slideshow").hover(function(){
		if ($("#imageGallery").children().length > 1){
			$("#imageGallery").cycle('pause');
    	$("#bildsteuerung").fadeIn(1200);
    }
  }, function(){
  	$("#imageGallery").cycle('resume');
    $("#bildsteuerung").fadeOut(600);
  });

	$("#steuerung a img").mouseover(function(){
		$(this).css('opacity', '.7');
	}).mouseout(function(){
		$(this).css('opacity', '1');
	});

	$(".project").each(function(){
		mainWidthElem++;
	});
	$(".mainwidth").css("width", mainWidthElem*250 + "px");

	$(".produktdetail-technic-icon").live('mouseover', function(){
	  var technicName = $(this).next("p").attr("innerHTML");
	 	var technicText = $(this).next("p").next("p").attr("innerHTML");
		var elemCoord = $(this).offset();

	 	$(this).parent().next()
	 		.append("<h2>" + technicName + "</h2><p>" + technicText + "</p>")
	 		.css("top", elemCoord.top-$(this).parent().next().height()-20 + "px")
	 		.css("left", "48px")
	 		.show();
	});

	$(".produktdetail-technic-icon").live('mouseout', function(){
		$(this).parent().next()
			.hide().empty();
 	});

	$("#grid").css("zIndex", 30000);
});
