var num_img=new Array();
var image=0;

Event.observe(window, 'load', function() {
	if ($('traintrain')) {
		if (FlashDetect.installed) {
			$("traintrain").show();
		} else {
			exit_flash();
			debut_violet();
		}
	};
});

//document.observe("dom:loaded", function() {
//	$('encart').hide();
//});



function swap (id) {
	file_name=document.getElementById(id).src
	if (!file_name.match("-over")) {
		new_file = file_name.replace(/(.*?)\.(\w+)$/, "$1-over.$2");
	} else {
		new_file = file_name.replace(/(.*?)-over\.(\w+)$/, "$1.$2");
	}
	document.getElementById(id).src=new_file;
}

function list_state (actu_page) {
	document.getElementById("liste_"+actu_page).className="select";
	document.getElementById("liste_"+page).className="";
	page=actu_page;
}
function show_pic(actu_image,nb_img,direction) {
	
	if (direction=='ff'){
		if(actu_image<nb_img-1) {
		image=actu_image+1
		} else {
			image=0;
		}
	} else if (direction=='rew') {
		if(actu_image>0) {
			image=actu_image-1
		} else {
			image=nb_img-1;
		}
	}
	
	document.getElementById("pic_folio").src=num_img[image]
	if (credits[image]!='') {
		$('credits').update();
		$('credits').show();
		$('credits').insert(credits[image])
	} else {
		$('credits').hide();
	};
	
	
}
function folio_preload() {
	var i=0;
	preload_image_object = new Image();
	for(i=0; i<num_img.length; i++){
		preload_image_object.src = num_img[i];
	}
}

function debut_violet () {
	$('starter').show();
	$('starter').morph('width: '+starter_width+'px;',{ duration: 0.5});
	$('train_box').setStyle({backgroundImage: 'url(pic/train_train.jpg)'});
	//$('brainsol_box').setStyle({backgroundImage: 'url(pic/ecusson_l.jpg)'});
}

function exit_flash () {
	$('brainsol_box').show();
	$('traintrain').hide();
}

function switch_on () {
	//alert("on");
	$('starter').hide();
	$('orange_lane').show();
	$('corpse_coin','encart','desordre','ektachrome').invoke('appear',{ duration: 0.5 });
	
	
}

function ektachrome_on () {
	$('ektachrome').setStyle({width: '164px',height: '30px',left: '43px',top: '182px'});
	$('desordre').setStyle({width: '85px',height: '21px',left: '103px',top: '270px'});
}

function init() {
	

	
	//$('royalpixel_box').observe('mouseover', function(){
	//	$('royalpixel').setStyle({backgroundPosition: '28px'});
	//});
	//
	//$('royalpixel_box').observe('mouseout', function(){
	//	$('royalpixel').setStyle({backgroundPosition: '0'});
	//});
	
	$('desordre').observe('click', function () {
		$('desordre').morph('width: 131px; height: 34px; left: 57px; top: 180px',{ duration: 0.3});
		$('ektachrome').morph('width: 96px; height: 18px; left: 107px;top: 270px',{ duration: 0.3});
		showpages('print','fr');
	})
	
	$('ektachrome').observe('click', function () {
		$('ektachrome').morph('width: 164px;height: 30px;left: 43px;top: 182px',{ duration: 0.3});
		$('desordre').morph('width: 85px;height: 21px;left: 103px;top: 270px',{ duration: 0.3});
		showpages('photo','fr');
	})
	
	if ($('box_eclair')) {
		$('box_eclair').observe('click', switch_on);
	};
	
	
	
	// bandes scotch bleu, à améliorer
	
	$('legal_box').observe('click', function(){
		if ($('legal').visible()) {
			//init_plan();
			$('legal').hide();
			$('legal_box').morph('width: 360px;height: 60px;',{ duration: 0.3,afterFinish:function(){
				$('credits_bas').appear({duration:0.4});
			} });
		} else {
			init_legal()	
		}
	});
	
	function init_legal () {
			
			$('credits_bas').hide();
			$('legal_box').morph('width: 54px;height: 21px;',{ duration: 0.3,afterFinish:function(){
				$('legal').show();
				} });
		
	}
}
