$(document).ready(function() {
	$('#photoarea').serialScroll({
		items:'a',
		prev:'#leftarrow a',
		next:'#rightarrow a',
		axis:'x',
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		cycle:false,
		step: 6
	});
	
	initFiltreGalerie()
});

function showPhoto(photo) {
	var grande = $('#photogalerie img');
	var petite = $('img', $(photo));
	var srcPhoto = petite.attr('src');
	var posPhoto = srcPhoto.indexOf('photo')+6;
	srcPhoto = srcPhoto.substring(0, posPhoto) + srcPhoto.substring(srcPhoto.indexOf('/', posPhoto)+1);
	grande.attr('src', srcPhoto);
	grande.attr('alt', petite.attr('alt'));
	$('#photogalerie h1').html(petite.attr('title'));
	$('#photogalerie p').html(petite.attr('alt'));
	return false;
}

function galerieChangeType() {
	var type = $('#typeRech').val();
	if(type=='1') {
		$('#articleRech').show();
		$('#joueurRech').hide();
		$('#matchRech').hide();
	}
	else if(type=='2') {
		$('#articleRech').hide();
		$('#joueurRech').show();
		$('#matchRech').hide();
	}
	else if(type=='3') {
		$('#articleRech').hide();
		$('#joueurRech').hide();
		$('#matchRech').show();
	}
	else if(type=='') {
		document.location='?type=0';
	}
}

function galerieChangeArticle() {
	id=$('#articleRech').val();
	if(id!='') {
		document.location='?type=1&id='+id;
	}
}

function galerieChangeJoueur() {
	id=$('#joueurRech').val();
	if(id!='') {
		document.location='?type=2&id='+id;
	}
}

function galerieChangeMatch() {
	var id=$('#matchRech').val();
	if(id!='') {
		document.location='?type=3&id='+id;
	}
}

function initFiltreGalerie() {
	var locat = ''+document.location;
	var reg=new RegExp("type=([0-9]+)\&id=([0-9]+)\&?", "g");
	var tab=reg.exec(locat);
	if(tab!=null) {
		var selectUsed;
		var type = tab[1];
		$('#typeRech').val(type);
		if(type=='1') selectUsed = $('#articleRech');
		else if(type=='2') selectUsed = $('#joueurRech');
		else if(type=='3') selectUsed = $('#matchRech');
		selectUsed.show();
		selectUsed.val(tab[2]);
	}
}

function showVideo(source) {
	$.modal("<div id=\"galerie_flashvideo\">La vid&eacute;o ne peut pas &ecirc;tre lue, car vous ne disposez pas d'une version de Flash suffisamment r&eacute;cente.Veuiller t&eacute;l&eacute;charger <a href=\"http://www.macromedia.com/go/getflashplayer\">le player Flash</a>.</div><div id=\"galerie_parenaire\"><a href=\"http://www.universal-connect.com/\"><img src=\"/images/universal_connect.png\" alt=\"partenaire\"/> </a>");
	var s1 = new SWFObject("/swf/player.swf","ply","400","320","9","#FFFFFF");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("flashvars","file="+source);
	s1.write("galerie_flashvideo");

	//var so = new SWFObject('/uploads/photo/5349c51b2373d8a2f752b71d908fcdea.swf', 'mpl', '212', '157', '9');
	//so.write('galerie_flashvideo');
}

