slider = new Array();
big = new Array();
big["width"] = 438;
big["height"] = 500;
big["height2"] = big["height"];
small = new Array();
small["width"] = 347;
small["height"] = 396;
small["height2"] = small["height"];
font = new Array();
font["big"] = 16;
font["small"] = 12;
timer = -1;

function equilibrate() {
	$('#main ul li').each(function(i) {
		d = Math.abs(actual - i);
		var a = $(this);
		var img = a.children('a').children('img');
		var glow = a.children('#glow');
		var ttl = a.children('.imtitle');
		switch(d) {
			case 0:
				//$(this).css("margin-top", "-40px");
				
				img.animate({width: big["width"], height: big["height"]});
				a.animate({width: big["width"], height: big["height2"], marginTop: '-40px'});
				
				$(this).css('z-index', '999');
				
				if($.browser.msie){
					glow.fadeTo("slow", 0.1);
				}
				else{
					glow.fadeTo("slow", 1.0);
				} 
				
			break;
			case 1:
				if (slider[i] == 1) {
					slider[i] = 0;
					a.css({display: 'inline', width: '0px', height: '0px'});
					img.css({width: '0px', height: '0px'});
					
				} else {
					//$(this).css("margin-top", "0px");
					$(this).animate({
						  marginTop: "0px"
					}, 'fast');

				}
				img.animate({width: small["width"], height: small["height"]});
				a.animate({width: small["width"], height: small["height2"]});
				
				$(this).css('z-index', '0');
				glow.fadeTo(0, 0);
				
			break;
			default:
				if (slider[i] != 1) {
					slider[i] = 1;
					a.hide('fast');
				}
			break;
		}
	});
	//directlink();
	//rotate();
	
}
function actual_change(diff) {
	if (actual + diff > 0 && actual + diff < max) {
		actual = actual + diff;
		
		// Hide left arrow if position is first slide
		if(actual==1){ $('#butleft').hide() } else{ $('#butleft').show() }
		// Hide right arrow if position is last slide 
		if(actual==11){ $('#butright').hide() } else{ $('#butright').show() }
		
		return true;
	}
	return false;
};
function directlink() {
	$('#directlink').attr('href', location.href.replace(location.search, '') + '?show=' + actual);
}
$(document).ready(function(){
	var requete = location.search.substring(1);
	var tab_paires = requete.split("&");
	var tab_elts = new Array();
	for (var i = 0; i < tab_paires.length; i++) {
		temp = tab_paires[i].split("=");
		tab_elts[temp[0]] = unescape(temp[1]);
	}

	$('#main ul').css('overflow', 'hidden');
	//$('#slider ul').prepend('<li><a><img src="images/img1.jpg" alt="" /></a></li>');
	max = $('#main ul li').size();

	i = (tab_elts["show"]) ? parseInt(tab_elts["show"]) : 0;
	actual = (!isNaN(i) && i > 0 && i < max) ? i : 1;

	$('#main ul li').each( function(i) {
		d = Math.abs(actual - i);
		var a = $(this);
		var img = a.children('a').children('img');
		var ttl = a.children('.imtitle');
		switch(d) {
			case 0:
				img.css({width: big["width"]+'px', height: big["height"]+'px'});
				a.css({height: big["height2"]+'px'});
			break;
			case 1:
				img.css({width: small["width"]+'px', height: small["height"]+'px'});
				a.css({width: small["width"]+'px', height: small["height2"]+'px'});
			break;
			default:
				a.css({display: 'none', width: '0px', height: '0px'});
			break;
		}
	});
	$('#butleft').click( function () {
		if (actual_change(-1))
			equilibrate();
		return false;
	});
	$('#butright').click( function () {
		if (actual_change(+1))
			equilibrate();
		return false;
	});
	
	//$('#butright').click();
	$('#butright').click();
	setTimeout('$(\'#butleft\').click();', 500)

	
});
function next() {
	if (actual_change(+1))
		equilibrate();
}
