// JavaScript Document

function PopupCentrerNl(page,nom,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,nom,'top='+top+',left='+left+',width='+largeur+',height='+hauteur+','+options);
}
/********************************************************
*  EXTERNAL LINK
********************************************************/
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 } 
}


/********************************************************
*  NAVHOVER
********************************************************/

navHover = function() {
	var lis = document.getElementById("navigation").getElementsByTagName("LI");
	for (var i=0; i<lis.length; i++) {
		lis[i].onmouseover=function() {
			this.className+=" iehover";
		}
		lis[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}


/********************************************************
*  SLIDE NEWS
********************************************************/


var boxHeight
var repeatHeight
var stopScroll = 0
var x

function scrollMe() {
	clearTimeout(x)
	if(stopScroll==1) {
		return
	}
	$('highlights').scrollTop=$('highlights').scrollTop+1
	if($('highlights').scrollTop<=repeatHeight) {
		// keep on scrolin' 
		x = setTimeout("scrollMe()",40)
	}
	else { //we have hit the wrap point
		$('highlights').scrollTop=0
		x = setTimeout("scrollMe()",40)
	}
}

function start_scrollMe(start_frame, end_frame, delay){
	if($('highlights'))
	{
		boxHeight 		=	$('highlights').style.height.replace('px','')
		repeatHeight 	=	$('highlights').scrollHeight
		$('highlights').innerHTML = $('highlights').innerHTML + $('highlights').innerHTML
		x = setTimeout("scrollMe()",1000);
	}
}


// scroll the element vertically based on its width and the slider maximum value
function scrollVertical(value, element, slider) {
	element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
}
// scroll the element horizontally based on its width and the slider maximum value
function scrollHorizontal(value, element, slider) {
	element.scrollLeft = Math.round(value/slider.maximum*(element.scrollWidth-element.offsetWidth));
}


var flagActu=false;

function scrollDivActu()
{
	// disable vertical scrolling if text doesn't overflow the div
	if ($("scrollable1").scrollHeight <= $("scrollable1").offsetHeight) {
		/*slider_i.setDisabled();*/
		$("scrollable1").style.height = "auto";
		$("track1").hide();
	}
	else
	{
		$("autresActus").style.width = "510px";
		$("scrollable1").style.height = "150px";
		$("track1").show();
	}
	
	// vertical slider control
	var sliderActu = new Control.Slider("handle1", "track1", {
		axis: "vertical",
		onSlide: function(v) { scrollVertical(v, $("scrollable1"), sliderActu);  },
		onChange: function(v) { scrollVertical(v, $("scrollable1"), sliderActu); }
	});
	
	flagActu=true;
}

function scrollDivContent()
{
	// disable vertical scrolling if text doesn't overflow the div
	if ($("scrollable2").scrollHeight <= $("scrollable2").offsetHeight) {
		/*slider_i.setDisabled();*/
		$("track2").hide();
	}
	else
	{
		$("track2").show();
	}
	
	// vertical slider control
	var sliderContent = new Control.Slider("handle2", "track2", {
		axis: "vertical",
		onSlide: function(v) { scrollVertical(v, $("scrollable2"), sliderContent);  },
		onChange: function(v) { scrollVertical(v, $("scrollable2"), sliderContent); }
	});
	
}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function lightwindowGo(src,myTitle){
		myLightWindow.activateWindow({ href: src, width:603, height:473, title: myTitle});
		
	}

Event.observe(window, 'load', externalLinks, false);




