function showNextTopMikestars(frame1,prevButton,nextButton){
	newTopMikestarsContent = "";
	topMikestarsFirstIndex += 4;
	liveList.getTopUsers(topMikestarsFirstIndex, 4, function (data){
	for (i=0;i<data.length;i++) {
		newTopMikestarsContent += topMikestarUserFormatter(data[i]);
	}
	if (topMikestarsFirstIndex <= totalNumberOfTopMikestars) {
		window.setTimeout("showNext()", 100);
		
		if(topMikestarsFirstIndex >= 4)
			$(prevButton).style.visibility='visible';
		if ((topMikestarsFirstIndex+4) >= totalNumberOfTopMikestars)
			$(nextButton).style.visibility='hidden';
	} else {
		topMikestarsFirstIndex -= 4;
	}
	});
}	
function showPrevTopMikestars(frame1,prevButton,nextButton){
	newTopMikestarsContent = "";
	topMikestarsFirstIndex -= 4;
	if (topMikestarsFirstIndex >= 0) {
		liveList.getTopUsers(topMikestarsFirstIndex, 4, function (data){
			for (i=0;i<data.length;i++) {
				newTopMikestarsContent += topMikestarUserFormatter(data[i]);
			}
			window.setTimeout("showNext()", 100);
			
			$(nextButton).style.visibility='visible';
			if (topMikestarsFirstIndex <= 0) {
				$(prevButton).style.visibility='hidden';
			}
		});
	}
}
function showNextMostViewedEntries(frame1,prevButton,nextButton){
	newMostViewedEntriesContent = "";
	mostViewedFirstIndex += 4;
	ajaxRecord.getMostViewedRecords(mostViewedFirstIndex, 4, function (data){
		for (i=0; i < data.length; i++){
			newMostViewedEntriesContent += recordListingFormatter(data[i]);
		}
		if (mostViewedFirstIndex <= totalNumberOfMostViewed) {
		window.setTimeout("showNextMostViewed('"+frame1+"')",100);
		
		if (mostViewedFirstIndex >= 4)
			$(prevButton).style.visibility='visible';
		if ((mostViewedFirstIndex+4) >= totalNumberOfMostViewed)
			$(nextButton).style.visibility='hidden';
		} else {
		mostViewedFirstIndex -= 4;
		}		
	});	
}
function showPrevMostViewedEntries(frame1,prevButton,nextButton){
	newMostViewedEntriesContent = "";
	mostViewedFirstIndex -= 4;
	if (mostViewedFirstIndex >= 0){
		ajaxRecord.getMostViewedRecords(mostViewedFirstIndex, 4, function (data){
			for (i=0; i < data.length; i++){
				newMostViewedEntriesContent += recordListingFormatter(data[i]);
			}
			window.setTimeout("showNextMostViewed('"+frame1+"')", 100);
			
			$(nextButton).style.visibility='visible';
			if (mostViewedFirstIndex <= 0) {
				$(prevButton).style.visibility='hidden';
			}
		});		
	}
}
function showPrevShootingEntries(frame1,prevButton,nextButton) {
	newShootingRecEntriesContent = "";
	shootingListFirstIndex -= 4;
	if (shootingListFirstIndex >= 0){
		ajaxRecord.getShootingRecords(shootingListFirstIndex, 4, function (data){
			for (i=0; i < data.length; i++){
				newShootingRecEntriesContent += recordListingFormatter(data[i]);
			}
			//Effect.Fade(frame1,{duration:0.5});
			window.setTimeout("showNextShooting('"+frame1+"')", 100);
			
			$(nextButton).style.visibility='visible';
			if (shootingListFirstIndex <= 0) {
				$(prevButton).style.visibility='hidden';
			}
		});
	}
}
function showNextShootingEntries(frame1,prevButton,nextButton) {
	newShootingRecEntriesContent = "";
	shootingListFirstIndex += 4;
	ajaxRecord.getShootingRecords(shootingListFirstIndex, 4, function (data){
		for (i=0; i < data.length; i++){
			newShootingRecEntriesContent += recordListingFormatter(data[i]);
		}
		if (shootingListFirstIndex <= totalNumberOfShootingRec) {
		//Effect.Fade(frame1,{duration:0.5});
		window.setTimeout("showNextShooting('"+frame1+"')",100);
		
		if (shootingListFirstIndex >= 4)
			$(prevButton).style.visibility='visible';
		if ((shootingListFirstIndex+4) >= totalNumberOfShootingRec)
			$(nextButton).style.visibility='hidden';
		} else {
			shootingListFirstIndex -= 4;
		}
	});
}
function showNextNewestEntries(frame1,prevButton,nextButton) {
	newNewestRecEntriesContent = "";
	newestListFirstIndex += 4;
	ajaxRecord.getNewestRecords(newestListFirstIndex, 4, function (data){
		for (i=0; i < 4; i++){
			newNewestRecEntriesContent += recordListingFormatter(data[i]);
		}
		if (newestListFirstIndex <= totalNumberOfNewestRec) {
		//Effect.Fade(frame1,{duration:0.5});
		window.setTimeout("showNextNewest('"+frame1+"')",100);
		
		if (newestListFirstIndex >= 4)
			$(prevButton).style.visibility='visible';
		if ((newestListFirstIndex+4) >= totalNumberOfNewestRec)
			$(nextButton).style.visibility='hidden';
		} else {
			newestListFirstIndex -= 4;
		}
	});
}
function showPrevNewestEntries(frame1,prevButton,nextButton) {
	newNewestRecEntriesContent = "";
	newestListFirstIndex -= 4;
	if (newestListFirstIndex >= 0){
		ajaxRecord.getNewestRecords(newestListFirstIndex, 4, function (data){
			for (i=0; i < data.length; i++){
				newNewestRecEntriesContent += recordListingFormatter(data[i]);
			}
			//Effect.Fade(frame1,{duration:0.5});
			window.setTimeout("showNextNewest('"+frame1+"')",100);
			
			$(nextButton).style.visibility='visible';
			if (newestListFirstIndex <= 0) {
				$(prevButton).style.visibility='hidden';
			}
		});
	}
}
function showNextContestEntries(contestID, lastRecord, frame1,prevButton,nextButton){
	newContestEntriesContent = "";
	contestFirstIndex += 4;
	ajaxRecord.getContestRecords(contestID, lastRecord, contestFirstIndex, 4, function (data){
		for (i=0; i < data.length; i++){
			newContestEntriesContent += contestUserFormatter(data[i],contestID);
		}
		if (contestFirstIndex <= totalNumberOfContestEntries) {
		window.setTimeout("showNextContest('"+frame1+"')",100);
		
		if (contestFirstIndex >= 4)
			$(prevButton).style.visibility='visible';
		if ((contestFirstIndex+4) >= totalNumberOfContestEntries)
			$(nextButton).style.visibility='hidden';
		} else {
			contestFirstIndex -= 4;
		}
	});	
}
function showPrevContestEntries(contestID, lastRecord, frame1,prevButton,nextButton){
	newContestEntriesContent = "";
	contestFirstIndex -= 4;
	if (contestFirstIndex >= 0){
		ajaxRecord.getContestRecords(contestID, lastRecord, contestFirstIndex, 4, function (data){
			for (i=0; i < data.length; i++){
				newContestEntriesContent += contestUserFormatter(data[i], contestID);
			}
			window.setTimeout("showNextContest('"+frame1+"')", 100);
			
			$(nextButton).style.visibility='visible';
			if (contestFirstIndex <= 0) {
				$(prevButton).style.visibility='hidden';
			}
		});		
	}
}
function showNext(){
	var topMikeStarsFrame1 = document.getElementById("topMikeStarsFrame1");
	topMikeStarsFrame1.innerHTML = newTopMikestarsContent;		
	Effect.Appear("topMikeStarsFrame1",{duration:0.5});
}
function showNextMostViewed(frame1){
	var topMikeStarsFrame1 = document.getElementById(frame1);
	topMikeStarsFrame1.innerHTML = newMostViewedEntriesContent;		
	Effect.Appear(frame1,{duration:0.5});
}
function showNextShooting(frame1){
	var ShootingFrame = document.getElementById(frame1);
	ShootingFrame.innerHTML = newShootingRecEntriesContent;		
	//Effect.Appear(frame1,{duration:0.5});
}
function showNextNewest(frame1){
	var NewestFrame = document.getElementById(frame1);
	NewestFrame.innerHTML = newNewestRecEntriesContent;		
	//Effect.Appear(frame1,{duration:0.5});
}
function showNextContest(frame1) {
	$(frame1).innerHTML = newContestEntriesContent;
	Effect.Appear(frame1,{duration:0.5});
}
var topUsers = null;
function loadTopMikestarsContent(){
	var topMikeStarsFrame2 = document.getElementById("topMikeStarsFrame2");
	topUsers = liveList.getTopUsers(topListFirstIndex, numberOfTopMikestars, createTopUserEntries);
}
function loadTopEntriesContent(){
	var topMikeStarsFrame2 = document.getElementById("topEntriesFrame1");
	topUsers = liveList.getTopUsers(topEntriesFirstIndex, numberOfTopEntries, createTopUserEntriesMostViewed);
}
var mostViewedEntries = null;
function loadMostViewedEntriesContent(){
	var topMikeStarsFrame2 = document.getElementById("mostViewedFrame1");
	mostViewedEntries = ajaxRecord.getMostViewedRecords(mostViewedFirstIndex, numberOfMostViewed, createTopUserEntriesMostViewed);
}
var shootingRecEntries = null;
function loadShootingRecsContent() {
	shootingRecEntries = ajaxRecord.getShootingRecords(shootingListFirstIndex, numberOfShootingRec, createShootingRecEntriesMostViewed);	
}
function createTopUserEntries(data){
	newTopMikestarsContent = "";
	for (i=0; i < data.length; i++){
		newTopMikestarsContent += topMikestarUserFormatter(data[i]);
	}
}	
function contestUserFormatter(data, contestID) {
	if (data != null) {
		return '<div class="top_mikestar" style="height:120px;">' +																		
			   '<div class="userpic_frame_nofloat" style="position:relative">' +
			   '<a class="horizontal_rec_box" href="'+contextPath+'/Contest/detail?contest=' + contestID + '&record='+ data.recordID + '" ><img src="' + ((data.webcam == true)?data.previewImage:((data.user.partner == 'MTV')?partnerImage:data.user.image.avatarThumb)) + '" style="width:74px;height:55px;" alt="' + data.user.username + '" title="' + data.user.username + '"/></a>' +
			   '</div>' +	
			   '<ul style="text-align:center;">' + 
			   '<li style="margin-bottom:5px;"><h3><a href="'+contextPath+'/Contest/detail?contest=' + contestID +'&record='+ data.recordID + '" class="user">' +
			   ( (data.user.partnerUsername.length < 15)?data.user.partnerUsername:data.user.partnerUsername.substring(0, 14)+"..." ) +
			   '</a></h3></li>' + 
			   '<li><a class="horizontal_rec_box" href="'+contextPath+'/Contest/detail?contest=' + contestID + '&record='+ data.recordID + '" >' + 
			   ((data.song.songTitle.length < 25)?data.song.songTitle:data.song.songTitle.substring(0,24)+"...") + 
			   '</a></li>' + 
			   '</ul>' + 		
		       '</div>';
	} else {
		return '<div class="top_mikestar" style="height:120px;">' +																		
			   '<div class="userpic_frame_nofloat" style="position:relative">' +
			   '<span>Kein weiterer Teilnehmer vorhanden. Jetzt mitmachen!</span>' +
			   '</div>' +	
			   '<ul style="text-align:center;">' + 
			   '<li style="margin-bottom:5px;"></li>' + 
			   '</ul>' + 		
		       '</div>';
	}	
}	
function topMikestarUserFormatter(data) {
	
	var username = data.username;
	var partnerUsername = data.partnerUsername;
	var avatar = data.image.avatarThumb;
	var numOfFans = data.numOfFans;
	var numOfRecords = data.numOfRecords;
	var country = data.country;

	
	return '<div class="top_mikestar" >' +																		
		'<div class="userpic_frame_nofloat" style="position:relative">' +
				'<a href="'+contextPath+'/Member/detail?user=' + username + '" ><img src="'+ ((data.partner == 'MTV')?partnerImage:avatar) + '" alt="' + username + '" title="' + username + '"/></a>' +
		'</div>' +	
		'<h3><a href="'+contextPath+'/Member/detail?user=' + username +'" class="user">' +
		( (partnerUsername.length > 8)?partnerUsername:partnerUsername.substring(0, 7) ) +
		'</a></h3>' + 
		'<ul>' + 
			'<li><img class="stats_fan" src="'+contextPath+'/img/icons/star_little2.gif" /><span class="grey_thin_small">' + numOfFans + " "+((numOfFans == 1)?numOfFanLabel:numOfFansLabel) + '</span></li>' + 
			'<li><img class="stats_disc" src="'+contextPath+'/img/icons/disc_little.gif" /><span class="grey_thin_small">' + numOfRecords + " " + ((numOfRecords == 1)?numOfRecordLabel:numOfRecordsLabel) + '</span></li>' + 
		'</ul>' + 
	 '</div>';
}	
function recordListingFormatter(data) {
	return '<div class="top_mikestar" style="height:120px;"><div class="userpic_frame_nofloat" style="position:relative">' +
		   '<a class="horizontal_rec_box" href="'+contextPath+'/Record/play?record=' + data.recordID + '" ><img src="'+ ((data.webcam == true)?data.previewImage:((data.user.partner == 'MTV')?partnerImage:data.user.image.avatarThumb)) + '" style="width:74px;height:55px;" alt="' + data.user.username + '" title="' + data.user.username + '"/></a>' +
		   '</div><ul style="text-align:center;"><li style="margin-bottom:5px;"><h3><a href="'+contextPath+'/Member/detail?user=' + data.user.username +'" class="user">' + ((data.user.partnerUsername.length < 15)?data.user.partnerUsername:data.user.partnerUsername.substring(0, 14)+"..." ) +
		   '</a></h3></li><li><a class="horizontal_rec_box" href="'+contextPath+'/Record/play?record=' + data.recordID +'">' + ((data.song.songTitle.length < 25)?data.song.songTitle:data.song.songTitle.substring(0,24)+"...")+ '</a></li></ul></div>';
}	