
$(document).ready(function(){
    //$('#news_1').addClass('selected');
    $('#news_2').hide();
    $('#news_3').hide();

    $('#actu_menu li').focus(function() {
        var id = $(this).attr('id');
        id++;
        
//        $('#news_' + id).addClass('selected').fadeIn('slow');
        $('#news_' + id).fadeIn('slow');
    });

    $('#actu_menu li').blur(function() {
        var id = $(this).attr('id');
        id++;
//        $('#news_' + id).removeClass('selected').fadeOut('fast');
        $('#news_' + id).fadeOut('fast');
    });

    

    //edition de news
    if($('#js_prev_img').attr('src') == '#')
	$('#js_prev_img').parent('div').hide();
    //bind btn close preview
    $('#btn_prev_close').bind('click', closePrev);
    //affiche la preview
    $('#js_prev_img').width(200);
    $('#upload_img').change(function(){
	show_img_prev();
    });

});

//edition de news
function closePrev()
{
    $(this).parent('div').hide('blind', 'slow');
    $('#upload_img').val('');
    $('#content_admin input[name=keep-img]').val('false');
    return false;
}

function show_img_prev()
{
    $('#content_admin div.img_content').show('blind', 'slow');
    var fileInput = document.getElementById("upload_img");
    var files = fileInput.files;
    var img = document.getElementById("js_prev_img");

    reader = new FileReader();
    reader.onload = function(e)
    {
	img.src = e.target.result;
    }

    reader.readAsDataURL(files[0]);
}

//news footer

$(document).everyTime(8000, function(){

    var next = $('#actualite').children('.focus').next('.content');
    if(next.html() == null)
	next = $('#actualite').children('.content:eq(0)');

    $('#actualite').children('.focus').removeClass('focus').fadeOut(function(){
	next.addClass('focus').fadeIn();
    });
    

});

$(document).ready(function(){

    $('#actualite').children('.content:eq(0)').addClass('focus');

    $('#actualite').children('.content').each(function(){
	if(!$(this).hasClass('focus'))
	    $(this).hide();
    });

});

/*
$(document).ready(function(){
    $('textarea.tinymce').tinymce({
	// Location of TinyMCE script
	script_url : 'libs/tinymce/tiny_mce.js',

	// General options
	theme : "advanced",
	plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

	// Theme options
	//theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	//theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false,

	// Example content CSS (should be your site CSS)
	//content_css : "css/content.css",

	// Drop lists for link/image/media/template dialogs
	template_external_list_url : "lists/template_list.js",
	external_link_list_url : "lists/link_list.js",
	external_image_list_url : "lists/image_list.js",
	media_external_list_url : "lists/media_list.js"

	// Replace values for the template plugin
//	template_replace_values : {
//		username : "Some User",
//		staffid : "991234"
//	}
    });
});
*/
