/* Bouncing up and down function */
var bounceglobal = false;

function startbounce(arg){
	if(bounceglobal == true) return;
	bounceglobal = true;
	var startPos = $(arg).getStyle('top');
	bounceup(arg, startPos);

}
function bounceup(arg, startPos){
	$(arg).setStyle({
		top: (parseInt(startPos)-2)+"px",
	});
	var uglyHack = function() { bouncedown(arg, startPos); };
	setTimeout(uglyHack, 150);
}

function bouncedown(arg, startPos){
	$(arg).setStyle({
		top: startPos,
	});
	if(bounceglobal == true){
		var uglyHack = function() { bounceup (arg, startPos); };
		setTimeout(uglyHack, 150);
	}
	else
		return;
}

function endbounce(arg){
	bounceglobal = false;
}
/* End bouncing function */

function showitem(arg){
	$(arg).setStyle({
		display: "inline",
	});
}

function hideitem(arg){
	$(arg).setStyle({
		display: "none",
	});
}

// Missions page swapping
function showmission(arg){
	if(arg == 'ark'){
		$('missions-crusade-text').hide();		
		$('missions-crusade-head').setStyle({
			opacity: "0.5",
		});
		$('missions-temple-text').hide();
		$('missions-temple-head').setStyle({
			opacity: "0.5",
		});
		$('missions-ark-text').show();
		$('missions-ark-head').setStyle({
			opacity: "1",
		});
	}
	if(arg == 'temple'){
		$('missions-crusade-text').hide();		
		$('missions-crusade-head').setStyle({
			opacity: "0.5",
		});
		$('missions-temple-text').show();
		$('missions-temple-head').setStyle({
			opacity: "1",
		});
		$('missions-ark-text').hide();
		$('missions-ark-head').setStyle({
			opacity: "0.5",
		});
	}
	if(arg == 'crusade'){
		$('missions-crusade-text').show();		
		$('missions-crusade-head').setStyle({
			opacity: "1",
		});
		$('missions-temple-text').hide();
		$('missions-temple-head').setStyle({
			opacity: "0.5",
		});
		$('missions-ark-text').hide();
		$('missions-ark-head').setStyle({
			opacity: "0.5",
		});
	}
}
// End missions page

// Downloads page effects
function overlay(){
/*	var arrayPageSize = getPageSize();
    $('downloads-overlay').setStyle({ 
		width: arrayPageSize[0] + 'px', 
		height: arrayPageSize[1] + 'px' 
	}); */

    new Effect.Appear($('downloads-overlay'), { duration: 1, from: 0.0, to: 0.7 });
}

function closeoverlay(){
	new Effect.Fade($('downloads-overlay'), {duration: 1, queue: 'end'});
}

function closewindow(arg){
	if(arg == "screenshots-window" && $('fullscreen-window').getStyle('display') != "none")
		new Effect.Fade($('fullscreen-window'), {duration: 0.5, queue: 'end'});
	if(arg == "desktops-window" && $('fulldesk-window').getStyle('display') != "none")
		new Effect.Fade($('fulldesk-window'), {duration: 0.5, queue: 'end'});
	if(arg == "trailers-window" && $('fulltrailer-window').getStyle('display') != "none")
		new Effect.Fade($('fulltrailer-window'), {duration: 0.5, queue: 'end'});
		
	new Effect.Fade($(arg), {duration: 0.5, queue: 'end'});
}

function screenshots(){
	new Effect.Appear($('screenshots-window'), {duration: 0.5, queue: 'end'});
}

function fullscreenshot(arg){
	new Effect.Appear($('fullscreen-window'), {duration: 0.5, queue: 'end'});
	imgSrc = "/data/games/legoindy/images/downloads/screenshots/"+arg;
	$('fullscreen').src=imgSrc;
}

function desktops(){
	new Effect.Appear($('desktops-window'), {duration: 0.5, queue: 'end'});
}

function fulldesktop(arg){
	new Effect.Appear($('fulldesk-window'), {duration: 0.5, queue: 'end'});
	imgSrc = "/data/games/legoindy/images/downloads/desktops/thumbs/"+arg+".jpg";
	deskPath = "/data/games/legoindy/images/downloads/desktops/"+arg+"_";
	$('fulldesk-thumb').src=imgSrc;
	$('desk1920').href=deskPath+"1920_1200.jpg";
	$('desk1680').href=deskPath+"1680_1050.jpg";
	$('desk1440').href=deskPath+"1440_900.jpg";
	$('desk1280').href=deskPath+"1280_800.jpg";
}

function trailers(){
	new Effect.Appear($('trailers-window'), {duration: 0.5, queue: 'end'});
}

function fulltrailer(arg){
	new Effect.Appear($('fulltrailer-window'), {duration: 0.5, queue: 'end'});
	imgSrc = "/data/games/legoindy/images/downloads/trailers/"+arg+".jpg";
	trailerPath = "/data/games/legoindy/trailers/"+arg+"/"
	$('fulltrailer-thumb').src=imgSrc;
	$('trailerlarge').href=trailerPath+"large.mov"
	$('trailermedium').href=trailerPath+"medium.mov"
	$('traileripod').href=trailerPath+"iPod.m4v"
	
}

function demo(){
	new Effect.Appear($('demo-window'), {duration: 0.5, queue: 'end'});
}

function comingsoon(){
	$('demos-image').src="/data/games/legoindy/images/downloads/demos-image-comingsoon.png";
}

function comingsoonfr(){
	$('demos-image').src="/data/games/legoindy/images/downloads/demos-image-comingsoon-FR.png";
}

function comingsoonoff(){
	$('demos-image').src="/data/games/legoindy/images/downloads/demos-image.png";
}
// End downloads page
