var global_score_control;


$(function(){
global_score_control=new worthPool();
});



var worthPool=function(){

var _this=this;



this.text_animation_font={
'init':'42pt',
'mid':'64pt',
'finall':'45pt'
}


this.worth_small_ball=10000;	//value representing the small balls

this.worth_big_ball=100000;		//value representing the Big balls

this.worth_maximum_limit_ball=1000000;	//maximum limit 

this.totalScore=1000000;				//Total target Score needs to be achieve

this.multiplicationFactor;


this.totalLevel=3;					//total number of levels

this.levelWiseRange=[				//Level Wise range for random score selection
{min:20,max:25}, 
{min:26,max:35},
{min:40,max:50}
];

this.level=[
    {target:23,score:0},
    {target:35,score:0},
    {target:42,score:0}
];


this.NumberOfSmallBalls=10;			//Number of small Balls should be on the screen;

this.NumberOfBigBalls=3;			//Number of Big balls should be on the screen;

this.total_balls_in_pool=this.NumberOfSmallBalls+this.NumberOfBigBalls;
this.text='<img src="media/1.png" style=" margin: 0 0 0 23px;"><span style="margin: 0 0 0 32px;">&nbsp;vale'+ numberWithCommas(this.worth_small_ball)+'.</span><br><br>'+
'<img src="media/10.png"><span style="margin: 0 0 0 9px;position:relative;top:-20px">&nbsp;vale '+numberWithCommas(this.worth_big_ball)+'.</span><br><br>'+
'<span>¡Englute estos glóbulos para llegar al número seleccionado!</span>';
this.init=function(){
$('#instruction_box').html(this.text);

 	var temp=0;
 	   this.multiplicationFactor=this.worth_small_ball;
	for(var i=0;i<(this.levelWiseRange.length-1);i++){
    	this.level[i].target=this.getRandominRange(this.levelWiseRange[i].min,this.levelWiseRange[i].max)*this.multiplicationFactor;
         temp=temp+this.level[i].target;
	}
   	this.level[i].target=this.totalScore-temp;
   _this.calculateFontSizes();
	document.getElementById('target').style.color='#54CDFF';
	document.getElementById('score').style.color='#FFE554';
}

this.calculateFontSizes=function(){

if(this.multiplicationFactor==10){
document.getElementById('gameTotal').style.fontSize='20pt';
document.getElementById('target').style.fontSize='40pt';
document.getElementById('score').style.fontSize='40pt';

this.text_animation_font={
'init':'37pt',
'mid':'55pt',
'finall':'40pt'
}

}
else if(this.multiplicationFactor==100){
document.getElementById('gameTotal').style.fontSize='18pt';
document.getElementById('target').style.fontSize='34pt';
document.getElementById('score').style.fontSize='34pt';

this.text_animation_font={
'init':'30pt',
'mid':'50pt',
'finall':'34pt'
}


}
else if(this.multiplicationFactor==1000){
document.getElementById('gameTotal').style.fontSize='16pt';
document.getElementById('target').style.fontSize='30pt';
document.getElementById('score').style.fontSize='30pt';

this.text_animation_font={
'init':'26pt',
'mid':'50pt',
'finall':'30pt'
}

}
else if(this.multiplicationFactor==10000){
document.getElementById('gameTotal').style.fontSize='14pt';
document.getElementById('target').style.fontSize='24pt';
document.getElementById('target').style.margin='66px 0px 0px 0px';
document.getElementById('score').style.fontSize='24pt';

this.text_animation_font={
'init':'20pt',
'mid':'36pt',
'finall':'24pt'
}

}

else if(this.multiplicationFactor==100000){
document.getElementById('gameTotal').style.fontSize='10pt';
document.getElementById('target').style.fontSize='18pt';
document.getElementById('target').style.margin='65px 0 0 0';
document.getElementById('score').style.fontSize='18pt';

this.text_animation_font={
'init':'14pt',
'mid':'22pt',
'finall':'18pt'
}

}

}

this.getLevel=function(){
	return _this.level;
}

this.getWorth=function(a){
	if(typeof a !=undefined && a!='' && a!=null){
		switch(a){
		case 1:
	return _this.worth_small_ball;
		break;

	case 2:
		return _this.worth_big_ball;
		break;

	case 3:
	return _this.worth_maximum_limit_ball;

			}
		}
}


this.getTotalScore=function(){
return _this.totalScore;
}

this.getTotalLevel=function(){
	return _this.totalLevel;
}

this.getLevelWiseScoreRange=function(){
return _this.levelWiseRange;
}

this.getNumber_Of_Small_balls=function(){
	return _this.NumberOfSmallBalls;
}

this.getNumber_Of_Big_balls=function(){
	return _this.NumberOfBigBalls;
}

this.getTotalBalls=function(){
	return _this.total_balls_in_pool;
}

this.getRandominRange=function (min, max) {
    return Math.floor(Math.random()*(max-min +1))+min;
 }


_this.init();
}
