/*  Js */

/* Variables */

// Liens

var link0 = ['Accueil','Le Yoseikan Budo','Une pratique pour tous','Les Clubs','Agenda','Liens','Structure du Y.B. et contact','Actualités'];

var link1 = ['Présentation de la méthode','La famille Mochizuki','Le Dojo Yoseikan','La Symbolique'];
var link2 = ['Pour tous les âges','Les enfants','Yoseikan et santé','La compétition','Yoseikan Training/Sparring','Equipement'];
var link3 = ['Bruxelles','Genappe','Ottignies-L.L.N','Walhain','Court-St-Etienne','Ken\'zen\' Bushido...'];


var href0 = ['index.html','','','','calendrier.php','liens.html','contact.html','http://www.yoseikan-budo.be/blog/'];

var href1 = ['yoseikan_presentation.html','yoseikan_mochizuki.html','yoseikan_dojo.html','yoseikan_symbol.html'];
var href2 = ['pratique_tous.html','pratique_enfants.html','pratique_sante.html','pratique_competition.html','pratique_training.html','pratique_tenue.html'];
var href3 = ['club_bx.html','club_genappes.html','club_ottignies.html','club_walhain.html','club_renivaux.html','club_academie_budo.html'];

// Tableau d'image gallerie

collImg = new Array('2011-series_06.jpg','2011-series_28.jpg','2011-series_09.jpg','2011-series_11.jpg','2011-series_12.jpg','2011-series_16.jpg','2011-series_17.jpg','2011-series_19.jpg','2011-series_20.jpg','2011-series_21.jpg','2011-series_22.jpg','2011-series_23.jpg','2011-series_24.jpg','2011-series_25.jpg','2011-series_26.jpg','2011-series_27.jpg','2011-series_29.jpg','2011-series_30.jpg','2011-series_31.jpg','2011-series_32.jpg','2011-series_33.jpg','2011-series_34.jpg','2011-series_04.jpg','2011-series_05.jpg','2011-series_07.jpg','2011-series_08.jpg','2011-series_10.jpg','2011-series_13.jpg','2011-series_14.jpg','2011-series_15.jpg','2011-series_18.jpg','stage_hiroo_2011_01.jpg','stage_hiroo_2011_02.jpg','stage_hiroo_2011_03.jpg','stage_hiroo_2011_04.jpg','stage_hiroo_2011_05.jpg','stage_hiroo_2011_06.jpg','stage_hiroo_2011_07.jpg','stage_hiroo_2011_08.jpg','stage_hiroo_2011_09.jpg','stage_hiroo_2011_10.jpg','stage_hiroo_01.jpg','stage_hiroo_02.jpg','stage_hiroo_03.jpg','stage_hiroo_04.jpg','stage_hiroo_05.jpg','stage_hiroo_06.jpg','stage_hiroo_07.jpg','stage_hiroo_08.jpg','stage_hiroo_09.jpg','stage_hiroo_10.jpg','stage_hiroo_11.jpg','stage_hiroo_12.jpg','stage_hiroo_13.jpg','stage_hiroo_14.jpg','stage_hiroo_15.jpg','stage_hiroo_16.jpg','stage_hiroo_17.jpg','aix_01.jpg','aix_02.jpg','aix_03.jpg','aix_04.jpg','aix_05.jpg','aix_06.jpg','sparing_01.jpg','sparing_02.jpg','sparing_03.jpg','sparing_04.jpg','sparing_05.jpg','sparing_06.jpg','sparing_07.jpg','sparing_08.jpg','sparing_09.jpg','sparing_10.jpg','sparing_11.jpg','sparing_12.jpg','sparing_13.jpg','sparing_14.jpg','sparing_15.jpg','sparing_16.jpg','sparing_17.jpg','sparing_18.jpg','sparing_19.jpg','sparing_21.jpg','sparing_20.jpg'); 

/*
Fonctions ... 
*/

function menuTop(lin,href){


  res = '<nav id="topNav"><ul>';
  

  for(i=0; i< href.length; i++){

  if(href[i] == ''){
    
    thisLink = eval('link'+i);
    thisHref = eval('href'+i);
    res += '<li><a href="#" >'+lin[i]+'</a>';
    res += '<ul>';
    for(k = 0; k < thisHref.length; k++){
      res += '<li><a href='+thisHref[k]+'>'+ thisLink[k] +'</a></li>';
    }
    res += '</ul>';    
    res += '</li>';
    }else{
    res +=   '<li class="menu"><a href="'+href[i]+'">'+lin[i]+'</a>';

    }

  }
  //res += '<li><form><input type="text" /></form></li>';
  res += '</ul></nav>';

document.write(res);
//alert(res); 

}

function link(lin,href){

 mess = '<ul>';
 for( i in lin) {
   mess += '<li><a href='+href[i]+'>'+ lin[i] +'</a></li>';
 }
 mess += '</ul>';
 document.write(mess);
//alert(res);
}

/*
  Nav bar
*/

$(function(){
				
				//cache nav
				
var navigbar = function(){
				//add indicator and hovers to submenu parents
				
$("#topNav").find("li").each(function() {
		if ($(this).find("ul").length > 0) {
			$("<span>").text("^").appendTo($(this).children(":first"));

						//show subnav on hover
			$(this).mouseenter(function() {
				$(this).find("ul").stop(true, true).slideDown();
			});
						
						//hide submenus on exit
			$(this).mouseleave(function() {
			$(this).find("ul").stop(true, true).slideUp();
                        });
                }
                });
  }
navigbar();
});
                        
                        
                        
                        
function menuFoot(lin,href){
   
 for(k=0; k<lin.length;k++){
  num = k+1;

  mess = '<ul id="footer'+num+'">';
  
  if(k == 1 || k == 2|| k == 3 ){
  mess += '<li class="liFootMenu">'+lin[k]+'</li>';
  lien = eval('link'+k);
  hre = eval('href'+k);
  
    for(i=0; i<lien.length;i ++){
  mess += '<li><a class="linkFootMenu" href='+hre[i]+'>'+lien[i]+'</a></li>'; 
    }        

  }else{
  mess += '<li><a class="linkFootMenu" href="'+href[k]+'">'+lin[k]+'</a></li>';
    
  }
  mess += '</ul>';
  document.write(mess);
  }

}



/*
SlideShow
*/

$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}

// Fonction alléatoire pour la  function gallery ..JQUERY
                    
function slideSort(tab){
  html = "";                       
  nb_tab = tab.length-1; 
  nlen = tab.length;
  for(n = 0 ; n < nlen; n++){
    
    numb = Math.round(Math.random()*nb_tab);

        if(n ==0){
        html += "<a href=\"galery-ui.html\" class=\"show various4\"><img src=\"img/slide/"+tab[numb]+"\" rel=\" \"/></a>";
        }else{
        html += "<a href=\"galery-ui.html\" class=\"various4\"><img src=\"img/slide/"+tab[numb]+"\" rel=\" \"/></a>";
        }      



    
    
  }
  //alert(html);
  return html;    
} 

function GalerySort(tab,opt){
  html = "";                       
  nb_tab = tab.length-1; 
  nlen = tab.length;
  for(n = 0 ; n < nlen; n++){
    
    numb = Math.round(Math.random()*nb_tab);
    if(opt==0){
        if(n ==0){
        html += "<a href=\"galery-ui.html\" class=\"show various4\"><img src=\"img/slide/"+tab[n]+"\" rel=\" \"/></a>";
        }else{
        html += "<a href=\"galery-ui.html\" class=\"various4\"><img src=\"img/slide/"+tab[n]+"\" rel=\" \"/></a>";
        }      
    }else{
        html+="<li>\n";
        html+="<a href=\"img/slide/"+tab[n]+"\"><img src=\"img/slide/"+tab[n]+"\" width=\"75px\" class=\"image"+n+"\"></a>\n"; 
        html+="</li>\n";         
    }

    
    
  }
  //alert(html);
  return html;    
} 



/*
 Background move
*/

$(function()
{
	var bgmouvement = function()
	{        
        $('#menus').bind('mousemove',function(e){
            largePageOfWidth = $(window).width();
            middlePageOfWidth = $(window).width()/2 ;
        
            largePageOfHeight = $(window).height();
            middlePageOfHeight = $(window).height()/2 ;
            
            valeurX = e.pageX - middlePageOfWidth; 
            valeurY = e.pageY - middlePageOfHeight;
                    //$("#block").text("e.pageX: " + valeurX + ", e.pageY: " + valeurY/3);
                    
                    $('#menus').stop().animate({backgroundPosition:valeurX/4 +" "+ valeurY/3},1500);        
            
            });
        }
        bgmouvement();
});        

/*
News ticker 
*/

$(function()
{
	var ticker = function()
	{
		setTimeout(function(){
			$('#ticker li:first').animate( {marginTop: '-120px'}, 800, function()
			{
				$(this).detach().appendTo('ul#ticker').removeAttr('style');	
			});
			ticker();
		}, 4000);
	};
	ticker();
});                



/*
*   Examples - images


$(document).ready(function() {

			$("#various3,.various4").fancybox({
				'width'				: 900,
				'height'			: 580,
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
                                'overlayOpacity' : 0.3,
                                'overlayColor' : '#333'
			});


}); 
 
*/

