$(function ()
{
	// PLUGIN STRIPHTML
	$.fn.stripHtml = function() 
	{  
		var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;  
		this.each(function() 
		{  
			$(this).html
			(  
	    		$(this).html().replace(regexp,'')
	    	);  
		});  
		return $(this);  
	};

	// AJAX SETUP
	$.ajaxSetup
	({
		'beforeSend' : function(xhr) 
		{
			if (xhr.overrideMimeType!=undefined)
			{
				//xhr.overrideMimeType('text/html; charset=ISO-8859-1');
				xhr.overrideMimeType('text/html; charset=UTF-8');
			}
		}
	});


	// DEBUT DES DEFINITIONS SPECIFIQUES A FD
	if ($('#dd-demo-1').attr("class").indexOf('recact')!=-1)
	{
		$('#RechercheAvancee').css('height','350px');
		$('#RechercheAvancee').css('width','749px');
		if ($.cookies.get( 'fdsearch_top'))
		{
			var mytop = $.cookies.get( 'fdsearch_top');
		
			$('#dd-demo-1').css('top',mytop);
		}
		if ($.cookies.get( 'fdsearch_left'))
		{
			var myleft = $.cookies.get( 'fdsearch_left');
			$('#dd-demo-1').css('left',myleft);
		}
		$("#dd-demo-1").fadeIn("slow");
		//$('#dd-demo-1').draggable({handle:'#EnteteRecherche'});
		$('#dd-demo-1').draggable();
	}
	
	// LienRecherche : ouverture de la recherche complexe et recuperation de l'emplacement
	$('.LienRecherche').click(function () 
	{
		grossir('RechercheAvancee','749px','350px');
		// a remettre
		if ($.cookies.get( 'fdsearch_top'))
		{
			var mytop = $.cookies.get( 'fdsearch_top');
			//alert('top' + mytop);
			$('#dd-demo-1').css('top',mytop);
		}
		if ($.cookies.get( 'fdsearch_left'))
		{
			var myleft = $.cookies.get( 'fdsearch_left');
			//alert('left' + myleft);
			$('#dd-demo-1').css('left',myleft);
		}
		$("#dd-demo-1").fadeIn("slow");//showDiv('dd-demo-1');showDiv('EnteteRecherche');showDiv('RechercheAvancee');
		//$('#dd-demo-1').draggable({handle:'#EnteteRecherche'});
		$('#dd-demo-1').draggable();
	});

	// Evenement d'arret de drag de la fenetre de recherche, ecriture des cookies
	$('#dd-demo-1').bind('dragstop', function(event, ui) 
	{
		/*alert(ui.position.left); 
		alert(ui.position.top);
		alert(ui.offset.left);
		alert(ui.offset.top);
		*/
		$.cookies.set( 'fdsearch_left',ui.position.left,{expiresAt: new Date( 2011, 1, 1 )});
		$.cookies.set( 'fdsearch_top',ui.position.top,{expiresAt: new Date( 2011, 1, 1 )});
	});				
			
			
			
	$('#fermetureRecherche').bind('click',function ()
	{
		grossir('RechercheAvancee','10px','10px');
		$('#dd-demo-1').fadeOut('slow');
	});
			
			
			
			
			
			
			
			
			
			
			
					
					
	$('#newwindow').unbind().click(function ()
	{
		myWindow=window.open('','Froggys_Delight_Player','width=300,height=320,menubar=no,status=no,resizable=no');
		//alert($('div#div_playlist').html());
		$('div#div_playlist').find("script").remove();
		//alert($('div#div_playlist').html());
		myWindow.document.write($('div#div_playlist').html()); 
$('div#div_playlist').remove();
$('#newwindow').html('Fenêtre externe ouverte');
$('#newwindow').removeAttr('href');
$('#newwindow').unbind("click");
	}
);




$('#voir_sess').click(function ()
			{
				if ($('#divvoir_sess').css("display")=='none')
				{
					//$('#divvoir_sess').css("display","block");
					$('#divvoir_sess').slideDown(2000);
					$('#voir_sess').innerHTML="Cacher les sessions précédentes";
				}
				else
				{
					$('#divvoir_sess').slideUp(2000);
					//$('#divvoir_sess').css("display","none");
					$('#voir_sess').innerHTML="Voir les sessions précédentes";
				}
			});
$('#voir_sess_rad').click(function ()
			{
				if ($('#divvoir_sess_rad').css("display")=='none')
				{
					//$('#divvoir_sess').css("display","block");
					$('#divvoir_sess_rad').slideDown(2000);
					$('#voir_sess_rad').innerHTML="Cacher les émissions précédentes";
				}
				else
				{
					$('#divvoir_sess_rad').slideUp(2000);
					//$('#divvoir_sess').css("display","none");
					$('#voir_sess_rad').innerHTML="Voir les émissions précédentes";
				}
			});		
/*
$('#article_titre1').click(function () 
							{ 
								//$('#ml').effect("shake", { times:10 , direction:'up', distance:10 }, 50);
								$('#ml').effect("clip", { direction: "horizontal",mode:"hide" }, 3000);
								$('#ml').effect("clip", { direction: "horizontal",mode:"show" }, 3000);
								

							}
						);
*/




	
	// Un span sur le gras desactivé pour l'instant	
/*
$('span.GRAS').each(function () 
	{ 
		$(this).attr('title',$(this).html()+' : cliquez pour en savoir plus (peut être)');
		$(this).addClass('GRASHELP');
	}
);
$('span.GRAS').bind("click",function () 
	{ 
		//alert('pp'+$(this).html());
		//$(this).replaceWith('<a class="lien01" href="froggydelight.php?valeur_search='+$(this).html()+'&type_search=rapide&express=1&mode=search">'+$(this).html()+'</a>');
		
		//$(this).removeClass('vtip'); marche pas
		
		
		
		
		$.ajaxSetup
	({
		'beforeSend' : function(xhr) 
		{
			if (xhr.overrideMimeType!=undefined)
			{
				xhr.overrideMimeType('text/html; charset=UTF-8');
			}
		}
	});
		if ($(this).find('div.expr').size()==0)
	{
			
		var chemin=$(this).html();
		var regExp = /^article-([0-9]+)-.*$/i;  
		// Faudra mettre dev/ dans la ligne d'en dessous
		chemin='modules/ajax.php?ajaxformat=search&ajaxparam='+chemin.replace(regExp,'$1');
		//alert(chemin);
		var mondessin = $(this);
		
		//alert($("#article_corps").attr('innerHTML'));
		var xhr=$.get(chemin, function(data) {
			//alert('ok');
			var table = $(data);
			//alert($(data).html());
			
			

			// a verifier
			
			if (table.html()!="")
			{
			
				//alert(table.find('a').size()); 
				table.find('a').attr('class','lien01gc');
				var aajouter='<div class="completeright">Fermer la fenêtre</div><br />'+table.html();
				$(mondessin).append('<div class="expr complete_gras">'+aajouter+'</div>');
				$(mondessin).find("div.expr").draggable();
			}
			//if ($(table).text().substring(0,320)=='')
			//{
//				$(mondessin).find("div.expr").remove();
	//		}
		//	else
			//{
			//$(mondessin).find("div.expr").append($(table).text().substring(0,320));
			//$(mondessin).find("div.expr").append(' ... (cliquez pour lire la suite)');
			//$(mondessin).find("div.expr").effect("shake", { times:2 , distance:5, direction:'up'}, 50)
			//}
		},"html");
		
		
		
		
		
		
		
		
		
		
	}
	else
		{
			$(this).find("div.expr").remove();
		}
		
		
		
		
		
		
		
	}
);

*/
	
						
$('div.d_lireaussi').mouseenter(function ()
	{ 
		var chemin=$(this).find("a").attr('href')+ '';
		var regExp = /^article-([0-9]+)-.*$/i;  
		// Faudra mettre dev/ dans la ligne d'en dessous
		chemin='modules/ajax.php?ajaxformat=apercu&ajaxparam='+chemin.replace(regExp,'$1');
		if ($(this).find(".expr").size()>0)
		{
		}
		else
		{
			//alert($(this).find("a").size());
			var mondessin = $(this).find("a");
			//alert($("#article_corps").attr('innerHTML'));
			var xhr=$.get(chemin, function(data) 
			{
				//alert('ok');
				var table = $(data);
				//alert($(table).text());
				var myimg=$(table).find('img:first').attr('src');
				//console.log(myimg);
				$(mondessin).append('<div class="expr" style="color:#fff"></div>');
			
				//$('#expr').effect("shake", { times:3 , direction:'up', distance:10 }, 50).append('<img width=150 src="'+myimg+'"></img>');
				//alert("a"+myimg+"a");
				if (myimg!=undefined)
				{
					$(mondessin).find("div.expr").append('<img class="photogauche" align="left" border="0" width=100 src="'+myimg+'"></img>');
				}
				//$('#expr').effect("shake", { times:3 , direction:'up', distance:10 }, 50).append($(table).text().substring(0,320));
				if ($(table).text().substring(0,320)=='')
				{
					//alert('vide comme un oeuf');
					$(mondessin).find("div.expr").remove();
				}
				else
				{
					$(mondessin).find("div.expr").append($(table).text().substring(0,320));
					$(mondessin).find("div.expr").append(' ... (cliquez pour lire la suite)');
					//$(mondessin).find("div.expr").effect("shake", { times:2 , distance:5, direction:'up'}, 50)
					$(mondessin).find("div.expr").slideDown("slow");
					//$(mondessin).find("div.expr").fadeIn("slow");
				}
			},"html");
		}
		$('div.d_lireaussi').mouseleave(function ()
		{
			//alert("zizi");
			if (xhr!=undefined)
			{
				//alert('abort');
				xhr.abort();
				if ($(this).find("a").find("div.expr").html()=='')
				{
					$(this).find("a").find("div.expr").remove();
				}
			}
		}
		);
	}
	);
















if (Math.random()>0.9)
{
	$('div.d_lireaussi:first').append('<p id="vtip"><img id="vtipArrow" />Découvrez les autres articles en passant la souris sur les aperçus</p>');
	$('p#vtip #vtipArrow').attr("src", 'gfx/vtip_arrow.png');
	var p=$('div.d_lireaussi:first').position();
	$('p#vtip').css("top", p.top-10+"px").css("left", p.left+40+"px").fadeIn(2000).fadeOut(10000);
 }           













// Toute fin
}
);
	
	
	








































var imageclick="";
var imagefic="";
function flipImage(nomimg,url){
if (nomimg != imageclick)
	document[nomimg].src= url;
}
function flipImageClick(nomimg,url){ 
document[nomimg].src= url;
}
function fixImage(nomimg,url,url1){
if (imageclick !=""){
	//restore previous image clicked
	document[imageclick].src = imagefic
}
imageclick = nomimg;
imagefic = url1;
flipImageClick(nomimg,url);
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function fnAutoComplete(valeur,viewed,xx,xx2,path)
{
	var vv = $("#"+viewed);
	if (valeur.length>3)
	{
		var chemin=path+"ajax.php?ajaxformat=search&ajaxparam="+valeur;
		
		var xhr=$.get(chemin, function(data) 
		{
				var table = $(data);
				
				if (table.text()=='')
				{
					vv.empty().slideUp("slow");
				}
				else
				{
					vv.empty();
					table.find('a').attr('class','lien01gc');
					vv.append('<div class="completeright"><a href="javascript:;" class="lien01g" onClick="hideDiv (\''+viewed+'\');">Fermer la fenêtre</a></div><br />').append(table);
					vv.slideDown("slow");
				}
				///document.getElementById(viewed).style.display="block";
				//alert($(table).text());
				/*var myimg=$(table).find('img:first').attr('src');
				//console.log(myimg);
				$(mondessin).append('<div class="expr" style="color:#fff"></div>');
			
				//$('#expr').effect("shake", { times:3 , direction:'up', distance:10 }, 50).append('<img width=150 src="'+myimg+'"></img>');
				//alert("a"+myimg+"a");
				if (myimg!=undefined)
				{
					$(mondessin).find("div.expr").append('<img class="photogauche" align="left" border="0" width=100 src="'+myimg+'"></img>');
				}
				//$('#expr').effect("shake", { times:3 , direction:'up', distance:10 }, 50).append($(table).text().substring(0,320));
				if ($(table).text().substring(0,320)=='')
				{
					//alert('vide comme un oeuf');
					$(mondessin).find("div.expr").remove();
				}
				else
				{
					$(mondessin).find("div.expr").append($(table).text().substring(0,320));
					$(mondessin).find("div.expr").append(' ... (cliquez pour lire la suite)');
					//$(mondessin).find("div.expr").effect("shake", { times:2 , distance:5, direction:'up'}, 50)
					$(mondessin).find("div.expr").slideDown("slow");
					//$(mondessin).find("div.expr").fadeIn("slow");
					
				}
				*/
		},"html");
	}
	else
	{
			vv.slideUp("slow");
	}	
}

function showDiv(divid)
{
if (document.layers) document.layers[divid].visibility="show";
else document.getElementById(divid).style.visibility="visible";
}

function hideDiv(divid)
{
if (document.layers) document.layers[divid].visibility="hide";
else document.getElementById(divid).style.visibility="hidden";
}

function grossir(divid,width,height)
{
	
	document.getElementById(divid).style.width=width;
	document.getElementById(divid).style.height=height;
}	
