//test support dom
var dom_sup = 0;
if (document.implementation.hasFeature('Core', '2.0')){
	dom_sup = 2;
}
// variables
var opac_val = 0.3; //entre 0 et 1
var opac_delay = 0.7; //s
var timeout_delay = 300; //ms
var opac_act = 0;
//opacity
var evt_carte = 0;
var effet_ali;
var effet_met;
var effet_dos;
var effet_ref;
var effet_out;
//var redir = '192.168.0.100/projets/aliod_v1.3/'
function initObs (e){
	$('corps').observe('mouseover', act_over);
	$('corps').observe('click', act_go_url);
}
function act_go_url (event) {
	var lien = event.findElement('img');
	if(!lien) return;
	
	if (lien.id =='carte_aliod_blank') {event.stop(); window.location.href="aliod-0-0.html";}
	if (lien.id =='carte_metiers_blank'){event.stop();  window.location.href="metiers-0-0.html";}
	//if (lien.id =='carte_dossiers_blank'){event.stop();  window.location.href="dossiers-0-0.html";}
	if (lien.id =='carte_references_blank'){ event.stop(); window.location.href="references-0-0.html";}
}
// function opacity_observe () {
// 	ali_opa = $('carte_aliod').getStyle('opacity');
// 	met_opa = $('carte_metiers').getStyle('opacity');
// 	dos_opa = $('carte_dossiers').getStyle('opacity');
// 	ref_opa = $('carte_references').getStyle('opacity');
// 	$('dev_coords').update(' ali='+ali_opa+' met='+met_opa+' dos='+dos_opa+' ref='+ref_opa);
// 	setTimeout("opacity_observe()",200);
// }

function act_over (event) {
	
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');

	var opa_ad = ali_opa + met_opa + ref_opa ; //+dos_opa
	event.stop();
	
		//$('dev_coords').insert({top: '<br/> class='+event.element(this).className});
		//$('dev_coords').insert({top: '<br/> id='+event.element(this).id});
	if ((opac_act == 0) && (opa_ad != 4) && ((event.element(this).className == 'dev_ttl') ||  (event.element(this).id == 'menu_rt') ||  (event.element(this).id == 'accroche') ||  (event.element(this).className == 'texte')  ||  (event.element(this).className == 'pre_ul')   ||  (event.element(this).className == 'opac_1')))  {
			evt_carte = 5;
		setTimeout("out_delay()",timeout_delay);
		
	}
	else if (event.element(this).id == 'carte_references_blank'){
		evt_carte = 4;
		setTimeout("ref_delay()",timeout_delay);
		
		
			
	
	}
//	else if (event.element(this).id == 'carte_dossiers_blank'){
//		evt_carte = 3;
//		setTimeout("dos_delay()",timeout_delay);
//	}
	else if (event.element(this).id == 'carte_metiers_blank'){
		evt_carte = 2;
		setTimeout("met_delay()",timeout_delay);
		
			
			
	
	}
	else if (event.element(this).id == 'carte_aliod_blank'){
			
		evt_carte = 1;
		setTimeout("ali_delay()",timeout_delay);
		
			
	
	}
	//$('dev_coords').insert({top: '<br/> evt_carte='+evt_carte});
}
function ali_delay () {
	if (evt_carte == 1){
	if (effet_ref) effet_ref.cancel();
	if (effet_dos) effet_dos.cancel();
	if (effet_met) effet_met.cancel();
	if (effet_out) effet_out.cancel();
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');
	effet_ali = new Effect.Parallel(
			[
				new Effect.Opacity('carte_references', {sync: true, from:ref_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_aliod', {sync: true, from:ali_opa, to: 1, fps: 30}),
				new Effect.Opacity('carte_metiers', {sync: true, from:met_opa, to: opac_val, fps: 30}),
				//new Effect.Opacity('carte_dossiers', {sync: true, from:dos_opa, to: opac_val, fps: 30})
			],
			{
				duration: opac_delay,
				queue: 'end'
				
			});	
			//Element.setStyle('carte_dossiers', {height: '154px', background: 'transparent url(images/main/main_carte_dossiers.png) no-repeat 0 0', zIndex: '3'});
			//Element.setStyle('carte_dossiers_blank', {zIndex: '4'});
			Element.setStyle('carte_references', {height: '168px', background: 'transparent url(images/main/main_carte_references.png) no-repeat 0 0', zIndex: '1'});
			Element.setStyle('carte_references_blank', {zIndex: '2'});

	}
}
function met_delay () {
	if (evt_carte == 2){
	if (effet_ref) effet_ref.cancel();
	if (effet_ali) effet_ali.cancel();
	if (effet_dos) effet_dos.cancel();
	if (effet_out) effet_out.cancel();
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');
	effet_met = new Effect.Parallel(
			[
				new Effect.Opacity('carte_references', {sync: true, from:ref_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_aliod', {sync: true, from:ali_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_metiers', {sync: true, from:met_opa, to: 1, fps: 30}),
				//new Effect.Opacity('carte_dossiers', {sync: true, from:dos_opa, to: opac_val, fps: 30})
			],
			{
				duration: opac_delay,
				queue: 'end',
				afterFinish:function(){}
				
			});	
			//Element.setStyle('carte_dossiers', {height: '154px', background: 'transparent url(images/main/main_carte_dossiers.png) no-repeat 0 0', zIndex: '3'});
			//Element.setStyle('carte_dossiers_blank', {zIndex: '4'});
			Element.setStyle('carte_references', {height: '168px', background: 'transparent url(images/main/main_carte_references.png) no-repeat 0 0', zIndex: '1'});
			Element.setStyle('carte_references_blank', {zIndex: '2'});
	}
}
function dos_delay () {
	if (evt_carte == 3){
	if (effet_ref) effet_ref.cancel();
	if (effet_ali) effet_ali.cancel();
	if (effet_met) effet_met.cancel();
	if (effet_out) effet_out.cancel();
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');
	effet_dos = new Effect.Parallel(
			[
				new Effect.Opacity('carte_references', {sync: true, from:ref_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_aliod', {sync: true, from:ali_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_metiers', {sync: true, from:met_opa, to: opac_val, fps: 30}),
				//new Effect.Opacity('carte_dossiers', {sync: true, from:dos_opa, to: 1, fps: 30})
			],
			{
				duration: opac_delay,
				queue: 'end',
				afterFinish:function(){}
				
			});	
			if (dom_sup == 2)
			{
				//Element.setStyle('carte_dossiers', {height: '168px', background: 'transparent url(images/main/main_carte_dossiers_over.png) no-repeat 0 0', zIndex: '10'});
			}
			else {
				//Element.setStyle('carte_dossiers', {height: '168px', background: 'transparent url(images/main/main_carte_dossiers_over.gif) no-repeat 0 0', zIndex: '10'});
			}
							
			//Element.setStyle('carte_dossiers_blank', {zIndex: '11'});
			Element.setStyle('carte_references', {height: '154px', background: 'transparent url(images/main/main_carte_references.png) no-repeat 0 0', zIndex: '1'});
			Element.setStyle('carte_references_blank', {zIndex: '2'});
	}
}
function ref_delay () {
	if (evt_carte == 4){
	if (effet_dos) effet_dos.cancel();
	if (effet_ali) effet_ali.cancel();
	if (effet_met) effet_met.cancel();
	if (effet_out) effet_out.cancel();
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');
	effet_ref = new Effect.Parallel(
			[
				//new Effect.Opacity('carte_dossiers', {sync: true, from:dos_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_aliod', {sync: true, from:ali_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_metiers', {sync: true, from:met_opa, to: opac_val, fps: 30}),
				new Effect.Opacity('carte_references', {sync: true, from:ref_opa, to: 1, fps: 30})
			],
			{
				duration: opac_delay,
				queue: 'end',
				afterFinish:function(){}
				
			});	
			//Element.setStyle('carte_dossiers', {height: '154px', background: 'transparent url(images/main/main_carte_dossiers.png) no-repeat 0 0', zIndex: '3'});
			//Element.setStyle('carte_dossiers_blank', {zIndex: '4'});
			if (dom_sup == 2)
			{
				Element.setStyle('carte_references', {height: '168px', background: 'transparent url(images/main/main_carte_references_over.png) no-repeat 0 0', zIndex: '10'});
			}
			else {
				Element.setStyle('carte_references', {height: '168px', background: 'transparent url(images/main/main_carte_references_over.gif) no-repeat 0 0', zIndex: '10'});
			}
			Element.setStyle('carte_references_blank', {zIndex: '11'});
	}
}
function out_delay () {
		if (evt_carte == 5)
		
		{

		opac_act == 1;
		if (effet_ref) effet_ref.cancel();
		if (effet_ali) effet_ali.cancel();
		if (effet_met) effet_met.cancel();
		if (effet_dos) effet_dos.cancel();
	var ali_opa = Element.getStyle('carte_aliod','opacity');
	var met_opa = Element.getStyle('carte_metiers','opacity');
	//var dos_opa = Element.getStyle('carte_dossiers','opacity');
	var ref_opa = Element.getStyle('carte_references','opacity');
	
		effet_out = new Effect.Parallel(
			[
				//new Effect.Opacity('carte_dossiers', {sync: true, from:dos_opa, to: 1, fps: 30}),
				new Effect.Opacity('carte_aliod', {sync: true, from:ali_opa, to: 1, fps: 30}),
				new Effect.Opacity('carte_metiers', {sync: true, from:met_opa, to: 1, fps: 30}),
				new Effect.Opacity('carte_references', {sync: true, from:ref_opa, to: 1, fps: 30})
			],
			{
				duration: opac_delay,
				afterFinish:function(){opac_act = 0;}
				
			});	
			//Element.setStyle('carte_dossiers', {height: '154px', background: 'transparent url(images/main/main_carte_dossiers.png) no-repeat 0 0', zIndex: '3'});
			//Element.setStyle('carte_dossiers_blank', {zIndex: '4'});
			Element.setStyle('carte_references', {height: '168px', background: 'transparent url(images/main/main_carte_references.png) no-repeat 0 0', zIndex: '1'});
			Element.setStyle('carte_references_blank', {zIndex: '2'});
			
	}

}


 if (document.getElementById && document.createTextNode){
	document.observe('dom:loaded', initObs);
	
}
