$(document).ready(function() {
 

//searchpop
$("a.searchpop").click(function() {
	$("#mainnavright").fadeOut("fast");
	$("#searchpop").fadeIn("fast");
});

$("a.hidesearchpop").click(function() {
	$("#searchpop").fadeOut("fast");
	$("#mainnavright").fadeIn("fast");	
});


//mostpop
$("a.commenttab").click(function() {
	$("#mostviewed").hide();
	$("#mostrecd").hide();
	$("#mostdugg").hide();
	$("#mostcommented").show();
	$("ul.tabbar > li > a").removeClass("active");
	$(this).addClass("active");
	
});

$("a.rectab").click(function() {
	$("#mostviewed").hide();
	$("#mostcommented").hide();
	$("#mostdugg").hide();
	$("#mostrecd").show();
	$("ul.tabbar > li > a").removeClass("active");
	$(this).addClass("active");
	
});

$("a.viewtab").click(function() {
	$("#mostrecd").hide();
	$("#mostcommented").hide();
	$("#mostdugg").hide();
	$("#mostviewed").show();
	$("ul.tabbar > li > a").removeClass("active");
	$(this).addClass("active");
	
});

$("a.duggtab").click(function() {
	$("#mostrecd").hide();
	$("#mostcommented").hide();
	$("#mostviewed").hide();
	$("#mostdugg").show();
	$("ul.tabbar > li > a").removeClass("active");
	$(this).addClass("active");
	
});

//email to friend

$("a.showmailform").click(function() {
	$("#mailform").show();
});

$("input.cancel").click(function() {
	$("#mailform").hide();
});

//abuse report

$("a.flagabuselink").each(function(i) {
	
	var $match = $(".abuse_warning").eq(i);
	
		$(this).click(function() {
		
			$match.show();
		});
	});

$("input.abuseno").click(function() {
	$(".abuse_warning").hide();
	});


//action notices

function actionNotice(message) {
	
	$(".notice").addClass("activenotice");
	$(".notice").append(message);
		/*
		function noticeFadeOut() {
			$(".notice")fadeOut();
		}
		
	setTimeout('noticeFadeOut()', 5000);
	*/
}



//stats param function
function appendRef(container, reftag) {
	var match = "talkingpointsmemo";
    $(container).each(function() {

    	if ( ($(this).attr('href').match(match)) && (!$(this).hasClass("noref")) ) {  		   		
        	var href = $(this).attr('href');             	
     		
     		var href = href.replace(/\?ref=.*$/,'');
     		
     			if ($(this).attr('href').match(/(id=|img=|page=)/)) {
     			
     				var refprefix = "&";
     			
     			} else {
     			
     				var refprefix = "?";
     			
     			}
     			
     			
     		var href = (href + refprefix + reftag); 
     		
     		
     		
     		$(this).attr('href', href);        
        
        }
    });
}

//fill this in for all the sections
appendRef(".right_col_module #feature a", "ref=tn");
appendRef(".right_col_module #c a", "ref=tn");




}); //dom ready function


