$(document).ready(function() {

	$('.menu_rubric').click(function () {

		var object = $(this).find('.menu_list');
		var time_open = 500;
		var time_close = 300;

		if (object.is(':hidden'))
			object.animate({opacity: 0}, 0);

		if (!object.is(':hidden'))
			object.animate({height: 'hide', opacity: 0}, time_close);
		else {
			$('.menu_rubric').find('.menu_list').animate({height: 'hide', opacity: 0}, time_close);
			object.animate({height: 'show', opacity: 1}, time_open);}
	});


	$('.titre_releases').click(function () {

		var object = $(this).next('.detail_releases');
		var time_open = 800;
		var time_close = 500;

		if (!object.is(':hidden'))
			object.animate({height: 'hide', opacity: 0}, time_close);
		else
			object.animate({height: 'show', opacity: 1}, time_open);
	});


	$('.surligne_table')
			.mouseenter(function () {
				$(this).css('background-color','#EEEEEE');})
			.mouseleave(function () {
				$(this).css('background-color','#FFFFFF');});


	$('.home_link')
			.mouseenter(function() {
				var time_open = 300;
				var time_close = 200;
				if ($(this).find('.popup_releases').is(':hidden')) {
					$('.home_link').find('.popup_releases').animate({width: 'hide'}, time_close);
					$(this).find('.popup_releases').animate({width: 'show'}, time_open); }})
			.mouseleave(function() {
				var time_close = 200;
				$('.home_link').find('.popup_releases').animate({width: 'hide'}, time_close); })
			.find('.popup_releases');

});


function slide_releases (num_releases) {
	$(document).ready(function () {
		var releases = 'releases_'+num_releases;
		var object = $('#'+releases).find('.detail_releases');
		var time_open = 0;
		window.location = '#'+releases;
		object.animate({height: 'show', opacity: 1}, time_open);

	});
}


function add_string (textarea, string) {
	if (document.getElementById(textarea).createTextRange && document.getElementById(textarea).caretPos) { 
		var caretPos = document.getElementById(textarea).caretPos; 
		selectedtext = caretPos.text; 
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? string + '' : string; 
		caretPos.text = caretPos.text + selectedtext;
	} else if (document.getElementById(textarea).textLength > 0) {
		Deb = document.getElementById(textarea).value.substring( 0 , document.getElementById(textarea).selectionStart );
		Fin = document.getElementById(textarea).value.substring( document.getElementById(textarea).selectionEnd , document.getElementById(textarea).textLength );
		document.getElementById(textarea).value = Deb + string + Fin;
	} else {
		document.getElementById(textarea).value = document.getElementById(textarea).value + string; }
		document.getElementById(textarea).focus(); 
}


function popup (lien) {
	window.open(lien.href, '', 'width='+screen.width+', height='+screen.height+', top=0, left=0, location=yes, resizable=yes, fullscreen=yes, scrollbars=yes, toolbar=no, menubar=no, status=no');
}
