// JavaScript Document
var domain = "http://www.star-colibri.eu/";
var shown ;
$(document).ready(function(){
	 menu();
	 hover();
	 news();
	 tailleColonne();
	 
	 $('#mail').focus(function(){
		$(this).attr('value',"");
	 });
	 $('.fancy').fancybox();
	 footer();
 });

$(window).resize(function(){
		if ($(document).height()>$(window).height()){
		$('#footer').css({position:'relative'});
	}	else{$('#footer').css({position:'absolute'});}			  
});

function menu(){
	$('#menu .selected').parent('li').find('ul.sousTitre').show(200);
	shown = $('#menu .selected').parent('li').find('ul.sousTitre');
	
	
	// ON SORT DU UL MENU
	$('#menu').hover(function(){},function(){
		/*shown.hide();
		alert(shown);*/
		$('#menu .selected').parent('li').find('ul.sousTitre').show();
		shown = $('#menu .selected').parent('li').find('ul.sousTitre');
	});
	
	// AFFICHE LES SOUS MENU
	$('#menu>li').hover(function(){
		if (shown !=$(this).find('.sousTitre')){
			$(this).find('.sousTitre').show();	
			//shown.hide();
			shown=$(this).find('.sousTitre');
			}
	},function(){
		shown.hide();
	});
	
	
	var selected= $('#menu .selected').css('backgroundImage');
	selected=selected.replace("_off", "_on");
	$('#menu .selected').css({backgroundImage:selected});
	$('#menu>li>a').hover(function(){
		if(!$(this).hasClass('selected')){
			var nom = $(this).css('backgroundImage');
			nom=nom.replace("off", "on");
			$(this).css({backgroundImage:nom});
			}						   
	
	} , function (){
		if(!$(this).hasClass('selected')){
		var nom = $(this).css('backgroundImage');
	nom=nom.replace("_on", "_off");
	$(this).css({backgroundImage:nom});
		}
		}
		)};
	
	

	
	
function hover(){
	$(".change").bind("mouseover", function() {
      $(".change").attr("src",domain+"files/Image/usine_on.jpg");
	});
		$(".change").bind("mouseout", function() {
      $(".change").attr("src",domain+"files/Image/usine_off.jpg");
	  });
			$("#progr").bind("mouseover", function() {
      $("#progr").attr("src",domain+"files/Image/programme_on.jpg");
	});
		$("#progr").bind("mouseout", function() {
      $("#progr").attr("src",domain+"files/Image/programme_off.jpg");
	  });

	}
	
	
function footer(){
	
	if ($(document).height()>$(window).height()){
		$('#footer').css({position:'relative'});
	}

}

function tailleColonne(){
	taille = $('#left_col').height();
	if(taille < $('#right_col').height())
	{ 
	 taille = $('#right_col').height();
	 $('#left_col').height(taille);
	 
		}
		else {
			$('#right_col').height(taille);
		}
	}
	
	function news(){
	var height=0;
	var maxheight = 0;
	$('.newsContent').each(function(){
	height = $(this).height();
	if (maxheight < height){
		maxheight = height;
		//alert ($(this).height());
	}
	});
	$('.newsContent').each(function(){
		$(this).height(maxheight);
	});
	}


