var tb_pathToImage = "/static/images/furniture/common/ajaxload.gif";

$(document).ready(function() {
	var navClass = $('#topNav').attr('class');
	$('#intentNetworkList').hide();
    $('#newsletter_signup_a').click(function() {
        $.blockUI({message: $('#newsletter_signup')});
    });
    $('#newslettergo').click(function(){
		ajaxEval('/ajax?action=newsletter&e='+$('#newsletteremail').val());
		return false;
    });
    $('.make_author_email').click(function(){
		$.get('/ajax?action=emailAuthor&d='+$(this).attr('rel'), function(response){
			$('#blockUI_inner').html(response);
		});
        $.blockUI({message: $('#blockUI')});
        return false;
    });
    $('.make_friend_email').click(function(){
		$.get('/ajax?action=emailFriend&d='+$(this).attr('rel'), function(response){
			$('#blockUI_inner').html(response);
		});
        $.blockUI({message: $('#blockUI')});
        return false;
    });
    $('.report_forum_spam').click(function(){
		$.get('/ajax?action=reportSpam&d='+$(this).attr('rel'), function(response){
			$('#blockUI_inner').html(response);
		});
        $.blockUI({
        	message: $('#blockUI')
        });
        return false;
    });
    $('.report_forum_abuse').click(function(){
		$.get('/ajax?action=reportSpam&d='+$(this).attr('rel'), function(response){
			$('#blockUI_inner').html(response);
		});
        $.blockUI({
        	message: $('#blockUI')
        });
        return false;
    });
    $('.rotatortab').mouseover(function(){
    	$('.rotatortab').removeClass('on');
    	$('#placehere').html(
    		$('#rotate_'+this.id+'_text').html()
    	);

    	var bg = $('#rotate_'+this.id+'_h2').attr('rel');
   		$('#rotatorpanel').css('background-image','url('+bg+')');

    	$(this).addClass('on');

    });
    $('.event_more_info').click(function() {
		var id = $(this).attr('rel');
		if($('#event'+id).html()==''){
			$.get('/ajax?action=eventInfo&i='+id, function(response){
				$('#event'+id).html(response);
			});
		} else {
			$('#event'+id).html('');
		}
		return false;
    });
    $('#m_screename').keyup(function(){
    	var sn = $('#m_screename').val();
	    if(sn.length > 3) {
	    	$('#screenameworking').addClass('working');
	    	ajaxEval('/ajax?action=screenameLookup&sn='+sn);
	    }
    });
   	$('.morefeedslist').slideUp();
	$('.clickmorearticles').click(function(){
		var boxId = $(this).attr('rel');
		if ($('#morearticles'+boxId).is(":hidden")) {
			$('#morearticles'+boxId).slideDown("slow");
		} else {
			$('#morearticles'+boxId).slideUp("slow");
		}
		return false;
	});
	$('#putTopNews').click(function(){
		$.get('/ajax?action=putTopNews',function(response){
			$('#topStories').html(response);
		});
		$('#newstabs').attr('class','tab_news_top');
		$('#newstabs').css('background-image','url(/static/images/furniture/tab_news_top.gif)');
		return false;
	});
	$('#putPopularNews').click(function(){
		$.get('/ajax?action=putPopularNews',function(response){
			$('#topStories').html(response);
		});
		$('#newstabs').attr('class','tab_news_comments');
		$('#newstabs').css('background-image','url(/static/images/furniture/tab_news_comments.gif)');
		return false;
	});
	$('#putViewsNews').click(function(){
		$.get('/ajax?action=putViewsNews',function(response){
			$('#topStories').html(response);
		});
		$('#newstabs').attr('class','tab_news_views');
		$('#newstabs').css('background-image','url(/static/images/furniture/tab_news_views.gif)');
		return false;
	});
	$('#nextTenPopular').click(function(){
		$.get('/ajax?action=putPopularNews&p='+($(this).attr('rel')),function(response){
			$('#topStories').html(response);
		});
		return false;
	});
	$('.show_comment').click(function(){
		if ($('#ct_'+$(this).attr('rel')).is(":hidden")) {
			$('#ct_'+$(this).attr('rel')).slideDown('slow');
			$(this).html('Hide comment');
		} else {
			$('#ct_'+$(this).attr('rel')).slideUp('slow');
			$(this).html('Show comment');
		}
		return false;
	});
	$('#intentNetwork').click(function(){
		if ($('#intentNetworkList').is(":hidden")) {
			$('#intentNetworkList').slideDown("slow");
		} else {
			$('#intentNetworkList').slideUp("slow");
		}
		$('#topNav').toggleClass('tab_network');
		$('#topNav').toggleClass(navClass);
		return false;
	});







	if($('#currentpoll')) {
		ajaxEval('/ajax?action=pollResults');
	}




});
function nextTenNews(p){$.get('/ajax?action=putTopNews&p='+p,function(response){$('#topStories').html(response);});return false;}
function nextTenPopular(p){$.get('/ajax?action=putPopularNews&p='+p,function(response){$('#topStories').html(response);});return false;}
function nextTenViews(p){$.get('/ajax?action=putViewsNews&p='+p,function(response){$('#topStories').html(response);});return false;}
function rateKarma(c,i,d) { ajaxEval('/ajax?action=rateKarma&c='+c+'&i='+i+'&d='+d); }
function rateArticleKarma(s,i,d) { ajaxEval('/ajax?action=rateArticleKarma&s='+s+'&i='+i+'&d='+d); }
function blank(){}
function unblock(){$.unblockUI();}

