$(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;
		});
	});
	
	
	/* 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");
	// $('.alignleft').parent().addClass("alignleft");
	/* strip parantheses from post count*/
	$('#channelnav li').each(function(){
		con = $(this).html();
		con = con.replace("(","<span>");
		con = con.replace(")","</span>");
		con = $(this).html(con);
	});
	/* 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);
	});
	$('#more_videos .item').slice(0, 3).addClass("set1");
	$('#more_videos .item').slice(3, 6).addClass("set2");
	$('#more_videos .item').slice(6, 9).addClass("set3");
	$(".set1").wrapAll("<div></div>");
	$(".set2").wrapAll("<div></div>");
	$(".set3").wrapAll("<div></div>");
	
	ln = $("#mySlides div").length;
	while(ln--) {
		$("#myController").append('<span class="jFlowControl">No 2 </span>');
	}
	$("#slidernav").removeClass("h");
	$("#myController").jFlow({
	    slides: "#mySlides",
	    width: "100%",
	    height: "234px",
	    duration: 400
	});
	$("#innerfade").innerfade({
		animationtype: 'fade',
		speed: 900,
		timeout: 5000,
		containerheight: '340px',
		type: 'random_start'
	});
});


