var size_wpx = (size == 's')? '100' : '140';
var size_hpx = (size == 's')? '82' : '115';
var count=0;
var timeout = 500;
var increments = new Array();
var defaultLink = "http://www.casinoportalen.fr/";

/* Methods of jp object */
jp.prototype.setIncrements = setIncrements;
function setIncrements(val){
    this.increments = val;
}
jp.prototype.setParameters = setParameters;
function setParameters(size){
	this.size = size;
	this.w = size_wpx;
	this.h = size_hpx;
	if (this.currency == "US$")  this.currency = "$";
    if (this.currency == "Multi") this.currency =  "$";
    if (this.currency == "&pound;") this.currency =  "£";
    if (this.currency == "&euro;") this.currency =  "€";	
}
jp.prototype.getHtml = getHtml 
function getHtml(id, alink){
	if (document.forms[id]) return '';	
//	var html = '<form name="' +id +'">';
	var html = '';
	html += '<span id="' +id +'" name="' +id +'"></span>';
//	html += '<input valign="bottom" type="text" name="progressive" size="9" value="" class="jp">';
//	html += '</form>';
	return html;
}
jp.prototype.rollJP = rollJP;
function rollJP(){
	var t =  String(this.previous_value + count*this.increments);
	var obj = document.getElementById(this.id);
	if (parseFloat(t) >0) {
		var dotPos = t.indexOf('.');
		if (dotPos > 0)	{
				t +='00';
				t = t.substring(0,dotPos +=3);
			} else t = t + '.00';		
		if (obj) obj.innerHTML = this.currency + insertComma(t);
	} else {
		if (obj) obj.innerHTML = '    - - - - -';
	}
    count++;
}

function insertComma(data){
	var dotPos = data.indexOf('.');
	var tmp ="";

	for (var i = dotPos; i>=0; i=i-3)
	{		
		tmp = (i-3>0)? ',' + data.substring(i-3,i) + tmp : data.substring(i-3,i) + tmp;		
	}
	tmp += data.substring(dotPos,data.length);
	return tmp;
}
/* end jp methods */

function getJPRef(_gameID){
    for (var i = 0; i < Jackpots.length; i++) { 
        if (Jackpots[i].id == _gameID) {
            return Jackpots[i];
        }
    }
}

function DisplayJackpotByID(gameID, size, alink){	
    var jpRef = getJPRef(gameID);
    jpRef.setParameters(size);    		
    document.write( jpRef.getHtml(gameID, alink) );		
    var steps = jpRef.interval/(timeout/1000);
    jpRef.setIncrements( (jpRef.current_value - jpRef.previous_value)/steps);    
    roll(gameID);
}	

function roll(gid){   
    var jpRef =  getJPRef(gid);
    jpRef.rollJP();
    count++;
    window.setTimeout("roll('" + gid + "')",timeout);	    
}

function DisplayJackpot(game, size, alink){
	// all_us -> all games with US$, all_uk -> all games with British pound
	if (game == 'all_us') jackpot = new Array(0,1,2,3,4,5,6,7);
	else if (game == 'all_uk') jackpot = new Array(8,9,10,11,12,13,14,15);
	else jackpot = new Array(game.toString()); 
	
	for (var i=0; i < jackpot.length; i++) { 
		var idx = jackpot[i];
        if (Jackpots[idx].id == "") return;
	    DisplayJackpotByID(Jackpots[idx].id, size, alink);
	}
}     



