/*
 * File Name : gallery.js
 * Created by Softage
 * http://www.softage.be
 */ 

var gallery_logged=false;
var gallery_currentId;
var picture_currentId;

function init_app_gallery()
{
	gallery_isLogged();
	var strForm="<table align='center' ><tr><td colspan='2'><div id='div_thumbs' style='left:0px'> "
		+ "    <div id='contenu' style='position:absolute; left:5px'>"
		+ "    </div>"
		+ "    <div id='scroll'> <img onmouseover=\"moveLayer(1);\" onmouseout='clearTimeout(Timer);' src='images/fleche_" + site_section + "_gauche.gif' style='cursor:pointer; position:relative; left:0; border:none;' alt='' /> "
		+ "     <img onmouseover=\"moveLayer(-1);\" onmouseout='clearTimeout(Timer);' src='images/fleche_" + site_section + "_droite.gif' style='cursor:pointer; position:absolute; right:0; border:none;' alt='' />"	
		+ "    </div> "
		+ " </div></td></tr>"
		+ "<tr><td class='td_bigPic' id='div_focus_container'><div id='div_focus' name='div_focus' class='div_focus'  >"
		+ "</div></td>"
		+ "<td><div id='div_gallery_list' class='galleryMenu'></div></td></tr>" 
		+ "<tr><td ><div id='picture_td_commentaire' class='div_commentPic'></div></td><td></td></tr></table>";

	$('main').innerHTML=strForm;
	//new Draggable('div_gallery_list',{revert:false});
	getGalleryList();

}
function isolatePic()
{
	var contentWin = new Window({maximizable: false, resizable: false, hideEffect:Element.hide, showEffect:Element.show, maxWidth:480, destroyOnClose: true});			
	contentWin.setContent('div_focus', true, true);
	contentWin.show();
	// Set up a windows observer, check ou debug window to get messages
	myObserver = { onDestroy: function(eventName, win) 
							{ 
								if (win == contentWin) { 
										if($('div_focus_container'))$('div_focus_container').appendChild($('div_focus')); 
										contentWin = null; 
										Windows.removeObserver(this); 
								}  
				 			} 
				} 
	Windows.addObserver(myObserver); 
}
//-------------------Test Admin ----------------------------------------
function gallery_isLogged()
{
		var url = 'bridge/bridge_user.php';
		var pars = 'action=isLogged';
		var myAjax = new Ajax.Request( url, { method: 'post',asynchronous:false, parameters: pars, onComplete: gallery_isLogged_resp });
}
	
function gallery_isLogged_resp(originalRequest)
{
	var test=false;
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Success"){
		gallery_logged=true;	
	}
	else {
		$('admin_logout').innerHTML="";	
		gallery_logged=false;
	}
	return test;
	
}

//---------------------Scroll---------------------------------------

var Timer;
var Pas = 10;
function moveLayer(Sens) {
	
    Objet=document.getElementById("contenu");

   if(parseInt(Objet.style.left) + (Pas*Sens)>5)  {
		clearTimeout(Timer);
		   // win2(parseInt(Objet.style.left));
    }
    else if(parseInt(Objet.style.left) + (Pas*Sens)<-(Objet.offsetWidth-document.getElementById("div_thumbs").offsetWidth)) {
		clearTimeout(Timer);
		
    }
    else {

        Objet.style.left = (parseInt(Objet.style.left) + (Pas*Sens)) + "px";
    }
	Timer = setTimeout("moveLayer(" + Sens + ");", 30);
}

//----------------------------Appel Ajax liste des galleries-----------------------------
function getGalleryList()
	{
		var url = 'bridge/bridge_gallery.php';
		var pars = 'action=getAll';
		initTest=false;
		var myAjax = new Ajax.Request( url, { asynchronous:true, method: 'post', parameters: pars, onComplete: respGetGalleryList });

	}

function respGetGalleryList(originalRequest)
{
			var strList="";
			var response =JSON.parse(originalRequest.responseText);
			if (response.Type=="Data")
			{
				strList+=" <table border='0' cellpadding='5px' cellspacing='0' id='gallery_menu_div' width='100%' style='align-left:0px'> ";
				strList+="<tr class='cellheader'><td  height='10px'  class='cellheader'>&nbsp;</td><td  height='10px'  class='cellheader' ><center><font class='stdTitle'><b>Galleries</b></font>";
				if (gallery_logged==true)  strList+="&nbsp;<img src='images/add2.png' style='cursor:pointer' onClick=\"gallery_edit('INSERT')\";>";
				strList+="</center></td><td class='cellheader'>&nbsp;</td></tr>";
				
				//alert(response.Value[0].id)
				for (var i=0;i<response.Size;i++) 
				{
					strList+="<tr id='gallery_entry_" + response.Value[i].id + "'><td  colspan='3'><font class='gallery_normal' style='cursor:pointer' onClick=\"document.getElementById('contenu').style.left='0px';getPicThumb('" + response.Value[i].id + "');\" id='gallery_title_value_" + response.Value[i].id + "' ><b>" + response.Value[i].title + "</b></font>";
					if (gallery_logged==true)  strList+="&nbsp;<img src='images/edit.gif' style='cursor:pointer;width:14px;height:12px' onClick=\"gallery_edit('UPDATE',"+ response.Value[i].id + ")\"/><img src='images/delete16.png' style='cursor:pointer;width:16px;height:16px' onClick='gallery_remove(" + response.Value[i].id + ")' >";
					
				}
				strList+="</td></tr></table> ";
				$('div_gallery_list').innerHTML=strList;
				getPicThumb(response.Value[0].id);
			}
			else 
			{
						strList+=" <table border='0' cellpadding='5px' cellspacing='0' id='gallery_menu_div' width='100%' style='align-left:0px'> ";
				strList+="<tr class='cellheader'><td  height='10px'  class='cellheader'>&nbsp;</td><td  height='10px'  class='cellheader' ><center><font class='stdTitle'><b>Galleries</b></font>";
				if (gallery_logged==true)  strList+="&nbsp;<img src='images/add2.png' style='cursor:pointer' onClick=\"gallery_edit('INSERT')\";>";
				strList+="</center></td><td class='cellheader'>&nbsp;</td></tr>";
				strList+="<tr ><td  colspan='3'><font class=stdText><b><center>Aucune entr&eacute;e</center></b></font>";
				strList+="</td></tr></table> ";
				$('div_gallery_list').innerHTML=strList;

			}
}

//----------------------------Appel Ajax miniatures-----------------------------

var myTimer;
var initTest=false;

function getPicThumb(gallery)
	{
		if ($('gallery_title_value_' + gallery_currentId)) $('gallery_title_value_' + gallery_currentId).className='gallery_normal';
		gallery_currentId=gallery;
		$('gallery_title_value_' + gallery_currentId).className='gallery_selected';
		var url = 'bridge/bridge_picture.php';
		var pars = 'action=getAllFromGallery&gallery=' + gallery;
		initTest=false;
		var myAjax = new Ajax.Request( url, { asynchronous:true, method: 'post',parameters: pars, onComplete: respGetPicThumb });
	}

function respGetPicThumb(originalRequest)
{
	if (!initTest){
		var response =JSON.parse(originalRequest.responseText);
		if (response.Type=="Data")
		{
			var strThumbs="";	
			var response =JSON.parse(originalRequest.responseText);
			var tab=response.Value;
			var tabSize=tab.length;
			var i;
			strThumbs+=" <table id='t1' bgcolor='#000' border='0' cellpadding='0' cellspacing='6'> "
				 + "<tr id='tr_thumbs'>";
			if(gallery_logged==true)strThumbs+="<td><img src='images/addPic.gif' onClick=\"picture_insert();\" class='opacityimg' /></td> ";
			for (i=0;i<tabSize;i++){
				if  (tab[i].type=="IMAGE"){
					
					var extLen=tab[i].url.length-tab[i].url.indexOf('.',0)-1;	
					var fileExtension=tab[i].url.substr(tab[i].url.length-extLen,extLen);
					var fileName=tab[i].url.substring(0,tab[i].url.length-(extLen+1));
	
					strThumbs+="<td id='td_img_"+ tab[i].id +"'><img id='img_"+ tab[i].id +"' src='userfiles/galleries/"+ gallery_currentId +"/" + fileName 
							+ "_thumb."+ fileExtension + "' alt='' onClick='picture_getMedium(" + tab[i].id  + ")' class='opacityimg' /></td> ";
				}
				else {
				strThumbs+="<td><img id='img_"+ tab[i].id +"' src='http://img.youtube.com/vi/" + tab[i].url + "/default.jpg' alt='' onClick='picture_getMedium(" + tab[i].id  + ")' height='80px'  class='opacityimg' /></td> ";	
				}
				if(i==0)picture_getMedium(tab[i].id );
			}
			strThumbs+="</tr></table> ";
			document.getElementById('contenu').innerHTML=strThumbs;
			initTest=true;
		}
		else if ((response.Type=="Info") && (gallery_logged==true))
		{
			var strThumbs="";
			strThumbs+=" <table id='t1' border='0' cellpadding='0' cellspacing='6'> "
				 + "<tr id='tr_thumbs'>";
			strThumbs+="<td><img src='images/addPic.gif' onClick=\"picture_insert();\" class='opacityimg' /></td> ";
			strThumbs+="</tr></table> ";
			document.getElementById('contenu').innerHTML=strThumbs;
		}
		else	
		{
			var strThumbs="";
			strThumbs+=" <table id='t1' border='0' cellpadding='0' cellspacing='6'> "
				 + "<tr id='tr_thumbs'>";
			strThumbs+="<td><img src='images/noPic.gif' class='opacityimg' /></td> ";
			strThumbs+="</tr></table> ";
			document.getElementById('contenu').innerHTML=strThumbs;
			$('picture_td_commentaire').innerHTML = "";
			$('div_focus').innerHTML="";
		}
		
	}
	
	
}

/*------------------------------------------------------------------------
/----------------------- Gallery ajax functions --------------------------
------------------------------------------------------------------------*/

function gallery_edit(mode,id)
{
	
	var form_gallery="";
	form_gallery+= "<br><table width=100%' height='70%'>"
				+ "<tr width='100%' valign='top'>"
				+ "<td align='center'>Titre</td><td align='center'><input type='hidden' id='gallery_edit_id'/><input type='text' id='gallery_edit_title' style='width:70%;'/></td>"
				+ "</tr><tr height='50px'><td>&nbsp;</td></tr>"
				+ "<tr width='100%' valign='center'><td ><center><input type='button' value='Envoyer'"; 					
				if (mode=="UPDATE") form_gallery+= " onClick='gallery_update()'";
				else if (mode=="INSERT") form_gallery+= " onClick='gallery_insert()'";
				form_gallery+= "/></center></td><td ><center><input type='button' value='Annuler' onclick='Windows.closeAll()'/></center></td></tr>"
				+ "</table>";
	Dialog.info(form_gallery,{className: "darkX",  width: 320, height: 150,showProgress: false});
	if (mode=="UPDATE")gallery_getOne(id);

}

function gallery_getOne(id)
{
		gallery_currentId=id;
		var url = 'bridge/bridge_gallery.php';
		var pars = 'action=getOne&id=' + id;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: gallery_getOne_resp });
}
	
function gallery_getOne_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Object"){
		ob=response.Value;
		$('gallery_edit_title').value=ob['Title'];
		$('gallery_edit_id').value=ob['Id'];
	}
	else win2("Une erreur s'est produite");
	
}


function gallery_update()
{
		var id=$('gallery_edit_id').value;
		var title=encodeURI($('gallery_edit_title').value);
		var url = 'bridge/bridge_gallery.php';
		var pars = 'action=update&id=' + id + '&title=' + title;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: gallery_update_resp });
}
	
function gallery_update_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Success"){
		$('gallery_title_value_' + gallery_currentId).innerHTML="<b>" + $('gallery_edit_title').value; + "</b>";
		Windows.closeAll();
	}
	else win2("Une erreur s'est produite");
	
}

function gallery_insert()
{
		var title=encodeURI($('gallery_edit_title').value);
		var url = 'bridge/bridge_gallery.php';
		var pars = 'action=insert&title=' + title;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: gallery_insert_resp });
}
	
function gallery_insert_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Object"){
		ob=response.Value;
		var htmlTxt="";
		htmlTxt+="<tr id='gallery_entry_" + ob.Id + "'><td  colspan='3'><font class='gallery_normal' style='cursor:pointer' onClick=\"document.getElementById('contenu').style.left='0px';getPicThumb('" + ob.Id + "');\" id='gallery_title_value_" + ob.Id + "' ><b>" + ob.Title + "</b></font>";
					if (gallery_logged==true)  htmlTxt+="&nbsp;<img src='images/edit.gif' style='cursor:pointer;width:14px;height:12px' onClick=\"gallery_edit('UPDATE',"+ ob.Id + ")\"/><img src='images/delete16.png' style='cursor:pointer;width:16px;height:16px' onClick='gallery_remove(" + ob.Id + ")' >";
		htmlTxt+="</td></tr>";
		
		new Insertion.Bottom('gallery_menu_div', htmlTxt);	
		Windows.closeAll();
	}
	else win2("Une erreur s'est produite");
	
}


function gallery_remove(id)
{
	Dialog.confirm("Voulez vous vraiment effacer cette entr&eacute;e ?", 
               {width:300, height:75, okLabel: "Oui", 
		className:"darkX",
               buttonClass: "myButtonClass",
               id: "dialogYesCancel",
               cancel:function(win){debug("cancel confirm panel")},
               ok:function(){	
			gallery_currentId=id;
			var url = 'bridge/bridge_gallery.php';
			var pars = 'action=remove&id=' + id;
			var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: gallery_remove_resp });
			return true;
			}
		
              });

}
	
function gallery_remove_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Success"){
		Effect.Fade('gallery_entry_' + gallery_currentId ); 	
	}
	else win2("Une erreur s'est produite");

	
}

/*------------------------------------------------------------------------
/----------------------- Pictures ajax functions --------------------------
------------------------------------------------------------------------*/

function picture_insert()
{
	idGallery=gallery_currentId; // On garde l'id qui correspond au moment ou la fenêtre a été ouverte
	var form_picture="";
	form_picture+= "<br><table width=100%'>"
				+ "<tr width='100%' valign='top' height='30px'>"
				+ "<td  width='30px'>Type</td><td align='left'><input type='hidden' id='picture_add_galleryId'/>"
				+ "<select id='picture_add_type' style='width:200px;' onChange='switchUrl()'/>"
				+ "<option id='picture_add_type_image' value='IMAGE'>IMAGE</option>"
				+ "<option id='picture_add_type_image' value='YOUTUBE'>YOUTUBE</option>"
				+ "</select>"
				+ "</td></tr>"
				+ "<tr width='100%' valign='top' height='60px' >"
				+ "<td height='30px'>URL</td><td align='left' id='picture_add_urlcontainer'><iframe src='include/upload.php?idGallery=" + gallery_currentId +"'  class='iframe_upload'  style='width:250px;' frameborder='0'></iframe></td>"
				+ "</tr>"
				+ "<tr width='100%' valign='top'>"
				+ "<td colspan='2'>Description</td></tr>"
				+ "<tr><td colspan='2' valign='top'><input type='hidden' id='picture_add_videoId'/> <input type='hidden' id='picture_add_pictureName'/>"
				+ "<textarea id='picture_add_description' name='picture_add_description' height='150px' rows='5' cols='5'></textarea>"
				+ "</td>"
				+ "</tr>"
				+ "<tr width='100%' height='35px' valign='center'>"
				+ "<td width='50%' ><center><input type='button' value='Envoyer' onClick='picture_record()'/></center></td>"
				+ "<td width='50%' ><center><input type='button' value='Annuler' onclick='Windows.closeAll()'/></center></td>"
				+ "</tr>"
				+ "</table>";
	Dialog.info(form_picture,{className: "darkX",  width: 500, height: 310,showProgress: false});
	 	
}

function switchUrl()
{
	var type= $('picture_add_type').options[$('picture_add_type').selectedIndex].value;
	if (type=="YOUTUBE") $('picture_add_urlcontainer').innerHTML="<input type='text' style='width:200px' id='picture_add_youtube' onchange='checkYouTubeUrl()'/>";
	else $('picture_add_urlcontainer').innerHTML="<iframe src='include/upload.php?idGallery=" + gallery_currentId +"' class='iframe_upload'  style='width:200px;' frameborder='0'></iframe>"
}

function checkYouTubeUrl()
{
 var parseurl="";
 url=$('picture_add_youtube').value;
 parseurl=url.indexOf("?v=",0);
 var stopme=false
 if (parseurl!=-1){
	 var i=parseurl+3;
	 var movieNumb="";
	 while ((i<url.length) && (stopme!=true))
	 {
		if (url.charAt(i)=="&") stopme=true;
		else movieNumb+=url.charAt(i);
		i++;
	 }
	
	$('picture_add_urlcontainer').innerHTML="<center><img src='http://img.youtube.com/vi/" + movieNumb + "/default.jpg' /> </center>";
	$('picture_add_videoId').value=movieNumb;
	$('picture_add_type').disabled=true;
 }

}

function picture_record()
{
		var gallery =gallery_currentId;
		var type= $('picture_add_type').options[$('picture_add_type').selectedIndex].value;
		var description = encodeURI($('picture_add_description').value);
		var imgurl="";
		if (type=="YOUTUBE") imgurl=$('picture_add_videoId').value;
		else imgurl=$('picture_add_pictureName').value;
		var url = 'bridge/bridge_picture.php';
		var pars ='action=insert&gallery=' + gallery + '&type=' + type +'&url=' + imgurl + '&description=' + description;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: picture_record_resp });
}
	
function picture_record_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	var ob;
	if (response.Type=="Object"){
		ob=response.Value;
		strThumbs="";
		if  (ob.Type=="IMAGE"){

			var extLen=ob.Url.length-ob.Url.indexOf('.',0)-1;	
			var fileExtension=ob.Url.substr(ob.Url.length-extLen,extLen);
			var fileName=ob.Url.substring(0,ob.Url.length-(extLen+1));
	
			strThumbs+="<td><img id='img_"+ ob.Id +"' src='userfiles/galleries/"+ ob.Gallery +"/" + fileName 
							+ "_thumb."+ fileExtension + "' alt='' onClick='picture_getMedium(" + ob.Id  + ")' class='opacityimg' /></td> ";
		}
		else {
			strThumbs+="<td><img id='img_"+ ob.Id  +"' src='http://img.youtube.com/vi/" + ob.Url  + "/default.jpg' alt='' onClick='picture_getMedium(" + ob.Id  + ")' height='80px'  class='opacityimg' /></td> ";	
		}
		
		new Insertion.Bottom('tr_thumbs', strThumbs);
		Windows.closeAll();
	}
	else win2("Une erreur s'est produite");
	
}

function picture_getMedium(idPic)
{

		var url = 'bridge/bridge_picture.php';
		var pars ='action=getOne&id=' + idPic;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: picture_getMedium_resp });
}
	
function picture_getMedium_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Object"){
		ob=response.Value;
		if  (ob.Type=="IMAGE")
		{
			picture_currentId=ob.Id;
			var extLen=ob.Url.length-ob.Url.indexOf('.',0)-1;	
			var fileExtension=ob.Url.substr(ob.Url.length-extLen,extLen);
			var fileName=ob.Url.substring(0,ob.Url.length-(extLen+1));
			
			$('div_focus').innerHTML="<center><a href='userfiles/galleries/" + ob.Gallery + "/" + fileName + "_big." + fileExtension + "' target='blank'><img src='userfiles/galleries/" + ob.Gallery + "/" + fileName + "_middle." + fileExtension + "' style='margin-top:20px;border-style:none'/></a></center>"; 
		}
		else 
		{
			var strHtml="<center><object width='425' height='315' style='margin-top:20px';><param name='movie' value='http://www.youtube.com/v/" + ob.Url +"&rel=1&border=0'></param><param name='wmode' value='transparent'></param><embed src='http://www.youtube.com/v/" + ob.Url +"&rel=1&border=0' type='application/x-shockwave-flash' wmode='transparent' width='425' height='315' style='margin-top:20px'></embed></object></center>";
			$('div_focus').innerHTML=strHtml;
		}
		$('picture_td_commentaire').innerHTML = "<font align='left' class='boldTitle'>Commentaire :</font>";
		if (gallery_logged==true)  $('picture_td_commentaire').innerHTML +="&nbsp;&nbsp;&nbsp;<font class='stdText'><img src='images/edit.gif' style='cursor:pointer;width:14px;height:12px' onClick=\"picture_edit(" + ob.Id + ")\"/>Editer &nbsp;&nbsp;&nbsp;<img src='images/delete16.png' style='cursor:pointer;width:16px;height:16px' onClick='picture_remove(" + ob.Id + ")' >Supprimer l'image</font>";
		
		$('picture_td_commentaire').innerHTML +="<br/><br/><font class='stdText'>" + ob.Description + "</font>";
		
	}
	else win2("Une erreur s'est produite");
	
}


function picture_remove(id)
{
	Dialog.confirm("Voulez vous vraiment effacer cette entr&eacute;e ?", 
               {width:300, height:75, okLabel: "Oui", 
		className:"darkX",
               buttonClass: "myButtonClass",
               id: "dialogYesCancel",
               cancel:function(win){debug("cancel confirm panel")},
               ok:function(){	
			picture_currentId=id;
			var url = 'bridge/bridge_picture.php';
			var pars = 'action=remove&id=' + id;
			var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: picture_remove_resp });
			return true;
			}
		
              });

}
	
function picture_remove_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Success"){
		$('contenu').style.left="0px";
		getPicThumb(gallery_currentId);
		$('div_focus').innerHTML="";
		$('picture_td_commentaire').innerHTML ="";
	}
	else win2("Une erreur s'est produite");

	
}
function picture_edit(id)
{
	
	var form_gallery="";
	form_gallery+= "<br><table width=100%' height='70%'>"
				+ "<tr width='100%' valign='top'>"
				+ "<td align='center' colspan='2'>Description</td>"
				+ "</tr>"
				+ "<tr>"
				+ "<td align='center' colspan='2'><input type='hidden' id='picture_edit_id' value=''/>" 
				+ "<textarea id='picture_edit_description' name='picture_edit_description' width='100px'>"
				+ "</textarea>"
				+ "</tr>"
				+ "<tr width='100%' valign='center'><td width='50%'><center><input type='button' value='Envoyer'"			
				+ " onClick='picture_update()'/></center></td><td width='50%'><center><input type='button' value='Annuler' onclick='Windows.closeAll()'/></center></td></tr>"
				+ "</table>";
	Dialog.info(form_gallery,{className: "darkX",  width: 320, height: 140,showProgress: false});
	picture_getOneForUpdate(id)
}

function picture_getOneForUpdate(id)
{
		picture_currentId=id;
		var url = 'bridge/bridge_picture.php';
		var pars = 'action=getOne&id=' + id;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: picture_getOneForUpdate_resp });
}
	
function picture_getOneForUpdate_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Object"){
		ob=response.Value;
		$('picture_edit_description').innerHTML=ob.Description.replace(/<br>/,"\n");
		$('picture_edit_id').value=ob.Id;
	}
	else win2("Une erreur s'est produite");
	
}

function picture_update()
{
		var id=$('picture_edit_id').value;
		var description=encodeURI($('picture_edit_description').value);
		var url = 'bridge/bridge_picture.php';
		var pars = 'action=update&id=' + id + '&description=' + description;
		var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: picture_update_resp });
}
	
function picture_update_resp(originalRequest)
{
	var response = JSON.parse(originalRequest.responseText);
	if (response.Type=="Object"){
		ob=response.Value;
		$('picture_td_commentaire').innerHTML = "<font align='left' class='boldTitle'>Commentaire :</font>";
		if (gallery_logged==true) 
		{
			$('picture_td_commentaire').innerHTML +="&nbsp;&nbsp;&nbsp;<font class='stdText'><img src='images/edit.gif' style='cursor:pointer;width:14px;height:12px' onClick=\"picture_edit(" + ob.Id + ")\"/>Editer &nbsp;&nbsp;&nbsp;<img src='images/delete16.png' style='cursor:pointer;width:16px;height:16px' onClick='picture_remove(" + ob.Id + ")' >Supprimer l'image</font>";
			$('picture_td_commentaire').innerHTML +="<br/><br/><font class='stdText'>" + ob.Description + "</font>";
			Windows.closeAll();
		}
	}
	else win2("Une erreur s'est produite");
	
}


