
var rotationAccueil = {
	actif: 0,
	interval: 5500,
	timerRotate: null,
	timerSelect: null,
	aItem: new Array(),
	cLiBloc: null,
	cLiOnglet: null,
	autoRotate: true,
	init: function() {
		rotationAccueil.cLiBloc = YAHOO.util.Dom.getElementsByClassName('accueilLi', 'li', 'tpl_accueilUne');
		rotationAccueil.cLiOnglet = YAHOO.util.Dom.getElementsByClassName('onglet', 'ul', 'tpl_accueilUne');
		if (rotationAccueil.cLiOnglet.length > 0) {
			rotationAccueil.cLiOnglet = rotationAccueil.cLiOnglet[0].getElementsByTagName('LI');
		}
		else {
			rotationAccueil.cLiOnglet = false;
		}
		
		var cImg = YAHOO.util.Dom.getElementsByClassName('accueilImgContainer', 'div');
		
		var i = 0;
		while (rotationAccueil.cLiBloc[i]) {
			rotationAccueil.cLiBloc[i].id = 'accueil_' + i;
			i++;
		}
		rotationAccueil.actif = Math.floor(Math.random() * i);
		
		YAHOO.util.Event.addListener(rotationAccueil.cLiOnglet, "click", rotationAccueil.selectOnglet);
		YAHOO.util.Event.addListener(rotationAccueil.cLiOnglet, "mouseover", rotationAccueil.pause);
		YAHOO.util.Event.addListener(rotationAccueil.cLiOnglet, "mouseout", rotationAccueil.start);
		YAHOO.util.Event.addListener(rotationAccueil.cLiBloc, "mouseover", rotationAccueil.selectTimer);
		YAHOO.util.Event.addListener(rotationAccueil.cLiBloc, "mouseout", rotationAccueil.start);
		YAHOO.util.Event.addListener(cImg, "mouseover", rotationAccueil.pause);
		YAHOO.util.Event.addListener(cImg, "mouseout", rotationAccueil.start);
		rotationAccueil.rotate();
		rotationAccueil.start();
	},
	add: function(src, content, type) {
		var len = rotationAccueil.aItem.length;
		rotationAccueil.aItem[len] = new Array();
		rotationAccueil.aItem[len].id =  "accueil_" + len;
		rotationAccueil.aItem[len].src = src;
		rotationAccueil.aItem[len].content = content;
		rotationAccueil.aItem[len].type = type;
	},
	rotate: function() {
		if (rotationAccueil.autoRotate) {
			rotationAccueil.select((rotationAccueil.actif + 1) % rotationAccueil.aItem.length);
		}
	},
	pause: function() {
		clearTimeout(rotationAccueil.timerSelect);
		clearInterval(rotationAccueil.timerRotate);
	},
	start: function() {
		if (rotationAccueil.autoRotate) {
			rotationAccueil.pause();
			rotationAccueil.timerRotate = setInterval("rotationAccueil.rotate()", rotationAccueil.interval);
		}
	},
	selectOnglet: function(evt) {
		var nb = rotationAccueil.aItem.length;
		for (var i = 0 ; i < nb; i++) {
			if ('li_' + rotationAccueil.aItem[i].type == this.id) {
				rotationAccueil.select(i);
				break;
			}
		}
		YAHOO.util.Event.stopEvent(evt);
	},
	selectTimer: function() {
		rotationAccueil.pause();
		var i = 0;
		for (i = rotationAccueil.aItem.length - 1 ; i >= 0; i--) {
			if (rotationAccueil.aItem[i].id == this.id) {
				break;
			}
		}
		if (rotationAccueil.actif != i) {
			rotationAccueil.timerSelect = window.setTimeout(function() {rotationAccueil.select(i)}, 500);
		}
		
	},
	select: function(val) {
		rotationAccueil.actif = val;
		var eA = rotationAccueil.cLiBloc[rotationAccueil.actif].getElementsByTagName('a')[1];
		var eImg = YAHOO.util.Dom.getElementsByClassName('accueilImg', 'img', rotationAccueil.aItem[rotationAccueil.actif].type)[0];
		var cDiv = YAHOO.util.Dom.getElementsByClassName('accueilContent', 'div', rotationAccueil.aItem[rotationAccueil.actif].type);
		
		eImg.src = rotationAccueil.aItem[rotationAccueil.actif].src;

		var txt = '<p class="titre">' + eA.innerHTML + '</p><p class="resume">' + rotationAccueil.aItem[rotationAccueil.actif].content + '</p>';
		if (eA.href) {
			txt += '<p class="suite"><a href="' + eA.href + '" class="puceBlanche">Lire la suite</a></p>';
		}
		cDiv[0].innerHTML = txt;

		YAHOO.util.Dom.removeClass(rotationAccueil.cLiBloc, 'selected');
		YAHOO.util.Dom.addClass(rotationAccueil.cLiBloc[rotationAccueil.actif], 'selected');
		
		YAHOO.util.Dom.removeClass(rotationAccueil.cLiOnglet, 'selected');
		YAHOO.util.Dom.addClass(document.getElementById('li_' + rotationAccueil.aItem[rotationAccueil.actif].type), 'selected');

		YAHOO.util.Dom.addClass(YAHOO.util.Dom.getElementsByClassName('bloc', 'div', 'tpl_accueilUne'), 'invisible');
		YAHOO.util.Dom.removeClass(document.getElementById(rotationAccueil.aItem[rotationAccueil.actif].type), 'invisible');
	}
}
YAHOO.util.Event.onDOMReady(rotationAccueil.init);









/************** BLOC VIDEO/PHOTO HOME****************/



//fonction affichage video
function Affichevideo(id){
		    

 var data = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="240" height="175"			id="cb_embed_player1" name="cb_embed_player1"><param name="movie" value="http://beauvais.fenetre-locale.com//player/jw_smart/player-viral.swf"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><PARAM NAME="autostart" VALUE="true"><param name="flashvars" value="file=http://beauvais.fenetre-locale.com//files/videos/'+id+'.flv&autostart=true"><embed id="cb_embed_player1"		  name="cb_embed_player1"		  src="http://beauvais.fenetre-locale.com//player/jw_smart/player-viral.swf"		  width="240"		  height="175"		  allowscriptaccess="always"		  allowfullscreen="true"		  flashvars="file=http://beauvais.fenetre-locale.com//files/videos/'+id+'.flv&autostart=true"   /></object>';
 
document.getElementById('playervideo').innerHTML = data;

}



//fonction affichage video
function Affichevideo2(id){
	    

 var data = '<object width="240" height="170"><param name="movie" value="http://www.dailymotion.com/swf/video/'+id+'?highlight=%23CA0000&autoPlay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><param name="wmode" value="transparent"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/'+id+'?highlight=%23CA0000&autoPlay=1" width="240" height="170" wmode="transparent" allowfullscreen="true" allowscriptaccess="always"></embed></object>';
 
document.getElementById('playervideo').innerHTML = data;

}


	
//fonction redirection galerie photo
function redir_gal(targ,selObj,restore){
	
	
if ((formulaire.listepages1.selectedIndex != 0)||(formulaire.listepages2.selectedIndex != 0)||(formulaire.listepages3.selectedIndex != 0))
						{
	
	
	 //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;

}

}


//fonction affiche photo ou video sur home
function affich_home_photo()
{
document.getElementById('bvtv').src='img/templates/beauvais/webtv/beauvaistv2.gif';
document.getElementById('bvph').src='img/templates/beauvais/webtv/phototheque2.gif';

document.getElementById('videohome').style.display='none';
document.getElementById('photohome').style.display='inline';

}
    function affich_home_video()
{
document.getElementById('bvtv').src='img/templates/beauvais/webtv/beauvaistv.gif';
document.getElementById('bvph').src='img/templates/beauvais/webtv/phototheque.gif';
document.getElementById('photohome').style.display='none';
document.getElementById('videohome').style.display='inline';

}
	
	
	
	
	/*fonction nuit du bac en direct*/
function ferm_une()
{

 targetElement = document.getElementById("ferm_voeux") ; 
 targetElement.style.display = "none" ;
 
 targetElement = document.getElementById("ferm_une") ; 
 targetElement.style.display = "" ;
	
}

  function ouvrir(fichier) {
  ff=window.open(fichier,"popup",
               "width=400,height=460,left=30,top=20,scrollbars=no") }


