$(document).ready(function() {
	/* implement wp-tabbing */
	$("#tabcontent").append('<div id="stv_tabs"></div>');
	$("#tabcontent .content").css("overflow","hidden");
	$("#tabcontent p").each(function(id){
		the_html = $(this).html();
		subid = the_html.indexOf("->");
		if(subid > 0) {
			the_html = the_html.substr(0,subid-1);
			the_tab = the_html.replace("<!--tab:","");
			$(this).wrap('<div id="stv_tab_'+id+'" class="stv_tab"></div>')
			$("#stv_tabs").append('<a id="stv_tablink_'+id+'" href="#stv_tab_'+id+'">'+the_tab+'</a>');
			$(".stv_tab:first").show();
			$("#stv_tabs a:first").addClass('active');
		} else {
			$(".stv_tab:last").append("<p>"+the_html+"</p>");
			$(this).remove();
		}
	});
	$("#stv_tabs a").each(function(){
		$(this).click(function(){
			tab_id = $(this).attr('href');
			$('.stv_tab').hide();
			$("#stv_tabs a").removeClass('active');
			$(this).addClass('active');
			$(tab_id).show();
			return false;
		});
	});
	$('#category #index_catnav').removeClass("h");
	$('#category #index_catnav').hide();
	$('#category #index_catnav.search').show();
		$('#toggler_button a').toggle(function() {
			$("#index_catnav").slideToggle();
			$(this).empty();
			$(this).append("Kategorien ausblenden");
	 	},function() {
	        $("#index_catnav").slideToggle();
			$(this).empty();
			$(this).append("Kategorien einblenden");
		});
	
	
	/* open external links in new window*/
	// $("a[@href^=http]").each(
	//    function(){
	// 	  if(this.href.indexOf(location.hostname) == -1) { 
	//       $(this).attr('target', '_blank');
	//     }
	// });
	/* alternate comment lists*/
	$('#commentlist li:odd').addClass("odd");
	/* implement rollover for submit button*/
	$("#searchform button img").hover(
	      function () {
			src = $(this).attr("src");
			src = src.replace(".png","_over.png");
			$(this).attr("src",src);
	      }, 
	      function () {
	        src = $(this).attr("src");
			src = src.replace("_over.png",".png");
			$(this).attr("src",src);
	      }
	 );
	/* reset default input value for search query */
	search_default_value = $("#s").attr("value");
	$("#s").focus(function(){
		current_value = $(this).attr("value");
		if(current_value == search_default_value) $(this).attr("value","");
	});
	$("#s").blur(function(){
		current_value = $(this).attr("value");
		if(current_value == "") $(this).attr("value", search_default_value);
	});
	
	$("#breadcrumb span:last").hide();

	
	$("#show_channels").removeClass("h");
	$("#show_channels a").each(function(){
		$(this).click(function(){
			$("#show_channels a").removeClass("active");
			$(this).addClass("active");
		});
	});
	
	$("#show_all").click(function(){
		$(".alpha_channel").show();
		return false;
	});
	$("#show_bikes").click(function(){
		$(".alpha_channel").hide();
		$("#alpha_bikes").show();
		return false;
	});
	$("#show_tuning").click(function(){
		$(".alpha_channel").hide();
		$("#alpha_tuning").show();
		return false;
	});
	$("#show_style").click(function(){
		$(".alpha_channel").hide();
		$("#alpha_style").show();
		return false;
	});
	$("#show_racing").click(function(){
		$(".alpha_channel").hide();
		$("#alpha_racing").show();
		return false;
	});
	$("#show_media").click(function(){
		$(".alpha_channel").hide();
		$("#alpha_media").show();
		return false;
	});
	
	$('#innerfade').innerfade({
		animationtype: 'fade',
		speed: 900,
		timeout: 5000,
		containerheight: '315px',
		type: 'random_start'
	});
});


