var where = "flash";
var class_css_prefix = "inst_";
var currentInsittute=0;

function clickInstitute() {
	if(currentInsittute!=0) {
		url = inserm.carrouselURL.get(class_css_prefix + currentInsittute);
		if ( url != "" ) {
/*			alert("Click on "+url);*/
			window.location = url;
		}
	}
}

function changeBackground( id, color, etat, where ){
	var colorFinal, background, img, backgroundOnTop;
	
	/*              1  2  3  4  5  6  7  8  9 10*/
	var idEquiv=[0, 9,10, 2, 1, 3, 4, 5, 6, 7, 8];
//	alert("Code "+id+"/"+idEquiv[id]);
	id=idEquiv[id];
	
	
	if ( $('nav') ) {
		
		/* Ajout de la classe NoBg */
		var addNoBg = function(a) {
			if ( a.getParent().getPrevious() ) {
				a.getParent().getPrevious().addClass('nobg');
			}
		};
		
		/* Suppression de la classe NoBg */
		var removeNoBg = function(a) {
			if ( a.getParent().getPrevious() && !a.hasClass('slide')) {
				a.getParent().getPrevious().removeClass('nobg');
			}
		};
		
		/* Virer le hightlight */
		var unhightlightAll = function() {
			$$('li a', 'nav').each( function( a ){
				a.removeClass('hightlight');
				removeNoBg(a);
			});
		}
		
		/* Aller à l'url */
		var goToURL = function() {
			if ( typeof(inserm) != "undefined" ) {
				url = inserm.carrouselURL.get(class_css_prefix + id);
				if ( url != "" ) {
					window.location = url;
				}
			}
		}
		
		/* Action celon l'état */
		if( etat == 'over' ) {
			currentInsittute=id;
			unhightlightAll();
			a = $('nav').getElement('.' + class_css_prefix + id + ' a');
			a.addClass('hightlight');
			addNoBg(a);
		}
		
		if( etat == 'out' ){
			currentInsittute=0;
			a =  $('nav').getElement('.' + class_css_prefix + id + ' a'); 
			a.removeClass('hightlight');
			removeNoBg(a);
		}

		if( etat == 'click' ){
			goToURL();
		}
	}
}
