// préfonctions
function afficher(idpassee)
{
	document.getElementById(idpassee).style.display = 'block';
}
function cacher(idpassee)
{
	document.getElementById(idpassee).style.display = 'none';
}
var versionMinor = parseFloat(navigator.appVersion);
var versionMajor = parseInt(versionMinor);

var IE = document.all && !window.opera && versionMajor < 7;
var IE7 = document.all && !window.opera && versionMajor >= 7;
var OP = window.opera;
var FF = document.getElementById;
var NS = document.layers;

// renvoie l'element DOM
function get_item(name,opener){
	if (IE){
		return (opener)?window.opener.document.all[name]:document.all[name];
	}else if (FF){
		return (opener)?window.opener.document.getElementById(name):document.getElementById(name);
	}else if(NS){
		return (opener)?window.opener.document.layers[name]:document.layers[name];
	}
}
function change_display(name,value,opener){
	if (IE){ // IE
		element = (opener == true)?window.opener.document.all[name].style:document.all[name].style;
	}else if(FF){ // FF
		element = (opener == true)?window.opener.document.getElementById(name).style:document.getElementById(name).style;
	}else if(NS){ // NETSCAPE
		element = (opener == true)?window.opener.document.layers[name]:document.layers[name];
	}
	element.display = value;
}

function reverse_display(name,opener){
	element = get_item(name);
	if(!element)
	{
		return false;
	}
	var display = (element.style.display != 'block')?'block':'none';
	change_display(name,display,opener);
}


// -------------------------------------------------- -------------------------------------------- ----------------------------------------- ----------------------------------- ------------------------ -------------- --------- ------ ----- --- ---  -- -- -- - - - - -    -   -     -       -


// PAGE PRESENTATION
function dispPrez()
{
	cacher('historique');
	cacher('localisation');
	afficher('presentation');
	
	document.getElementById('histoTab').className = 'ongletInactif';
	document.getElementById('locTab').className = 'ongletInactif';
	document.getElementById('prezTab').className = 'ongletActif';
}
function dispHisto()
{
    cacher('localisation');
    cacher('presentation');
	afficher('historique');
	
	document.getElementById('locTab').className = 'ongletInactif';
	document.getElementById('prezTab').className = 'ongletInactif';
	document.getElementById('histoTab').className = 'ongletActif';
}
function dispLoc()
{
	cacher('historique');
    cacher('presentation');
	afficher('localisation');
	
	document.getElementById('prezTab').className = 'ongletInactif';
	document.getElementById('histoTab').className = 'ongletInactif';
	document.getElementById('locTab').className = 'ongletActif';
}

// PAGE DOMAINE D'ACTIVITES
function dispNaval()
{
	document.getElementById('cNavalTab').className = 'ongletActif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('cIndTab').className = 'ongletInactif';
	document.getElementById('magasinTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	
	cacher('portuaire');
	cacher('balisage');
	cacher('industriel');
	cacher('negoce');
	afficher('naval');
	
}
function dispCPor()
{
	cacher('naval');
	cacher('balisage');
	cacher('industriel');
	cacher('negoce');
	afficher('portuaire');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('cIndTab').className = 'ongletInactif';
	document.getElementById('magasinTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletActif';
}
function dispBal()
{
	cacher('naval');
	cacher('industriel');
	cacher('negoce');
	cacher('portuaire');
	afficher('balisage');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletActif';
	document.getElementById('cIndTab').className = 'ongletInactif';
	document.getElementById('magasinTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
}
function dispCInd()
{
	cacher('naval');
	cacher('balisage');
	cacher('negoce');
	cacher('portuaire');
	afficher('industriel');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('magasinTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	document.getElementById('cIndTab').className = 'ongletActif';
}
function dispMag()
{
	cacher('naval');
	cacher('balisage');
	cacher('industriel');
	cacher('portuaire');
	afficher('negoce');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('cIndTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	document.getElementById('magasinTab').className = 'ongletActif';
}

// PAGE REALISATIONS
function dispReaCNaval()
{
	document.getElementById('cNavalTab').className = 'ongletActif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('rNavalTab').className = 'ongletInactif';
	document.getElementById('clientsTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	
	cacher('portuaire');
	cacher('balisage');
	cacher('reparnaval');
	cacher('clients');
	afficher('construnaval');
	
}
function dispReaRNaval()
{
	cacher('construnaval');
	cacher('balisage');
	cacher('clients');
	cacher('portuaire');
	afficher('reparnaval');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('clientsTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	document.getElementById('rNavalTab').className = 'ongletActif';
}
function dispReaCPor()
{
	cacher('construnaval');
	cacher('balisage');
	cacher('reparnaval');
	cacher('clients');
	afficher('portuaire');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('rNavalTab').className = 'ongletInactif';
	document.getElementById('clientsTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletActif';
}
function dispReaBal()
{
	cacher('construnaval');
	cacher('reparnaval');
	cacher('clients');
	cacher('portuaire');
	afficher('balisage');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletActif';
	document.getElementById('rNavalTab').className = 'ongletInactif';
	document.getElementById('clientsTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
}
function dispReaCli()
{
	cacher('construnaval');
	cacher('balisage');
	cacher('reparnaval');
	cacher('portuaire');
	afficher('clients');
	
	document.getElementById('cNavalTab').className = 'ongletInactif';
	document.getElementById('balisageTab').className = 'ongletInactif';
	document.getElementById('rNavalTab').className = 'ongletInactif';
	document.getElementById('cPortTab').className = 'ongletInactif';
	document.getElementById('clientsTab').className = 'ongletActif';
}

// PAGE RESSOURCES
function dispTechprod()
{
	cacher('nautique');
	cacher('rH');
	afficher('techProd');
	
	document.getElementById('rHTab').className = 'ongletInactif';
	document.getElementById('nautiqueTab').className = 'ongletInactif';
	document.getElementById('techProdTab').className = 'ongletActif';
}
function dispNautique()
{
    cacher('rH');
    cacher('techProd');
	afficher('nautique');
	
	document.getElementById('rHTab').className = 'ongletInactif';
	document.getElementById('techProdTab').className = 'ongletInactif';
	document.getElementById('nautiqueTab').className = 'ongletActif';
}
function dispRH()
{
	cacher('nautique');
    cacher('techProd');
	afficher('rH');
	
	document.getElementById('techProdTab').className = 'ongletInactif';
	document.getElementById('nautiqueTab').className = 'ongletInactif';
	document.getElementById('rHTab').className = 'ongletActif';
}



// ouverture d'une fenetre
var current_tooltip;
function show_tooltip(caller,content,content_title)
{
	var current_tooltip = get_item('tooltip');
	
	if(!current_tooltip)
	{
		var current_tooltip = document.createElement('div');
		current_tooltip.setAttribute('id','tooltip');
		document.body.appendChild(current_tooltip);
	}
	current_tooltip.style.zIndex = 100;
	current_tooltip.style.position = 'absolute';
	
	if(content_title)
	{
		content = '<table background="contenu/img/fond_tooltip.png" style="border: 1px #4575be dashed; padding: 3px;" width=410 cellspacing=1><tr><td><font color=#233e81 size=2 face=\'Trebuchet MS\'><center><b>'+content_title+'<br />'+content;
	}
	else
	{
		content = '<table background="contenu/img/fond_tooltip.png" style="border: 1px #4575be dashed; padding: 3px;" width=410 cellspacing=1><tr><td><font color=#233e81 size=2 face=\'Trebuchet MS\'><center><b>'+content+'</b></center></td></tr></table>';
	}
	current_tooltip.innerHTML = content;
	current_tooltip.style.visibility = 'visible';
	// append action to DOM
	caller.onmousemove = move_tooltip;

	caller.onmouseout = function()
	{
		current_tooltip.style.visibility="hidden";
	}
}
/**
* Move the current_tooltip in document area
*/
var alerted = false;
function move_tooltip(e)
{
	if(!current_tooltip)
	current_tooltip = get_item('tooltip');
	
	if (!IE && !OP)
	{
		current_tooltip.style.left=e.pageX + 15+"px";
		current_tooltip.style.top=e.pageY + -200+"px";
	}
	else {
		if(document.documentElement.clientWidth>0)
		{
			current_tooltip.style.left=15+event.x+document.documentElement.scrollLeft+"px";
			current_tooltip.style.top=10+event.y+document.documentElement.scrollTop-150+"px";
		}
		else
		{
			current_tooltip.style.left=20+event.x+document.body.scrollLeft+"px";
			current_tooltip.style.top=100+event.y+document.body.scrollTop-150+"px";
		}
	}
}



// jcarousel
function mycarousel_initCallback(carousel)
{
	// Disable autoscrolling if the user clicks the prev or next button.
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});

	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});

	// Pause autoscrolling if the user moves with the cursor over the clip.
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};

jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 3,
		visible: 1,
		scroll: 1,
		wrap: 'last',
		initCallback: mycarousel_initCallback
	});
});