﻿function UR_Start() 
{
	UR_Nu = new Date;
	UR_Indhold = UR_Nu.toLocaleDateString()+"<br>"+showFilled(UR_Nu.getHours()) + ":" + showFilled(UR_Nu.getMinutes()) + ":" + showFilled(UR_Nu.getSeconds());
	document.getElementById("ur").innerHTML = UR_Indhold;
	setTimeout("UR_Start()",1000);
	size_body();
}
function showFilled(Value) 
{
	return (Value > 9) ? "" + Value : "0" + Value;
}

function lienActif(){
	var params = extractUrlParams();

		if(!params['page']){
			activerLien('accueil');
		}else{
			if(parametreValide(params['page'])){
				activerLien(params['page']);
			}else{
				alert("Désolé mais l'url saisie n'est pas valide. Vous allez être redirigé");
				window.location = "http://intradev.o2.wan/siteo2new/index.php";
				
			}
		}
	
}

function activerLien(id){
	var image = 'font-size:15px;font-weight:bold;color:navy;';
	var lmt = document.getElementById(id);
	lmt.className="gras";
}

function size_body(){
/*
 * fonction permettant de d'adapter la hauteur du div content2
 * heuteur = hauteur body - hauteur de la banniere
 *
 */
var corps = document.getElementById('div_corps');
var banniere = document.getElementById('banniere');
corps.style.height=document.body.clientHeight-banniere.clientHeight+'px';

}

function align()
{

	var lmt = document.getElementById('centrage');
	var container = document.documentElement;

	if(lmt && container)
	{
	    var containerHeight;
	    if (container.innerWidth)
	    {
            containerHeight = container.innerHeight;
		}
		else
		{
            containerHeight = container.clientHeight;
		}
	    var lmtHeight;
	    if (lmt.innerWidth)
	    {
            lmtHeight = lmt.innerHeight;
		}
		else
		{
            lmtHeight = lmt.offsetHeight;
		}
		var y = Math.ceil((containerHeight - lmtHeight) / 2);
		if(y < 0)
		{
			y = 0;
		}
		lmt.style.position = "relative";
		lmt.style.top = y + "px";
	}
	if (document.getElementById)
	{
		document.body.style.visibility = 'visible';
	}

}

function addevent(obj,evt,fn,capt){
	if(obj.addEventListener)
	{
		obj.addEventListener(evt, fn, capt);
		return true;
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+evt, fn);
		return true;
	}
	else return false;
}

if (document.getElementById && document.getElementsByTagName)
{
	addevent(window, 'load', align, false);
	addevent(window, 'resize', align, false);
}
/*
 * récupère les parametres passés dans l'url dans la variable f.
 * exemple : pour récupérer la valeur de la variable "x" dans l'url : f['x'];
 */
function extractUrlParams(){	
	
	var t = location.search.substring(1).split('&');
	
	var f = [];

	for (var i=0; i<t.length; i++){

		var x = t[ i ].split('=');
		f[x[0]]=x[1];

	}
	return f;

}

function parametreValide(param){
	var liens = document.getElementsByTagName("a");
	var valide = false;
	for (var i=0; i<liens.length; i++){
		if(param==liens.item(i).id){
			valide=true
		}
	}
	return valide;
}