
// 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

//Script pour afficher la page catégorie de 2 façons différentes
function montrer_rayons(nb_sscategs) {
	var nb = nb_sscategs;
	if (nb >0) {
		$('#desrayons').css('display','block');
		$('#unrayon').css('display','none');
	} else if (nb == 0) {
		$('#desrayons').css('display','none');
		$('#unrayon').css('display','block');
	}
}

function PrmUrl()
{
 var prm = new Array();
 var tmp = unescape(window.location.search).substr(1).split("&");
 var inter;
 for ( i=0; i<tmp.length; i++)
 {
  inter=tmp[i].indexOf("=");
  if ( inter>=0 )
    {
     prm[tmp[i].substr(0,inter)]=tmp[i].substr(inter+1)
    }
  else {
     prm[tmp[i]]="";
    }
 }
 return prm;
}



// 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 = 520;
			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);
			});			
		});	
	};
});


function css_emulateMaxWidthHeight() {
/* (c) Evan Roberts - 7/10/2009
www.GoWFB.com - Wholesale Furniture Brokers
Everyone is free to use/mdoify this but please keep the copyright statement!
*/

	$(".ongletBit",".ongletBit_over").each(function() {		

		if( $(this).css('max-width') != 'none' || $(this).css('max-height') != 'none' ) {

			max_width = $(this).css('max-width').replace(/[^0-9]/g, '');
			max_height = $(this).css('max-height').replace(/[^0-9]/g, '');		

			if( $(this).width() > max_width || $(this).height() > max_height ) {
				if( (max_width / $(this).width()) < (max_height / $(this).height()) ) {
					$(this).css('height', Math.round($(this).height() * (max_width / $(this).width())));
					$(this).css('width', max_width);
				} else {
					$(this).css('width', Math.round($(this).width() * (max_height / $(this).height())));
					$(this).css('height', max_height);
				}

			}
		}
	});
}

$(document).ready(function() {
	css_emulateMaxWidthHeight();
	$("#onglets .ongletBit:last-child").css("background","none");
});


