var App = {
	flashParameters : {
		wmode: 'transparent',
		allowscriptaccess:'always'
	}
}

function umbrellas(){
	var footerUmbrella = $('#footer-umbrella');
	var footerUmbrellaX = ($(document).width() / 2) + 221;
	var footerUmbrellaY = $('#content').height() + $('#content').position().top - 217;
	footerUmbrella.css('background-position', footerUmbrellaX+'px '+footerUmbrellaY+'px');
	
	var umbrellas = $('#umbrellas');
	var umbrellasX = ($(document).width() / 2) - 565;
	var umbrellasY = 86;
	umbrellas.css('background-position', umbrellasX+'px '+umbrellasY+'px');	
}

function baseBoot(){
	umbrellas();
	$(window).resize(function(){
		umbrellas();
	});
	swfobject.embedSWF(
			'flash/Hagels.swf',
			'flash',
			'1600',
			'1600',
			'9.0.0',
			'swf/expressInstall.swf',
			App.flashVariables,
			App.flashParameters,
			App.flashAttributes
		);

}

function calculateRandPos( location ){
	var rand = 1 + Math.floor(Math.random() * 10); // calculate a random number from 1 to 10
	var curclass = $('#page').attr('class'); // get the class (if set)
	var current = curclass.charAt( curclass.length-1 ); // get the class 'number'

	if( current ){
		if( current == rand ){
			// random is the same as current variation. change the random.
			(rand == 1 ) ? rand += 1 : rand -= 1 ;
		}
	}

	// set the class to location + random, like 'tennis6'
	$('.familievenz #page').attr('class',location+rand);
}

function randPosInit( location ){
	var location;
	var postime;
	var interval = 10000; /*changed to 10 sec*/

	calculateRandPos(location); // set the position on the first page load
	postime = setInterval(function(){ calculateRandPos(location) },interval); // set the position every x seconds

	$('.findelement a').click(function(){
		clearInterval( postime ); // clear the interval on click
		$('.foundblock').show();
		return false;
	});
	$('.foundblock a').click(function(){
		$('.foundblock').hide();
		clearInterval( postime ); // clear the interval on click, just to be sure..
		calculateRandPos(location); // set the position on click on object
		postime = setInterval(function(){ calculateRandPos(location) },interval); // set the position interval again
		return false;
	});
}

function introSlider(){
	var intro = $('#familie-intro'); // the slider element
	var slideinterval = 6000; // slide interval (slide after ... seconds)
	var lastslide = 4; // what is the last slide (count starts at 0) 
	var forward;
	
	// init slider from tinycarousel plugin. 
	// - plugincode modified: slider doesn't stop but scrolls on hover
	intro.tinycarousel({
		interval: 		true,
		intervaltime: 	slideinterval,
		duration: 		1500, 
		controls: 		true,
		callback: 		function(element, index){
							if(index != 0) $("#familie-intro a.buttons.next span").text("Volgende");
							else $("#familie-intro a.buttons.next span").text("Start");
		
							if(index==4){
								// if this is the last slide, stop the slider and redirect to landingpage
								intro.tinycarousel_stop();
								forward = setTimeout('window.location = "kaart.php"',slideinterval);
							}
						}
	});
}
