jQuery(function($){
//text replacement
Cufon.replace('h1, .post h2, #rightcol h2, .post h3, #footer h4');

function setEqualHeight(columns){
	var tallestcolumn = 0;
 	columns.each(
 		function(){
	 		currentHeight = $(this).height();
 			if(currentHeight > tallestcolumn){
 				tallestcolumn  = currentHeight;
	 		}
 		}
 	);
 	columns.height(tallestcolumn);
 };


$('#multifeat').anythingSlider({
	easing: "swing",        // Anything other than "linear" or "swing" requires the easing plugin
	autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
	delay: 5000,                    // How long between slide transitions in AutoPlay mode
	startStopped: false,            // If autoPlay is on, this can force it to start stopped
	animationTime: 750, //US100514             // How long the slide transition takes
	hashTags: false,                 // Should links change the hashtag in the URL?
	buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
	pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
	/*startText: "Go",             // Start text
	stopText: "Stop",               // Stop text*/
	navigationFormatter: null       // Details at the top of the file on this use (advanced use)
});


// US100515 - Expand / Collapse Selection

$('div.expander').addClass('closed');
$('a.expcolbtn').css({"visibility":"visible"});
$('a.lesslink').css({"display":"block"});

var lessinfo = "- weniger Informationen anzeigen";
var moreinfo = "+ mehr Informationen anzeigen";


$("a.expcolbtn").click(
	function(){
		var expander = $(this).parent().find('div.expander');
		if (expander.is('.closed')) {
			$(this).text(lessinfo);
			expander.slideDown('1000');
			expander.removeClass('closed');
			return false;
		} else {
			expander.slideUp('1000');
			$(this).text(moreinfo);
			expander.addClass('closed');
			return false;
		}
	}
);


$("a.lesslink").click(
	function(){
		var expander = $(this).parent();
		if (expander.is('.closed')) {
			return false;
		} else {
			expander.slideUp('1000');
			expander.next('a.expcolbtn').text(moreinfo);
			expander.addClass('closed');
			return false;
		}
	}
);



//Fancybox
$("a.fancy").fancybox({
				'titleShow'		: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
// equal height cols
 setEqualHeight($("ul.fourboxes  > li"));
 setEqualHeight($("ul.fourboxeslong > li"));
 setEqualHeight($("ul.sixboxes > li"));
  setEqualHeight($("#kat #content ul > li"));

// character counter
// controls character input/counter
$('#fbtext').keyup(function() {
	var charLength = 500 - $(this).val().length;
// Displays count
	$('p#fbtextcount').html('(noch <span>' + charLength + '</span> Zeichen)');
// Alerts when 050 characters is reached
	if(charLength < 1)$('p#fbtextcount').html('<strong>Bitte nur maximal 500 Zeichen!</strong>');});
});



/*  addon windwerfer  */

// wenn ein link auf einen bild verweist, dann soll das bild in einer lightbox aufgerufen werden...
$(document).ready(function(){
		// für das starPlugin von jquery
		$('.hover-star').rating({
		  focus: function(value, link){
			var tip = $('#hover-tip');
			tip[0].data = tip[0].data || tip.html();
			tip.html(link.title || 'value: '+value);
		  },
		  blur: function(value, link){
			var tip = $('#hover-tip');
			$('#hover-tip').html(tip[0].data || '');
		  },
		  callback: function(value, link){
			var tip = $('#hover-tip');
			tip.html(link.title || 'value: '+value);
			tip[0].data=link.title;
		  }
		});


	   $("#content a").each(function(i,n) {
			var href = $(n).attr("href");
			if (typeof href=='undefined') return;
			href = href.toLowerCase();
			if (href.endsWith('.jpg') || href.endsWith('.png') || href.endsWith('.gif'))
				$(n).fancybox({
				'titleShow'		: true,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
		});

});

String.prototype.endsWith = function(str)
{return (this.match(str+"$")==str)}
/*String.prototype.startsWith = function(str)
{return (this.match("^"+str)==str)}
String.prototype.trim = function(){return
(this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""))}*/



