/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - 
+ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - */
function ask(url){
	document.location = url + ((url.indexOf('?') > 0) ? '&' : '?') + 'confirmed';
}

/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - 
+ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - */
document.addEvent('domready', function(){

	//
	// Overview People
	//
	peopleRequest = new Request.HTML({
		'link'	: 'cancel',
		'url'	: '/people/ajax-display',
		'onComplete': function(v,a,d){
			$('overview').set('html', d);
		}
	});

	$$('.displayPeople').addEvents({
		'mouseenter' : function(){
			createOverView(this, 345);
			peopleRequest.get({id_people:this.id});
		}
	});



	//
	// Overview Film
	//
	filmRequest = new Request.HTML({
		'link'	: 'cancel',
		'url' 	: '/film/ajax-display',
		'onComplete': function(v,a,d){
			$('overview').set('html', d);
		}
	});

	$$('.displayFilm').addEvents({
		'mouseenter' : function(){
			createOverView(this, 345);
			filmRequest.get({id_film:this.id});
		}
	});
	
	
	//
	// Recto / Verso
	//
	if($('verso')){

		$('recto').addEvent('mouseover', function(){
			$('recto').setStyle('display', 'none');
			$('verso').setStyle('display', 'block');
		});

		$('verso').addEvent('mouseout', function(){
			$('recto').setStyle('display', 'block');
			$('verso').setStyle('display', 'none');
		});
	}
	
	//
	// Favoris
	//
	$$('.my-fav').addEvent('click', function(){
		var d = (this.hasClass('fav-on')) ? 'remove' : 'set';
		var f = (this.hasClass('is-people')) ? 'people' : 'film';
		
		if(f == 'film'){
			var opt = {
				'id_film'	: this.id,
				'todo'		: d
			}
		}else{
			var opt = {
				'id_people' : this.id,
				'todo'		: d
			}
		}

		if(d == 'remove'){
			this.removeClass('fav-on');
		}else{
			this.addClass('fav-on');
		}

		new Request.JSON({
			'link'	: 'cancel',
			'url'	: '/'+f+'/fav',
			'onComplete': function(v){
			}
		}).get(opt);
		
	});
	
});

/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - 
+ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - */
function createOverView(el, delta){

	if($('overview')) $('overview').destroy();

	var pos = el.getCoordinates();
	
	var div = new Element('div', {
		'id'		: 'overview',
		'styles'	: {
			'left' 	: pos.left + 'px',
			'top'  	: pos.top  + 'px'
		},
		'events'	: {
			'mouseleave' : function(){
				$('overview').destroy();
			}
		}
	}).inject(document.body, 'bottom');
	
	if(el.hasClass('displayAbove')){
		div.setStyle('top', (div.getStyle('top').toInt()  + pos.height)+'px');
	}else
	if(el.hasClass('displayLeft')){
		var parDv = el.getParent();
		var parSi = parDv.getCoordinates();

		div.setStyle('left', (parSi.left - delta)+'px');
	}

}


/* + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - 
+ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - */
function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

