function updateFlickr(val,label,year,winner,loser) {
	page=page+val
	$('#flickr_badges').load('/includes/ajax.php',{ 'which':'flickr','page':page,'label': label,'year': year,'winner': winner,'loser': loser });
	if(val==1){
		$(".flickr_badge_image").animate({
				marginLeft: "-546px"
		}, 500);
	}
	if(val==-1){
		$(".flickr_badge_image").animate({
				marginLeft: "546px"
		}, 500);
	}
	 $('.lightbox').lightbox();
}

function updateYoutube(val,label,year,winner,loser) {
	YTpage=YTpage+val
	$('#youtube_badges').load('/includes/ajax.php',{ 'which':'youtube','page':YTpage,'label': label,'year': year,'winner': winner,'loser': loser }, function(){ytTabs();});
}

function updateTwitter(winner,loser,label) {
	$('.twittersW').load('/includes/ajax.php',{ 'which':'twitter','query': winner,'label': label });
	$('.twittersR').load('/includes/ajax.php',{ 'which':'twitter','query': loser,'label': label });
	setTimeout('updateTwitter('+winner+','+loser+','+label+')', 60*1000);
}

function updateAmazon(page,loc,key,cat,WorL,label,sub_cat) {
	if(page>0){
		$(loc).load('/includes/ajax.php',{ 'which':'amazon','page':page,'Keywords': key,'cat': cat},function(ret){
			if(ret==0){
				$(loc).load('/includes/ajax.php',{ 'which':'amazon','page':page,'Keywords': label,'cat': cat},function(ret2){
					if(ret2==0){
						$(loc).load('/includes/ajax.php',{ 'which':'amazon','page':page,'Keywords': sub_cat,'cat': cat},function(ret3){
							if(ret3==0){
								$("."+cat+WorL).hide();
							}
						});
					}
				});
			}
			reset(cat,WorL);
		});
	}
}
	
function ytTabs(){

	if($('#vid_list').children().length>0){
		$('.vid > ul').tabs();
		$('.contenttitle > ul').tabs({ selected: null, unselect: true, fx: { width: 'toggle', opacity: 'toggle' } });
		$('.video > ul').tabs();
		$('.contenttitle > ul').tabs({ selected: null, unselect: true, fx: { width: 'toggle', opacity: 'toggle' } });
	}
	else{
		$('#box_video').hide();
	}
}
function reset(cat,WorL){
	$("#"+cat.toLowerCase()+WorL).css({
		marginLeft: "0"
	});
	if(page==1){
		$("#"+cat.toLowerCase()+WorL+"L").addClass('fade');
	}
	else{
		$("#"+cat.toLowerCase()+WorL+"L").removeClass('fade');
	}
}

function slide(what,dir,WorL,whatU){
		
		eval(what+WorL+"page="+what+WorL+"page+"+dir);
		eval("page="+what+WorL+"page");
		eval("where='#"+what+WorL+"'");
		
		key=loser;
		if (WorL == "W") key=winner;
		updateAmazon(page,where,key,whatU,WorL);
	}
	
