function shot_next() {
	pos = ( (current_shot_pos + 1) >= nb_shots ) ? 0 : current_shot_pos + 1 ;
	
	go_shot(current_shot_pos, pos);
	
}

function shot_previous() {
	pos = ( (current_shot_pos - 1) < 0 ) ? nb_shots - 1 : current_shot_pos - 1;

	go_shot(current_shot_pos, pos);
	
}


function go_shot(old, pos) {
		
		
	if ( old == -1 ) {
		old = current_shot_pos;
	}	
	if ( old == pos ) {
		return false;
	}
	
	elt = $('shot'+old);
	elt_new = $('shot'+pos);
	
	$('bullet'+old).set('class', 'emptybullet');
	$('bullet'+pos).set('class', 'fullbullet');
	var fade_out = new Fx.Morph(elt, {duration: 500, onStart: function() {
		


		
														elt_new.setStyle('display', 'block');
														var fade_in = new Fx.Morph(elt_new, {duration: 500,onStart:function() {var width = new Fx.Morph($('currentshot')).start({'width':[elt.width,elt_new.width]});
														}}).start({'opacity': [0,1]});
													}
									}).start({
		    'opacity': [1,0],

		});



		current_shot_pos = pos;
	
	
}


// JavaScript Document
var xmlhttps= new Array();

function loadXMLdoc(url, id, attente, postvars) {
	var i= xmlhttps.length;
	if ( attente != null ) {
		document.getElementById(id).innerHTML= attente;
	}
	
	if(window.XMLHttpRequest) {/*Mozilla*/
		xmlhttps[i]= new XMLHttpRequest();
		xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
		
		if ( postvars != null ) {
			xmlhttps[i].open("POST", url, true);
			xmlhttps[i].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttps[i].send(postvars);
		} else {
			xmlhttps[i].open("GET", url, true);
			xmlhttps[i].send(null);
		}
	}
	else if(window.ActiveXObject) {/*IE*/
		xmlhttps[i]= new ActiveXObject("Microsoft.XMLHTTP");
		if(xmlhttps[i]) {
			xmlhttps[i].onreadystatechange= function() { xmlhttpChange(i, url, id); };
			if ( postvars != null ) {
				xmlhttps[i].open("POST", url, true);
				xmlhttps[i].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttps[i].send(postvars);
			}
			else {
				xmlhttps[i].open("GET", url, true);
				xmlhttps[i].send();
			}
		}
	}
}

function xmlhttpChange(i, url, id) {
	if(xmlhttps[i].readyState==4) {/*complete*/
		if(xmlhttps[i].status < 400) {
			document.getElementById(id).innerHTML= xmlhttps[i].responseText;
		}
		else {
			document.getElementById(id).innerHTML= "[<span title=\""+url+"\">Erreur "+xmlhttps[i].status+"</span>]";
		}
	}
}


function tick(type, id) {
	if ( type == 1 ) {
		str = 'own';
	}
	else {
		str = 'wish';
	}
	var status = document.getElementById(str+id).src;
	loadXMLdoc('/includes/ajax.inc.php?app_id=' + id + '&action='+type, 'tmp', null, null);
	var reg=new RegExp("[/]+", "g");
	tmp = document.getElementById(str+id).src.split(reg)

	if (tmp[4] == 'tick.png' ) {
		document.getElementById(str+id).src = '/styles/img/tick-checked.png';
	}
	else {
		document.getElementById(str+id).src = '/styles/img/tick.png';
	}
}

function remove(type, id) {
	url = '/includes/ajax-remove.inc.php?app_id=' + id +'&action='+ type;
	elt = $('app'+id);
	var fade_out = new Fx.Morph(elt, {duration: 500, onComplete: function() {elt.setStyle('display', 'none'); var req = new Request({'method':'get','url':url}).send();}}).start({'opacity': [1,0]});
}

