
		var get_comment = function(id_photo,nb,page){		
						
			var handlerFunc = function(t) {
				    document.getElementById('comment_container').innerHTML = t.responseText;	
			}
			
			var errFunc = function(t) {
			    alert('Error ' + t.status + ' -- ' + t.statusText);
			}
		
			new Ajax.Request('/photos/get_comments/'+id_photo+'/'+nb+'/'+page, {onSuccess:handlerFunc, onFailure:errFunc});
		}
		var vote = function(id_photo){	
						
			var handlerFunc = function(t) {
				if(t.responseText == 'already_voted')
				    alert("Vous avez déjà voté...");
				else
				{
					document.getElementById('note-text-'+id_photo).innerHTML = t.responseText;
					document.getElementById('note-link-'+id_photo).innerHTML = 'Voté';
					
				}
				document.getElementById('note-link-'+id_photo).parentNode.parentNode.className='blocVote2';
			}
			
			var errFunc = function(t) {
			    alert('Error ' + t.status + ' -- ' + t.statusText);
			}
						
			new Ajax.Request('/photos/vote', {method:'post', postBody:'id_photo='+id_photo, onSuccess:handlerFunc, onFailure:errFunc});
		}
		
		var activeBallon = function(anObj){
				var anObj_id = anObj.id.split('_');
				anObj_id = anObj_id[anObj_id.length-1];
				//voted = 3;
				if(anObj_id >voted )
					lightup(anObj,20);
					
				if(!voted){
					anObj.onmouseover = function(){
							var id = this.id.split('_');
							id = id[id.length-1];
							for(i=0;i<5;i++)
							{
								document.getElementById('vote_ballon_'+(i+1)).style.cursor = 'pointer';
								if(i<id)
									lightup(document.getElementById('vote_ballon_'+(i+1)),100);
								else
									lightup(document.getElementById('vote_ballon_'+(i+1)),20);
							}
					}
					anObj.onclick = function(){
							var id = this.id.split('_');
							voted = id[id.length-1];
							for(i=0;i<5;i++)
							{
								document.getElementById('vote_ballon_'+(i+1)).style.cursor = 'normal';
								document.getElementById('vote_ballon_'+(i+1)).onmouseover = null;
								document.getElementById('vote_ballon_'+(i+1)).onclick = null;	
							}
							vote(id_photo,voted);		

							
					}
				}
			}
		
		var add_comment = function(){
			var id_photo = escape(document.getElementById('id_photo_comment').value);
			var pseudo = escape(document.getElementById('pseudo_comment').value);
			if(document.getElementById('password_comment'))
				var password = escape(document.getElementById('password_comment').value);
			var title = escape(document.getElementById('title_comment').value);
			var comment = escape(document.getElementById('text_comment').value);
			
			
			var handlerFunc = function(t) {
				if(t.responseText != 'OK')
				    alert(t.responseText);
				else
				{
					get_comment(id_photo,nb_comment,1);
					document.getElementById('title_comment').value = '';
					document.getElementById('text_comment').value = '';
					if(document.getElementById('password_comment'))
					{
						get_user_block();
					}
				}
			}
			
			var errFunc = function(t) {
			    alert('Error ' + t.status + ' -- ' + t.statusText);
			}
			new Ajax.Request('/photos/send_comment', {method:'post', postBody:'id_photo='+id_photo+'&pseudo='+pseudo+'&password='+password+'&title='+title+'&comment='+comment, onSuccess:handlerFunc, onFailure:errFunc});
		}	
		
		var showLayer = function(){
			if(document.getElementById('photoLayer').style.display != 'block')
			{
				document.getElementById('photoLayer').style.display = 'block';
				document.getElementById('photoLayerContent').style.display = 'block';
				document.getElementById('pub_header').style.display = 'none';
				document.getElementById('sky_pub').style.display = 'none';
				document.getElementById('carre_pub').style.display = 'none';				

			}
			else
			{
				document.getElementById('photoLayer').style.display = 'none';
				document.getElementById('photoLayerContent').style.display = 'none';
				document.getElementById('pub_header').style.display = 'block';
				document.getElementById('sky_pub').style.display = 'block';
				document.getElementById('carre_pub').style.display = 'block';				
			}
				
		}		
