
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=9473085\';"><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=9473085"><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=9473085" class="size13k"><strong>Porsalille<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">1. februar kl. 07:07<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 121.57<\/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=9382489\';"><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=9382489"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/myprofile/profileimages/thumbs_no/OTM4MjQ4OQ==1278539818.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=9382489" class="size13k"><strong>karili<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">25. januar kl. 13:38<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 261.73<\/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=10644061\';"><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=10644061"><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=10644061" class="size13k"><strong>Smiline35<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">11. januar kl. 01:59<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 171.40<\/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=10213059\';"><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=10213059"><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=10213059" class="size13k"><strong>susi46<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">1. januar kl. 14:19<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 234.97<\/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=9383361\';"><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=9383361"><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=9383361" class="size13k"><strong>niandi<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">1. januar kl. 09:02<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 889.66<\/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=9613609\';"><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=9613609"><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=9613609" class="size13k"><strong>maritaas<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">19. desember 2011 kl. 14:12<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 299.90<\/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=9910507\';"><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=9910507"><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=9910507" class="size13k"><strong>Annie61<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">2. desember 2011 kl. 23:51<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 171.46<\/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=9699310\';"><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=9699310"><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=9699310" class="size13k"><strong>baj15<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">23. november 2011 kl. 12:06<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 127.51<\/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=9519510\';"><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=9519510"><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=9519510" class="size13k"><strong>metteamun<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">16. november 2011 kl. 10:44<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 270.99<\/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=9895655\';"><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=9895655"><div class="recentWinnersCutout"><\/div><\/a><\/div><img src="/myprofile/profileimages/thumbs_no/OTg5NTY1NQ==1274639578.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=9895655" class="size13m"><strong>skeptisk46<\/strong><\/a><\/td><\/tr><tr><td colspan="2"><div style="overflow: hidden; height: 16px; color: #999999; font-size: 9px;">2. november 2011 kl. 04:42<\/div><\/td><\/tr><tr><td class="recentWinnersMoney"><\/td><td class="size12darkgrey">&nbsp;<strong>NOK 817.98<\/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("Innleser vinnere");
  //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);
}


