
var mobile=0;

// Début script pour le menu horizontal déroulant 
fDomOffset = function( oObj, sProp )
{
 var iVal = 0;
 while (oObj && oObj.tagName != 'BODY') {
  eval('iVal += oObj.' + sProp + ';');
  oObj = oObj.offsetParent;
 }
 return iVal;
}

fSwapSelect = function( sId ) 
{ 
 oObj = document.getElementById(sId); 
 Top_Element  = fDomOffset(oObj, 'offsetTop'); 
 Left_Element  = fDomOffset(oObj, 'offsetLeft'); 
 Largeur_Element  = oObj.offsetWidth; 
 Hauteur_Element  = oObj.offsetHeight; 
 oSelects = document.getElementsByTagName('SELECT'); 
 if (oSelects.length > 0) { 
  for (i = 0; i < oSelects.length; i++) { 
   oSlt = oSelects[i]; 
   Top_Select = fDomOffset(oSlt, 'offsetTop'); 
   Left_Select = fDomOffset(oSlt, 'offsetLeft'); 
   Largeur_Select = oSlt.offsetWidth; 
   Hauteur_Select = oSlt.offsetHeight; 
   isLeft = false; 
   if ((Left_Element > (Left_Select - Largeur_Element)) && (Left_Element < (Left_Select + Largeur_Select))) { 
    isLeft = true; 
   } 
   isTop = false; 
   if ((Top_Element > (Top_Select - Hauteur_Element)) && (Top_Element < (Top_Select + Hauteur_Select))) { 
    isTop = true; 
   } 
   if (isLeft && isTop) { 
    sVis = (oObj.style.visibility == 'hidden') ? 'visible' : 'hidden'; 
    if (oSlt.style.visibility != sVis) {oSlt.style.visibility = sVis;} 
   } else { 
    if (oSlt.style.visibility != 'visible') {oSlt.style.visibility = 'visible';} 
   } 
  } 
 } 
} 

function ferme_autres_que(ongletID) {
	var a_afficher=document.getElementById('ssonglet_'+ongletID);
	var deb=document.getElementById('onglets');
	var divs=deb.getElementsByTagName('div');
	var reg=/ssonglet_(.*)/
	for(var i=0 ; i<divs.length ;i++) {
		var div = divs[i];
		if (div.id.match(reg) && div.id != a_afficher.id) {
			var m = div.id.match(reg);
			div.style.display='none';
			document.getElementById('ongletBit_'+m[1]).className='ongletBit';
		}
	}
}

function montre(ongletID) {
	document.getElementById('ongletBit_'+ongletID).className='ongletBit_over';
	if (document.getElementById('ssonglet_'+ongletID)) {
		var reg=/MSIE 6/;
		document.getElementById('ssonglet_'+ongletID).style.display='block';
		ferme_autres_que(ongletID);
		if (navigator.appVersion.match(reg)) fSwapSelect('ssonglet_'+ongletID);
	}
}

var timeoutdiv=false ;
var t = 500;
function timeoutHide(ongletID)
{
	clearTimeout(timeoutdiv);
    timeoutdiv = setTimeout("hidediv('"+ongletID+"');",t );
}

function clearTime() {
	clearTimeout(timeoutdiv);
}

function hidediv(ongletID)
{ 
	if (document.getElementById('ssonglet_'+ongletID)){
		var reg=/MSIE 6/;
		 document.getElementById('ssonglet_'+ongletID).style.display='none';
		if (navigator.appVersion.match(reg)) fSwapSelect('ssonglet_'+ongletID);
	}
}
// Fin script pour le menu horizontal déroulant 

//Dédut fonction montrer et cacher un div
function montrer(divID) {
	if (document.getElementById(divID)) {
		document.getElementById(divID).style.display='block';
	}
}

function cacher(divID) {
	if (document.getElementById(divID)) {
		document.getElementById(divID).style.display='none';
	}
}
//Fin fonction montrer et cacher un div

// Début script pour affichage description complète ou partielle
function voir_desc_total()
{
	var fp = document.getElementById('fiche_partielle');
	fp.style.display="none";
	var fc = document.getElementById('fiche_complete');
	fc.style.display="block";
}

function voir_desc_partiel()
{
	var fp = document.getElementById('fiche_partielle');
	fp.style.display="block";
	var fc = document.getElementById('fiche_complete');
	fc.style.display="none";
}
// Fin script pour affichage description complète ou partielle

//Script pour texte administrable
$(document).ready(function() {
	//$(".nombre").attr('readonly', 'readonly');
	jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.05
		}, settings);		
		return this.each(function(){
			var $strip = jQuery(this);
			$strip.addClass("newsticker")
			var stripWidth = 0;
			var $mask = $strip.wrap("<div class='mask'></div>");
			var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
			var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
			$strip.find("li").each(function(i){
			stripWidth += jQuery(this, i).outerWidth(true); // thanks to Michael Haszprunar
			});
			$strip.width(stripWidth);			
			var totalTravel = 700;
			var defTiming = totalTravel/settings.travelocity;
			function scrollnews(spazio, tempo){
			$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", 0); scrollnews(totalTravel, defTiming);});
			}
			scrollnews(totalTravel, defTiming);				
			$strip.hover(function(){
			jQuery(this).stop();
			},
			function(){
			var offset = jQuery(this).offset();
			var residualSpace = offset.left + stripWidth;
			var residualTime = residualSpace/settings.travelocity;
			scrollnews(residualSpace, residualTime);
			});			
		});	
	};
});

