function displaypost(lepost)
{
	
	var idpost=lepost.id;
	if (currentlyopened.indexOf(idpost)==-1)
		{	
			new Ajax.Updater('openedposts',themeURL+'getpost.php',
					 							{
													postBody: $H({'idpost':idpost}).toQueryString(),
													insertion: Insertion.Bottom,
													onComplete: function(requester){
																						gotop('opened'+idpost);
																						new Draggable('opened'+idpost,{
																									  handle: 'titreopened'+idpost,
																									  starteffect:function(obj){return true;},
																									  endeffect:function(obj){return true;},
																									  });
																						
																					}
												}
							 );
			currentlyopened.push(idpost);
	
		}
		else
			{
				gotop('opened'+idpost);
				//new Effect.Shake('opened'+idpost,{duration:0.1});
				//alert("deja ouvert : "+currentlyopened.join(","));
			}
}


function showthemes()
{
	new Effect.toggle('listethemes','blind',{duration:0.5});
	new Ajax.Updater('listethemes','/wp-content/themes/wahal-revolution/getcat.php');
}

function showfooter ()
{

	new Effect.toggle('infocookies','blind',{duration:0.5});
}


function getpostsbycat(lacat)
{
		new Effect.toggle('listethemes','blind',{duration:0.5});
		var catname=(lacat.className).split(' ')[1];
		var toutecat=lacat.id;
				
		new Ajax.Updater('content','/wp-content/themes/wahal-revolution/getpostslist.php',
					 							{
													postBody: $H({'catname':catname,'toutecat':toutecat}).toQueryString()
												}
						);
		
}

/*POUR ARRANGER LE BORDEL, il faut mettre un delay au onmouseout et au onmousein regarder si y'a pas un effet dans la queue en delay avec Effect.Queue = Effect.Queues.get('listposts');*/
/*la fonctionn recupere un objet Effect.ScopedQueue auquel on peut faire tout ça 
Effect.ScopedQueue.CONSTRUCTOR() ??? ??? ??? - 
Effect.ScopedQueue.effects ??? ??? ??? - 
Effect.ScopedQueue.interval ??? ??? ??? - 
Effect.ScopedQueue._each() ??? ??? ??? - 
Effect.ScopedQueue.add() ??? ??? ??? - 
Effect.ScopedQueue.remove() ??? ??? ??? - 
Effect.ScopedQueue.loop() 
*/

function previewin(bloc)
{
	if ($(bloc.id).match('div.post'))
	{	//alert("coucou"); 
		var lapreview = bloc.next();
		new Effect.BlindDown(lapreview,{duration:0.1,queue:{scope:'listposts',position:'end',limit:3}});
	}
	else
		if ($(bloc.id).match('div.preview'))
			{
				
			}
			else
				{}
		
}

function previewout(bloc)
{
		if ($(bloc.id).match('div.post'))
	{			   
		var lapreview = bloc.next();
		new Effect.BlindUp(lapreview,{duration:0.1,queue:{scope:'listposts',position:'end',limit:3}});
	}
	else
		if ($(bloc.id).match('div.preview'))
			{
				
			}
			else
				{}
	
}

function removepost(lepost)
{
	currentlyopened = currentlyopened.without(lepost.slice(6));
	$(lepost).remove();
}

function gotop(idopenpost)
{
	$(idopenpost).style.zIndex=zindexmax;
	zindexmax++;
}
/******************************************************************************************************************************/

/*FONCTIONS DE COOKIES JAVASCRIPT*/
function EcrireCookie(nom, valeur)
{
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}


function EffaceCookie(nom)
{
date=new Date;
date.setFullYear(date.getFullYear()-1);
EcrireCookie(nom,null,date);
}

/*FIN DES COOKIES*/


/******************************************************************************************************/




var themeURL = 'http://www.wearehereatlast.com/wp-content/themes/wahal-revolution/';

var currentlyopened = new Array ();
var zindexmax=10;

function lafonctiondudebut()
{
	EffaceCookie('readposts');
}


Event.observe(window, 'load', lafonctiondudebut);