/* 
!! CHECKUPDATES.PHP NEEDS TO MANUALLY GET CHANGED ON UPDATE FOR VERSION 1.20 (1.2 IN FILE)
!! REMEMBER TO SET: VERSION = VERSION, BETA = FALSE
!! UPDATE DATABASE TO CURRENTVERSION + LINK(to file or apple)
!! HUSK AT ÆNDRE PLIST!
!! Husk warning ang reset af score
!! CHECK ALLE ***
*/

/*

Final release notes:
Fruitz 2.0
Keyboard shortcuts for rolling and holding
Online personal highscore submission and tracking
Improved graphics
Online update checking
Personality switch
New rules added
Special events
Multiline responses
Mini illustrations for wins
Even more animation
Dialogs for updates and submissions
Special events
Rotating links and welcome texts
More than 200 new responses from the Slotmachine
Core score results rewritten 
All new Fruitz website
Time played information

**Warning. If you allready have a version of Fruitz, your current score will be reset.**



*/
/*

//**********************************************************
// Fruitz 1.50
//
// Author: Kevin Andersson
// Editor: Anders Christensen
// Fruitcake icon: Kobhen
// Website: http://blog.kevinandersson.dk
// Email: graphics@kevinandersson.dk
// Fruitz website: fruitz.kevinandersson.dk
//
//*********************************************************




//*********************************************************
Fruits:
1. grapes
2. strawberry
3. cherries
4. banana
5. watermelon
6. apple
7. coconut
8. peach
9. blackberry
10. orange
11. kiwi
12. lime
13. special orange
14. BAR
15. Joker
//*********************************************************

*/


var version = "1.52";// 1.49 release candidate for 2.0
var beta = true;

var dailyChecked = false;

var resetfix = false;
var speeds = new Array(250, 110, 60, 20);							
var currency = new Array('<img src="images/yen.png" class="coin" />', '<img src="images/dollar.png" class="coin" />', '<img src="images/euro.png" class="coin" />', '<img src="images/pound.png" class="coin" />','<img src="images/gold.png" class="coin" />', '<img src="images/apple.png" class="coin" />'); 
var minicurrency = new Array('<img src="mini/yen.png" class="minicoin" />', '<img src="mini/dollar.png" class="minicoin" />', '<img src="mini/euro.png" class="minicoin" />', '<img src="mini/pound.png" class="minicoin" />','<img src="mini/gold.png" class="minicoin" />', '<img src="mini/apple.png" class="minicoin" />'); 
// yen, dollar, euro, pound, gold, apple
//var tempgold;
var rolling = false;
var startgold;	
var currentspeed;
var currencyselection;
var tempgold;
var waittimeronscreen;
var currentversion  = version;
var welcometext;
var versionlink;
var berry_count = 0;
var roll_count;
var todays_link;
var versionnote;
var update_selection;
var personality;
/* text animation */
var anitimer;
var mainmessage;
var alphavalue;
var old_count = 0;
var timer; 
var eanitimer;
var ealphavalue;
var target;
var waittimer;
var switchani;
var addString;
var feed;	
var textDisplaytime = 3200;

/* XML information */
var last_updated = 0;
var xml_request = null;
var extra_anitimer;
var extra_anitimer_a;
var extra_wait_timer;
var extra_alphavalue = 100;
var today_opened = false;
var checkDate = new Date();
var checktime = 1000*60*60*24; // millisekunder x sekunder x timer * 24
var maxbet = 50000;
var corereset;
var typer = false;
var useridentify = 0;
var username = '';

function initialize(){
	_uacct = "UA-1003170-13"; // google
	urchinTracker(); // google
	initialized = false;
	slotitem = new Array('0','1','2','3','4','5','6','7','8','9','10','11','12','13','14', '15', '16');
	fruitcount = new Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0)//17
	slotnames = new Array('Lemons',
						  'Grapes',
						  'Strawberries',
						  'Cherries',
						  'Bananas',
						  'Watermelons',
						  'Apples',
						  'Coconuts',
						  'Peaches',
						  'Blackberries',
						  'Oranges',
						  'Kiwis',
						  'Lime',
						  'Special Oranges',
						  'BARS', 
						  'Joker');
	
	//document.slots.bet.focus();
	
	startgold = 250;
	totalgold = startgold;
	tempgold = totalgold;
	document.getElementById("total_gold").value = startgold;
	document.getElementById("gold_score").innerHTML = totalgold;
	
	//alert(document.getElementById("gold_score"))
	totalvisits = 0;

	currencyselection = 4;
	currentspeed = 3;

	hold1 = false;
	hold2 = false;
	hold3 = false;
	antal = 16;	
	holded = 1;
	addgold = 1000;
	betvalue = 10;
	minimumbetting	= 10;
	spin_clicks = 0;
	minimumtohave = 500; // minimum to get extra gold
	currentspeed = 3;
	waittimeronscreen = 800;

	update_selection = true;
	personality = true;

	
	pair = 'none';
	
	document.getElementById('holda').style.backgroundImage = 'url(images/nohold_disabled.png)';			
	document.getElementById('holdb').style.backgroundImage = 'url(images/nohold_disabled.png)';
	document.getElementById('holdc').style.backgroundImage = 'url(images/nohold_disabled.png)';	
	

	tempgold = startgold;
	max_count_a = Math.floor(Math.random()*60);
	max_count_b = Math.floor(Math.random()*60);
	max_count_c = Math.floor(Math.random()*60);
	max_counter_d = speeds[currentspeed]; // spinner time
	
	slot1_now = 0;
	slot2_now = 0;
	slot3_now = 0;
	rolling = false;
	holders = 0;
//	setMessage('Welcome to version '+version)
	document.getElementById('version_back').innerHTML = version;	
	extra_1 = false;
	


	showInformation('<br> <brSetting initialization...',true, 1, true); // text, fade in, extraicon, closebutton	
	getPrefs();	
	getXMLdata();	
	resetHolders();	
	setBet(0);	
	//setgold();
	startCounting();


}


// username, check username (if exists), 


/*
//*********************************************************
// History

Version:
0.01 
Controls
Rolling
Blurred rolling

0.02
Overlay on score

0.03
Info window

0.04
Hold buttons + check on hold first round
Variable amount of fruits
Hold pair fix - no second winning on the same pair
Info window
Bigger font on score + position
Accept knap

0.05
Disabled hold graphics
Seperate stop
Animated win

0.06
Interface improvements, reflections, overlays
Performance inprovements
Point system, with text information
Apple BAR icon
Ruleset on back
Flip animations
Spin button fix
Removed the top bar, fits better with the other widgets
Other minor adjustments
Decrement in size (only 1mb zipped now)


0.07
Win function to handle wins
Fruit names added to wins
Fixed win bug
Joker
Orange with straw is double point 
Bar super win
Hold fix after double win
Withdraw money on roll
No spinning when already spinning

0.8
Set information text function
Optimized graphics, smooth colors
Max 2 active holders at the same time + information to the user
Alpha animation on messages
Random loose messages, find Steve ;)

0.9
Toned down text overlay
Variable bets (Betting amount)
Bet step buttons
Variable speeds on adding gold
Dynamic version numbering
New back
New hold graphics

0.10
More "no match" phrases - if you have any suggestions feel free to come with them :)
1/500 chance to get extra bonus on 25000 gold
Powerups on top (x2 points)
Fruit counter
Strawberry bonus
Mini icon fixed round reflection
Currency definition
Custom currencies, or images for currency

0.11
You collected x fruits popup
Win fixes
Save preferences (gold, betamount, currency)
Get preferences(gold, betamount, currency)
Reset preferences (And save them)
Save money won
Load money won
Save bet amount
Load bet amount
New graphics for all currencies
Amount of times spinned
Set icon for currency
Reset switch (with switchin :) )
New backside
Roll buttons goes down on press (not hover)
"Bet changed to *currency" text
Bug fix: Adding gold from blog.kevinandersson.dk will now add correctly
Bet can't be more than your total gold
Minimum bet text
Select chosen currency selection if set in the preferences
Sticking spin button
Animation on spin button

0.12
Bug fix: Reset fixed. No you will get the gold :)
Bug fix: Gold will now be added correctly 
Don't display currency change on startup
No change in bets while spinning
Random stops on the spinners
Faster gold addup on high bets
Timer fixes (spinner timeout cleared)
Variable spin time (variable, for later preferences)
Speed selection added to preferences
Speed selection is saved in preferences
More random winnings
Speed control on big winnings
Icon on final widget


1.1 (bugfix)
Bugs:
Fast click on spin button made the spinners stuck
HOLD button got stuck


1.1c (bugfix)
NULL setting fix

1.1d (bugfix)
Remove old settings on reset
Initialize correctly

1.2
CSS fix (overlays)
Bug fixes
Online version check
Overlay information window


1.34
Updates version checker for online statistics
Message of the day 
Link of the day
Fadeout on check message decreased
Daily update check
Remove personality chip :)
Check for updates button
Reset Fruitz fixes
Close widget button position fix
Code cleanup, with 2000 lines of javascript it gets messy
Animation cleanup on "info" button
3xbar win decresed to 50xbet and 10xbet for 2xbar
Updated backside, front and rulepage
Rules made more prominent
Fruitcake winning added with a illustration by Kobhen
Max bet 500 points
If bet is more than the total points, and less than the max bet - the bet is set to max bet (on loss)
Spinners getting stuck, fixed
If beta version beta downloads enabled (automatic beta updates)

1.38
New responses
Keyboard commands activated: SPACE spins the machine, 1 2 3 Holds the spinners
More than 15.000 users worldwide!

1.39
Rotten fruits fixed
"You have the latest version" text removed
Over 100 new responses added
Text display messsage animation
Message container fixed
Spelling mistakes...
Timer on textdisplay (time before it scrolls)
PLIST file updated

1.40
Version checker improved
Core reset

1.41
Information about update in checker
25.000 and server crash(30.09.07 - 03:30 - fixed at 03:45)
Clear text animation (sliding) on roll - not rolling the next text
Online highscore registraion + submit button + information to user
Reset score function
ShowInformation timeout cleared when showing a new window
"More" added to multiline responses
Responses onscreen time increased

1.46
Now showing "you have the latest version again" :
Submit highscore fix. (If you havn't gotten 1500 you don't reset)
Update notes in version check
Changed rotten Fruitz to a 1/50 chance 
Database fixes
fruitz.kevinandersson.dk up and running
More highscores, and user highscores ("user profile")
Even more responses
Version on back moved down and logo outline removed
Whole win rewritten, from 250 lines to just 100, now with easy specific win situations for later
Text scroller fix

1.47
Additions:
Link to fruitz home on backside
Mini fruitz on wins
Mini gold added for wins / losses
Personal scores on Fruitz.kevinandersson.dk
+Click user to see all his scores

Corrections:
Max text to scroll decresed
Text corrections
Moved score up to fit submit button
Joker fix - if joker the fruit will be stated instead of the joker (at 3 of a kind)
Response: "I challange you to a dual" corrected to "I challange you to a duel"

Bugs:
Lemon win (double variable use). Fixed
Win text on two strawberries ("two grapes") corrected
Three Bars result in 200 points on a 20 point bet instead of 50x the bet. Fixed
No win on Lime. Fixed
Joker and 2 fruitz of same type only register as lucky joker.This is regardless of where the joker is positioned. Fixed
Special orange does not result in a win. Fixed

1.48
Counter, time spend button, only timing on active
Firefox / safari 3 compability

1.49
Corrections:
Strawberry popup stays on screen for 500 milliseconds
Big win popupscreens stays on screen for 2000 milliseconds
Clear timer on big popup if another on shows afterwards (so it doesn't close on show)
Hitting 70.000 users :D
No reset of score on update from version 1.2

1.50
User login in the widget
Reset score button
Reset score activation (on upgrade)
Roll button position fix (ragged edges)
Count up / down optimization (score dependent)
Selective submission of score
Optimized information windows, and content dependent sizes
Score text size optimized
Joker fix 
Special orange fix
Size optimization

Website:
Added icons for highscore pages
Added a download button on the front page
** Added comment section for users
Daily star. If you made it to the first place a day you will get a star in your personal profile

1.51
* Submit more info for the statistics (rollcount, timeplayed, score)

** 512 icon
**Bugs:
*** You have been banned text -on submit of highscore
**No win on Bar + fruitx2
**joker-joker-bar states as "2 special oranges"
*** animation on button (move down + right)
*** maximum score 1 billion
*** information time on screen (new downloads, you got the latest version)
*** submit time spend on this submitted win
*** Special orange win combination
*** check for updates (check if it's working)
*** Reset score on front (to 250 gold)
*** Direct link to download (in database + read)
**** on score submit reset roll counter (rollcount will be sent to server)
**** Final: Check på rollcount / submitted score / playtime for at finde ud af om det er reelt
**** RSS feed på daily scores / top 100
**** Lokal roll count til tjek
**** Rolling text gettign stuck
**** x2 special win - doesn't pay double
**** max bet raise with score (and decrese on submit + lower score)
**** score comments
**** display user submitted scores amount + registered users count on admin
**** No resetting the score!
**** Anders: Submit x points to score, show your total score on website (sum)
*** forskellige server feeds?
** gamble 50% of your current score? Youre chance to win is 10 / 1
** two special oranges = no win
** debug window
** You're score has been submitted, and can be viewed here.
** Time played counter
*** Downloaded from in javascript
*** Check om check for updates virker
*** Under 100 -> money boost
** Big version updates window
** How much do you want to submit?
** Link to registration after 'check for updates'
** Fix textscroller!
** Submit highsore - reset score + weekly highscores + yesterdays highscore (registered)
** Downloads - either refer to blog -> downloads / apple.com
** counter on how many uses the highscore page (database entry)
** PHP fil der generer "yesteday" highscore (1 fil)
** Event ved 1.000.000
** Event ved 100.000
** Event ved 10.000
** Event ved 5.000
** Warning on reset (global variabel om den er resat - hvis ikke, besked: ingen highscore + gem information)
* REKLAMER! I fruitz
** special orange fix!!!
** RESET scores on final release
** Button includes
** HUSK* Personality button swap to inactive on load prefs
** HUSK* Auto updates check on pref load
** HUSK* 2x win move animation timer
** Clear animation timer
** Subdomæne for fruits

* Daily highscore, online
* Daily highscore - ingame
* Daily highscore widget?
* tilføjelse af numerisk tastatur
* rollover på informations link (daily link) - fade in / out
* Personality: Lovely, Normal, Mean
* highscore implementation (in fruitz)
* rolling text hvis der er for meget til fremviseren
* vil du smide 1000 for at prøve lykken? ja = +5000 nej = -5000
* Information page on wins
* send variable "check" when check for updates is pressed
* win array {x,x,y,win}
* send bug report
* personal login
*if multible splash (2x) + (strawberries) animation sticks
* Skins
* countdown; you have X seconds to get 10 x coconuts
* If bet is higher than total gold, set to total gold
* Statistics
* PowerUp turbo mode
* minigame ved 3x bars - flip til ny side
* bar + x + x (wildcard)
* Clickcounter!
* Fade in on hold buttons 

//*********************************************************
*/