// changePage
function changePage(lst)
{
	if (lst.selectedIndex && (url = lst.options[lst.selectedIndex].value))
		document.location.href = url;
}

// toggle
$(document).ready(function()
{	
	// pngfix compatible :)
	$.fn.extend({
		src: function(v) {
			var f = this.css('filter'), fix = (f && f != 'none');
			if (typeof v == 'undefined')
				return fix ? f.replace(/^.+src='([^']+)'.+$/, "$1") : this.attr('src');
			else
				fix ? this.css('filter', f.replace(/src='([^']+)'/, "src='" + v + "'")) : this.attr('src', v);
		}
	});

	// gestion des toggle
	$('a.toggle')
		.each(function(){  $(this).hasClass('current') ? $(this.hash).show() : $(this.hash).hide(); })
		.click(function(){
			var self = this;
			if ($(this).hasClass('exclu'))
				$('a.toggle').each(function(){ if (this != self) { $(this.hash).hide(); $(this).removeClass('current'); } });
			$(this.hash).slideToggle("medium");
			$(this).toggleClass("current");
			return false;
		});
	
	// gestion des onglets
	var l = $(".menu_onglets > li > a[href^='#']");
	l.click(function()
	{
		$(l.filter('.current').removeClass('current').attr('hash')).hide();
		$(this).addClass('current');
		$(this.hash).show();
		return false;
	})
	.each(function(){ $(this.hash).hide(); })
	.first().click();
	
});

// selectToPopup
function selectToPopup(o)
{
	window.open(o.options[o.selectedIndex].value);
	o.selectedIndex = 0;
}

// shuffle :: faire "tourner" une série d'éléments
shuffle = function(selector, interval)
{
	if (!($(selector).length))
		return;

	var current = Math.floor(Math.random() * $(selector).length);
	$(selector).hide().eq(current).show();

	setInterval(function(){ 
		for(old=current; (current=Math.floor(Math.random() * $(selector).length)) == old;);
		$(selector).hide().eq(current).show();
	}, interval * 1000);
};

// ajoute un lien sur le body d'une page (promo, etc)
function setBodyLink(url)
{
	$('body').css('cursor', 'pointer');
	$('#container, #footer .content').css('cursor', 'default');
	$('body').click(function(e){
		var node = e.target;
		if (node.localName && node.localName == "body" || node.nodeName && node.nodeName == "BODY")
		{
			window.location = url;
		}
	});
}


