/* Planungsbuero Kagel - Javascript by g:wend Webentwicklung */

$(document).ready(function() {
	//********************************************
	// Tag-Cloud
	$(".widget_tag_cloud a").removeAttr("style");
	$(".widget_tag_cloud a").each(function(){
		$(this).wrap('<li value="'+$(this).attr("title").replace(/ topics/g, "")+'" />');
	});
	$(".widget_tag_cloud li").wrapAll("<ul />");
//	$(".widget_tag_cloud ul").tagcloud({type:"sphere",power:0.8,sizemin:10,sizemax:20,height:150,width:195,colormin:"999",colormax:"473931"});
	$(".widget_tag_cloud ul").tagcloud({type:"list",sizemin:10,sizemax:20,colormin:"999",colormax:"473931"});
	//********************************************
	
	//********************************************
	// Simulated active Archive-Links
	$(".widget_archive a").each(function(){
		if($(this).attr("title") == document.title.replace(/ \|(.)*/g, "")) {
			$(this).addClass("active");
		}
	});
	//********************************************
	
	//********************************************
	// Zeilenumbruch der Überschriften in den Kategorieübersichtsseiten
	$(".category-box .post h2.entry-title a, .right-column-post-title a").each(function(){
		$(this).html($(this).text().replace(/ \| /g, " |<br />"));
	});
	//********************************************
	
	//********************************************
	// Bildergalerie
	$(".left-column-post .size-thumbnail").hide();
	$(".left-column-post .size-thumbnail").parent().hide();

	var firstContentImageAlt = $(".entry-content img:first").attr("alt");
	var firstContentImageDesc = $(".entry-content img:first").parent().find(".wp-caption-text").text();

	$(".right-column-post .gallery-thumb").each(function(){
		$(this).attr("image",$(this).attr("href"));
		$(this).removeAttr("href");
		
		// Verbergen wenn gleich alt-Tag wie großes Bild
		if($(this).attr("rel") == firstContentImageAlt || $(this).attr("rel") == firstContentImageDesc) {
			$(this).animate({
				opacity: 0.3
			},250,function(){
				$(this).addClass("active-thumb");
			});
		}
		
		$(this).click(function(){
			// Alle einblenden
			$(".active-thumb").animate({
				"opacity":1
			},250,function(){
				$(this).removeClass("active-thumb");
			});

			// geklicktes verbergen
			$(this).animate({
				opacity: 0.3
			},250, function(){
				$(this).addClass("active-thumb");
			});
			
			if($(".left-column-post .size-full").length > 0) {
				$(".left-column-post .size-full").attr("src",$(this).attr("image"));
				$(".left-column-post .size-full").attr("alt",$(this).attr("rel"));
				$(".left-column-post .size-full").parent().find(".wp-caption-text").html($(this).attr("rel"));
			}
			if($(".left-column-post .size-large").length > 0) {
				$(".left-column-post .size-large").attr("src",$(this).attr("image"));
				$(".left-column-post .size-full").attr("alt",$(this).attr("rel"));
				$(".left-column-post .size-large").parent().find(".wp-caption-text").html($(this).attr("rel"));
			}
			if($(".left-column-post .size-medium").length > 0) {
				$(".left-column-post .size-medium").attr("src",$(this).attr("image"));
				$(".left-column-post .size-full").attr("alt",$(this).attr("rel"));
				$(".left-column-post .size-medium").parent().find(".wp-caption-text").html($(this).attr("rel"));
			}
			return false;
		});
	});
	//********************************************
	

	//********************************************
	// Höhen-Attribut für Bilder im Artikel entfernen
	$(".entry-content img").removeAttr("height");
	$(".gallery-thumb img").removeAttr("height");
	//********************************************
	
});

