// JavaScript Document


function switch_background(ind_background )  // diaparama page d'acueil
{

	background_path = "/images/website/";	
	if(typeof(ind_background) == 'undefined')   ind_background = 0 ;  
	new_background = background_path + background_image_list[ind_background]; // background_image_list => gobal setté depuis php

	$('.main_frame .tag_back_2').html('<img src="'+ new_background + '"  class="tag_img_back" />');	
	$('.main_frame .tag_back_2').delay(1000).animate({
    opacity: 1,
  }, 2000, function() {
    $('.main_frame .tag_back_1').html($('.main_frame .tag_back_2').html());
		$('.main_frame .tag_back_2').css('opacity',0).html('');
		ind_background++;
		if(ind_background > background_image_list.length-1) ind_background = 0 ; 
		switch_background(ind_background);	
  });
}



function highlight_nav(selected_page)
{
	$("#nav").find("a[href='"+selected_page+"']").addClass('selected');	
}


// ------ Ajax Function ----




function navig_gallery (way)
{
	
	picture_path = "/images/picture/";	
	
	if(typeof(gallery_photo) == 'undefined') return false ;
	// alert(way + '-' + gallery_photo);
	picture_element = $('#content_gallery .tag_img_in_frame_picture') ;
	current_picture = parseInt($(picture_element).attr('value'));
	
	new_indice_picture = current_picture + parseInt(way) ;
	
	if(new_indice_picture == gallery_photo.length) 
	{
	new_indice_picture = 0;
	} else {
	if(new_indice_picture <0) new_indice_picture = gallery_photo.length-1;
	}
		
	$(picture_element).attr('value' ,new_indice_picture ) ;
	$(picture_element).attr('src' ,picture_path + gallery_photo[new_indice_picture]['name'] ) ;
	
	if(gallery_photo[new_indice_picture]['titre'] == null) gallery_photo[new_indice_picture]['titre'] = '&nbsp;';
	$('#content_gallery .tag_nav_titre').html(gallery_photo[new_indice_picture]['titre']) ;

	$('#content_gallery .tag_nav_commentaire').html(gallery_photo[new_indice_picture]['commentaire']) ;
		
	//  console.log(typeof(gallery_photo[new_indice_picture]['titre']));
}




