function HTMLGraphicContent(fichier,width,height)
{
	width = (width)?width:700 ;
	height = (height)?height:550 ;
  
  if(!fichier) return false ;
  var fictmp = fichier.split('.') ;
  var ext = fictmp[fictmp.length-1] ; 
  
  if(ext == 'swf') return displayFlashObject(fichier,width,height) ;
  else if(ext == 'flv') return GetVideoPlayer(fichier,width,height) ;
  
  return false ;
}

function GetVideoPlayer(fichier,width,height)
{
  var html='';
	var flashvars='';
	width = (width)?width:700 ;
	height = (height)?height:550 ;
	flashvars+='flv='+fichier;
  /*flashvars+='&amp;startimage='+Videos[0].image ;*/
	flashvars+='&amp;width='+width ;
	flashvars+='&amp;height='+height ;
	flashvars+='&amp;showstop=1' ;
	flashvars+='&amp;showiconplay=1' ;
	flashvars+='&amp;showvolume=1' ;
	flashvars+='&amp;buffermessage=Chargement _n_' ;
	flashvars+='&amp;playeralpha=50' ;
	flashvars+='&amp;buttonovercolor=686868' ;
	flashvars+='&amp;sliderovercolor=FFFFFF' ;
	flashvars+='&amp;buttoncolor=ffffff' ;
	flashvars+='&amp;skin=' ;
	flashvars+='&amp;margin=0' ;
	flashvars+='&amp;ondoubleclick=fullscreen' ;
	
	
	html+='<object id="VideoPlayer" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" type="application/x-shockwave-flash" data="/flash/player_flv_maxi.swf" width="'+width+'" height="'+height+'">\n' ;
	html+='<param name="movie" value="/flash/player_flv_maxi.swf" />\n' ;
	html+='<param name="FlashVars" value="'+flashvars+'" />\n' ;
	html+='<param name="allowFullScreen" value="true" />' ;
	html+='<embed name="VideoPlayer" src="/flash/player_flv_maxi.swf"	quality="high" width="'+width+'" height="'+height+'" name="video_0" align="middle" allowScriptAccess="sameDomain"	allowFullScreen="true"	type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="'+flashvars+'"/>\n';
	html+='</embed>\n';
  	html+='</object>\n' ;
	
	return html ;	
}

function displayFlashObject(fichier,width,height)
{
  	var d = new Date() ;
    var id = d.getFullYear()+''+d.getMonth()+''+d.getDate() ;
    
    var html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' ;
		html +=' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"' ;
		html +=' width="'+width+'" height="'+height+'"	id="'+id+'">' ;
		html +=' <param name="allowScriptAccess" value="sameDomain" />' ;
		html +=' <param name="allowFullScreen" value="true" />' ;
		html +=' <param name="movie" value="'+fichier+'" />' ;
		html +=' <param name="quality" value="high" />' ;
		html +=' <embed src="'+fichier+'" quality="high" width="'+width+'"	height="'+height+'"	name=\$id"' ;
		html +=' allowScriptAccess="sameDomain" allowFullScreen="true"	type="application/x-shockwave-flash"' ;
		html +=' pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>' ;
		html +=' </object>' ;
		
		return html ;
}

function getFlashObject(movieName) {
     if (window.document[movieName]) {
         return window.document[movieName];
     }
     if (navigator.appName.indexOf("Microsoft Internet") == -1) {
         if (document.embeds && document.embeds[movieName])
             return document.embeds[movieName];
     } else {
         return document.getElementById(movieName);
     }
}

function send_request(url, queryString, method, callback)
{
  $.ajax({
    type: method,
    url: url,
    data: queryString,
    success: callback
    }
  );
}

function init_news()
{
  /* num‚rotation des items */
  var cpt = 1 ;
  var imgs = '' ;
  var IMG_ON = new Array() ;
  
  var duree = 6000 ;/* 6sec */

  /* initialisation de l'affichage */
  $('.news').css('position','relative') ;
  $('.news h2').after('<div id="news-overlay">&nbsp;</div>') ;
  $('#news-overlay').height($('.news').height()) ;
  $('#news-overlay').width($('.news').width()) ; 
  
  $('.news .nitem').each(function()
  {
    $(this).attr('id','n-'+cpt) ;
    $(this).hide() ;
    imgs += '<img id="nimg-'+cpt+'" src="/images/item-'+cpt+'.gif" alt="" />' ;
    /* preload */
    IMG_ON[cpt]     = new Image() ;
		IMG_ON[cpt].src = '<img src="/images/itemOn-'+cpt+'.gif" alt="" />' ;
    cpt++ ;
  }) ;
  $('.news h2').prepend('<div class="nlinks">'+imgs+'<div>') ;
  item_show(1) ;
  
  var nbItem = parseInt($('.nitem').length) ;
  if(nbItem >= 2)
  {
    var t = set_new_timer(duree) ;
    /* evenement sur le clic de souris */
    $('.news .nlinks img').click(function(){
      var num = $(this).attr('id').split('-')[1] ;
      var oldnum = $('.news .nitem:visible').attr('id').split('-')[1] ;
      item_hide(oldnum)
      item_show(num) ;
      
      clearInterval(t) ;
      t = set_new_timer(duree) ;
    } ) ;
  }
}

function set_new_timer(duree)
{
  return window.setInterval(toggle_news,duree) ;
}

function hide(elt)
{
  elt.css('display','none') ;
}

function show(elt)
{
  $('#news-overlay').css('display','block') ;
  elt.css('display','block') ;
  $('#news-overlay').fadeOut('normal') ;
}

/** Afficher l'item num **/
function item_show(num)
{
  $('#nimg-'+num).attr('src','/images/itemOn-'+num+'.gif') ;
  /*$('#n-'+num).fadeIn('normal') ;*/
  show($('#n-'+num)) ;
}

/** Masque l'item num **/
function item_hide(num)
{
  $('#nimg-'+num).attr('src','/images/item-'+num+'.gif') ;
  /*$('#n-'+num).hide() ;*/
  hide($('#n-'+num)) ;
}

/** Passe d'un item au suivant **/
function toggle_news()
{
  var item = $('.news .nitem:visible') ;
  var nitem = $('.news .nitem:visible').next('.nitem') ;
  
  if( nitem.attr('class') == undefined )
  {
    var nitem = $('.news .nitem:first') ;
  }
  toggle(item, nitem) ;
}

/** Passe de l'item old_elt … l'item new_elt **/
function toggle(old_elt,new_elt)
{
  var oldn = old_elt.attr('id').split('-')[1] ;
  var newn = new_elt.attr('id').split('-')[1] ;
  
  $('.news #nimg-'+oldn).attr('src','/images/item-'+oldn+'.gif') ;
  /*old_elt.hide() ;*/
  hide(old_elt) ;
  /*new_elt.fadeIn('normal') ;*/
  show(new_elt) ;
  $('.news #nimg-'+newn).attr('src','/images/itemOn-'+newn+'.gif') ;
}

function init_srch()
{
  var default_txt = 'Rechercher' ;
  $('#srchform input[name=keyword]').focus(function()
  {
    if( $(this).val()==default_txt ) $(this).val('') ; 
  }) ;
  
  $('#srchform input[name=keyword]').blur(function()
  {
    if( $(this).val()=='' ) $(this).val(default_txt) ; 
  }) ;
}

$(function()
{
  init_srch() ;
}) ;