
var winners	= new Array();
var objWinners	= '';
var scrollPos 	= '';
var numScrolls	= '';
var heightOfElm = '62'; // Height of each element (px)
var numberOfElm = '';
var scrollOn 	= 'true';
	
function scrollState (val) {
	if (scrollOn != val) {
		scrollOn = val;
		if (val == 'true') {
			setTimeout("scrollWinners();", 1000);
		}
	}
}

function scrollWinners() {
	objWinners.scrollTop = objWinners.scrollTop + 1;
	scrollPos++;
	if ((scrollPos%heightOfElm) == 0) {
		numScrolls--;
		if (numScrolls == 0) {
			objWinners.scrollTop = '0';
			makeContent();
		} else {
			if (scrollOn == 'true') {
				makeContent();
			}
		}
	} else {
		setTimeout("scrollWinners();", 10);
	}
}

var winnerNum = 0;
/*
Creates amount to show + 1 for the scrolling ability to work
scrollTop is set to top position after each creation
Otherwise the scrolling cannot happen
*/
function makeContent() {
	var tmp = '';

	w = winnerNum - parseInt(numberOfElm);
	if (w < 0) {
		w = 0;
	} else {
		w = w%winners.length;
	}
	
	// Show amount of winners
	var elementsTmp = parseInt(numberOfElm) + 1;
	for (i = 0; i < elementsTmp; i++) {
		
		// Add HTML to tmp var
		tmp += winners[w%winners.length];
		w++;
	}
	
	// Set vars
	
/*	$('div#winnerHolder').html(tmp);*/
	objWinners.innerHTML 	= tmp;
	
	winnerNum 				= w;
	numScrolls 				= winners.length;
	objWinners.scrollTop 	= '0';
	// Begin scrolling
	setTimeout("scrollWinners();", 2000);
}

function createWinnerScroll() {
		
	winners[0] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10075435\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10075435"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_female.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10075435" class="size13k"><strong>JazzyCA69<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">08 January at 00:30<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 21.02<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[1] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10532858\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10532858"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_male.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10532858" class="size13m"><strong>Paulm<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">30 November 2011 at 05:48<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 14.96<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[2] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10566472\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10566472"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_female.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10566472" class="size13k"><strong>norberta<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">02 November 2011 at 15:33<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 19.30<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[3] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10571340\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10571340"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_male.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10571340" class="size13m"><strong>turbo50<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">28 September 2011 at 01:52<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 29.80<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[4] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10198168\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10198168"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_female.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10198168" class="size13k"><strong>susanm<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">30 August 2011 at 08:12<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 61.37<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[5] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=9735419\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=9735419"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_female.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=9735419" class="size13k"><strong>sparkie96<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">04 August 2011 at 02:33<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 12.49<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[6] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10113017\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10113017"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_male.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10113017" class="size13m"><strong>skenkerbob<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">12 July 2011 at 01:32<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 10.52<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[7] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10041565\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10041565"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/myprofile/profileimages/thumbs_com/MTAwNDE1NjU=1307891020.JPG" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10041565" class="size13k"><strong>SoulVenus<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">22 June 2011 at 16:05<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 9,459.16<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[8] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=7538415\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=7538415"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/images/profiles/noimage70x52_female.gif" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=7538415" class="size13k"><strong>riccapooh<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">22 June 2011 at 15:47<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 20.96<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		
	winners[9] = '<table cellpadding="4" cellspacing="0" border="0" width="100%" onclick="window.location=\'/profile/myprofile/profile.php?profile=10112489\';"><tr><td width="56"><div style="position: relative; top: 0px; left: 0px;"><div style="position: absolute; top: 0px; left: 0px;"><a href="/profile/myprofile/profile.php?profile=10112489"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/myprofile/profileimages/thumbs_com/MTAxMTI0ODk=1328033335.JPG" width="70" height="52" alt="KOV_TITLE" style="border: solid 1px #CCCCCC;"><\/div><\/td><td><table cellpadding="0" cellspacing="0" border="0"><tr><td colspan="2"><a href="/profile/myprofile/profile.php?profile=10112489" class="size13k"><strong>fawm<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">14 May 2011 at 23:50<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>USD 16.06<\/strong><\/td><\/tr><\/table><\/td><\/tr><\/table>';
	
		objWinners	= document.getElementById('winnerHolder');
	objWinners.style.height = (numberOfElm * heightOfElm) + 'px'; // Set height of DIV
	
	makeContent();
}

function changeContent(show, resultpage) {
  wait("Loading winners");
  //makeHttpRequest("ajax/recentwinners.php?show="+show+"&resultpage="+resultpage, "showContent");
  $.get('ajax/recentwinners.php', {show : show, resultpage : resultpage}, showContent);
}

function paging(resultpage) {
  //makeHttpRequest("ajax/recentwinners.php?show="+document.getElementById("show").value+"&resultpage="+resultpage, "showContent");
  $.get('ajax/recentwinners.php', {show : $('#show').val(), resultpage : resultpage }, showContent);
}

function initRecentWinners() {
  changeContent(0,1);
}


