var state = 0;          
var fontBg = "<img src='images/background_45.jpg' alt=''/><img src='images/background_44.jpg' alt=''/><img src='images/background_36.jpg' alt='class='active' /><img src='images/background_29.jpg' alt=''/><img src='images/background_25.jpg' alt=''/><img src='images/background_31.jpg' alt=''/><img src='images/background_47.jpg' alt=''/><img src='images/background_41.jpg' alt=''/><img src='images/background_8.jpg' alt='' /><img src='images/background_17.jpg'/><img src='images/background_4.jpg'/><img src='images/background_24.jpg'/><img src='images/background_16.jpg' /><img src='images/background_54.jpg' alt=''/>";

function preLoadImg() {

	heavyImage = new Image();
	heavyImage.src = "images/background_6.jpg";
	heavyImage.src = "images/background_10.jpg";
	heavyImage.src = "images/background_16.jpg";
	heavyImage.src = "images/background_4.jpg";
	heavyImage.src = "images/background_21.jpg";
	heavyImage.src = "images/background_8.jpg";
	heavyImage.src = "images/background_15.jpg";
	heavyImage.src = "images/background_12.jpg";
	heavyImage.src = "images/background_18.jpg";
	heavyImage.src = "images/background_20.jpg";
	heavyImage.src = "images/background_7.jpg";
	heavyImage.src = "images/background_24.jpg";
	heavyImage.src = "images/background_11.jpg";
	heavyImage.src = "images/background_15.jpg";
	heavyImage.src = "images/background_9.jpg";
	heavyImage.src = "images/background_19.jpg";
	heavyImage.src = "images/background_22.jpg";
}

function slideSwitch() {
	
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
        });
}

function loadGallery (idGallery) {
	
	$('.gallery').load('page/galerie.php?event=' + idGallery);
}

function loadListGallery () {
	
	$('.gallery').load('page/evenements_particulier.php');
}

function loadConnectionGallery (idGallery) {
	
	$('.gallery').load('page/connection_galerie.php?event=' + idGallery);
}

function loadPageGallery (idGallery, pageGallery) {
	
	$('.gallery').load('page/galerie.php?event=' + idGallery + '&galry_pg=' + pageGallery);
}

function loadDevis () {
	
	$('#cboxLoadedContent').load('page/devis.php');
}

function showPhoto (Event, currentPage, photo, previusPhoto) {
	
	$('.gallery').load('page/photo.php?event=' + Event + '&galry_pg=' + currentPage + '&photo=' + photo + '&previus_photo=' + previusPhoto);
}

function switchPhoto (Event, photoname) {
	
	$('.gallery').load('page/photo.php?previus_photo=' + photoname + '&event=' + Event);
}
function switchBackPhoto (Event, photoname) {
	
	$('.gallery').load('page/photo.php?previus_photo=' + photoname + '&event=' + Event + '&back=1');
}

function showTeam () {
	
	$('#slideshow').html('<img src="images/equipe.png" alt="" /><img src="images/equipe.png" alt="" />').fadeIn(6000);
	$('#center').load('page/empty.php').fadein(6000);
	state = 1;
}

function ChangeState() {
	
	if (state == 1) {
		$('#center').load('page/accueil.php').fadein(6000);
		$('#slideshow').html(fontBg).fadeIn(6000);
	}
}

var opts =
    // horizontal Dock with images expanding downwards in the vertical axis...
  { align: 'left'
    // set the maximum minor axis (vertical) image dimension to 48px
  , size: 50
    // add labels..
  , labels: true
  , fadeIn: 1000
};

$(document).ready(function(){
	$('#slideshow').html(fontBg).fadeIn(6000);
    $('#menu').jqDock(opts);
});

$(function() {
	
    setInterval( "slideSwitch()", 3000 );
});

$(document).ready(
    function(){
		$('#menu').jqDock(opts);
		$('#center').load('page/accueil.php').hide().fadeIn('slow');
		Cbox ();
		$('#footer').load('template/footer.php').fadeIn('slow');
		$('#footer').fadeIn('slow', function() {
		$('#footer').corner('10px tl');
		preLoadImg();
		});
    }
);

$(document).mouseover(function(){
	$('.jqDock').corner('10px tr br');
});

function Cbox () {
	
	$('.cboxElement').colorbox({
            	onComplete:function() {
					$("#tabs").tabs({
						ajaxOptions: {
							error: function(xhr, status, index, anchor) {
										$(anchor.hash).html("La page n'existe pas, nous nous excusons pour ce désagrément.");
								   }
						}
					});
				}
	});
}

