window.onload = function WindowLoad() {
	Menu();
	hoverMenu();
	hover('NavigationUL','li');
	/*Corner('AccesRapide');
	Corner('bloc_5');
	Corner('Inter');
	Corner('NextData');*/
	navigation();
	CornerH('bloc_2');
	CornerOnglet('bloc_3');
	CornerOnglet2('bloc_7'); // scav
	Onglets();
	Ongletdata();
	SousOnglet();
	//HeightBloc('bloc_1');
	HeightBloc('bloc_2');
	HeightBloc('bloc_3');
	HeightBloc('bloc_4');
	HeightBloc('bloc_5');
}

var ns4 = (document.layers)? true:false;   			//NS 4 
var ie4 = (document.all)? true:false;   				//IE 4 
var dom = (document.getElementById)? true:false;   //DOM
var PreloadFlag = false;

function Menu() {
	if(document.getElementById('Menu')) {
		var li = document.getElementById('Menu').getElementsByTagName('li');
		divLeft = document.createElement('div');
		divRight = document.createElement('div');
		li[0].className='CornerLeft';
		li[0].appendChild(divLeft);
		li[li.length-1].className='CornerRight';
		li[li.length-1].appendChild(divRight);
		widthExport = new Array();
		var j = '0';
		for(i=1; i<li.length-1; i++) {
			if(li[i].parentNode.parentNode.tagName=='DIV') {
				if (li[i].getElementsByTagName('ul')[0]) {
					if (dom) var width = li[i].offsetWidth;
					else var width = li[i].clientWidth;
					li[i].getElementsByTagName('ul')[0].style.width =width + 'px';
					li[i].id='id'+j;
					widthExport['id'+j] = new Array();
					widthExport['id'+j].push(width);
					j++;
				}
			}
		}
		var ul = document.getElementById('Menu').getElementsByTagName('ul');
		for(i=1; i<ul.length; i++) {
			if(ul[i].parentNode.parentNode.parentNode.parentNode.parentNode.tagName=='DIV') {
				if (dom) var width = li[i].parentNode.parentNode.offsetWidth;
				else var width = li[i].parentNode.clientWidth;
				ul[i].style.left= widthExport[ul[i].parentNode.parentNode.parentNode.id] - 2  + 'px';
			}
		}
	}
}

function navigation() {
	if(document.getElementById('NavigationUL')) {
		var ul = document.getElementById('NavigationUL').getElementsByTagName('ol'); 
		for(i=0; i<ul.length; i++) {
			var dump = ul[i].innerHTML;
			ul[i].innerHTML ='<li class="top"></li>' + dump + '<li class="bottom"></li>';
		}
	}
}

function hoverMenu() {
	if(document.getElementById('Menu')) {
		var li = document.getElementById('Menu').getElementsByTagName('li');
		for(i=0; i<li.length; i++) {
			if(i!=0 && i!=li.length-1 ) {
				if (navigator.appName == "Microsoft Internet Explorer") {
					li[i].setAttribute("onmouseover",function() { this.className='MouseHover' });
					li[i].setAttribute("onmouseout",function() { this.className='' });
				} else {
					li[i].setAttribute('onmouseover','this.className=\'MouseHover\'');
					li[i].setAttribute('onmouseout','this.className=\'\'');
				} 
			}
		}
	}
}

function hover(id,tag) {
	if(document.getElementById(id)) {
		var li = document.getElementById(id).getElementsByTagName(tag);
		for(i=0; i<li.length; i++) {
			if(li[i].className!="Static") {
				if (navigator.appName == "Microsoft Internet Explorer") {
					li[i].setAttribute("onmouseover",function() { 
						KillAll(); this.className='MouseHover';
					});
					li[i].setAttribute("onmouseout",function() { 
						KillAll(); this.className='';
					});
				} else {
					li[i].setAttribute('onmouseover','KillAll(); this.className=\'MouseHover\';');
					li[i].setAttribute('onmouseout','KillAll(); this.className=\'\';');
				}
			}
		}
	}
}

function KillAll() {
	if(document.getElementById('NavigationUL')) {
		var ul = document.getElementById('NavigationUL').getElementsByTagName('li');
		for(i=0; i<ul.length; i++ ) {
			if(ul[i].parentNode.tagName!='OL' && ul[i].className!="Static") {
				ul[i].className='';
			}
		}
	}
}

function getElementsByClass(maClass) {
	var tabRetour = new Array();
	var tabTmp = new Array();
	tabTmp = document.getElementsByTagName("*");
	j=0;
	for (i=0; i<tabTmp.length; i++) {
		if (tabTmp[i].className.indexOf(maClass)!='-1') {
			tabRetour[j]=tabTmp[i];
			j++;
		}
	}
	return tabRetour;
}

/*function Corner(div) {
	if(getElementsByClass(div)) {
		var GetDiv = getElementsByClass(div);
		for(i=0; i<GetDiv.length; i++) {
			CorderTL = document.createElement('div');
			CorderTR = document.createElement('div');
			CorderBL = document.createElement('div');
			CorderBR = document.createElement('div');
			GetDiv[i].appendChild(CorderTL).className='tl';
			GetDiv[i].appendChild(CorderTR).className='tr';
			GetDiv[i].appendChild(CorderBL).className='bl';
			GetDiv[i].appendChild(CorderBR).className='br';
		}
	}
}*/

function CornerH(div) {
	if(getElementsByClass(div)) {
		var GetDiv = getElementsByClass(div);
		for(i=0; i<GetDiv.length; i++) {
			CorderL = document.createElement('div');
			CorderR = document.createElement('div');
			GetDiv[i].appendChild(CorderL).className='left';
			GetDiv[i].appendChild(CorderR).className='right';
		}
	}
}

function CornerOnglet(div) {
	if(getElementsByClass(div)) {
		var Getborder = getElementsByClass('border');
		var GetDiv = getElementsByClass(div);
		for(i=0; i<GetDiv.length; i++) {
			if (dom) var Fwidth = Getborder[i].offsetWidth;
			else var Fwidth = Getborder[i].clientWidth;
			if (dom) var Hwidth = GetDiv[i].getElementsByTagName('h1')[0].offsetWidth;
			else var Hwidth = GetDiv[i].getElementsByTagName('h1')[0].clientWidth;
			var RightWidth = Fwidth-Hwidth;
			CorderL = document.createElement('div');
			CorderR = document.createElement('div');
			CorderTL = document.createElement('div');
			CorderBR = document.createElement('div');
			CorderBL = document.createElement('div');
			GetDiv[i].appendChild(CorderTL).className='tl';
			GetDiv[i].appendChild(CorderBR).className='br';
			GetDiv[i].appendChild(CorderBL).className='bl';
			
			GetDiv[i].appendChild(CorderL).className='left';
			GetDiv[i].appendChild(CorderR).className='right';
			GetDiv[i].appendChild(CorderR).style.width= RightWidth + 'px';
		}
	}
}

function Onglets() {
	if(document.getElementById('Onglets')) {
		var li = document.getElementById('Onglets').getElementsByTagName('li');
		for(i=0; i<li.length; i++) {
			var Corner = document.createElement('div');
			li[i].appendChild(Corner);
			var Tmpclass=li[i].className;
			li[i].className=Tmpclass + ' Ongletid'+(i+1);
			var Alink = li[i].getElementsByTagName('a')[0];
			if (dom) var Ah = Alink.offsetHeight;
			else  var Ah = Alink.clientHeight;
			var MargTop = (34-Ah)/2;
			Alink.style.marginTop = MargTop + 'px';
			if(i==li.length-1) {
				li[i].getElementsByTagName('div')[0].className='last';
				if(Tmpclass=='last') break;
			}
		}
	}
}

function Ongletdata() {
	if(document.getElementById('Ongletdata')) {
		var div = document.getElementById('Ongletdata');
		CorderL = document.createElement('div');
		CorderR = document.createElement('div');
		div.appendChild(CorderL).className='left';
		div.appendChild(CorderR).className='right';
		var data = document.getElementById('data');
		CorderTL = document.createElement('div');
		CorderTR = document.createElement('div');
		CorderBL = document.createElement('div');
		CorderBR = document.createElement('div');
		data.appendChild(CorderTL).className='tl';
		data.appendChild(CorderTR).className='tr';
		data.appendChild(CorderBL).className='bl';
		data.appendChild(CorderBR).className='br';
		if(document.getElementById('Presentation')) {
			var data2 = document.getElementById('Presentation');
			CorderTL = document.createElement('div');
			CorderTR = document.createElement('div');
			CorderBL = document.createElement('div');
			CorderBR = document.createElement('div');
			data2.appendChild(CorderTL).className='tl';
			data2.appendChild(CorderTR).className='tr';
			data2.appendChild(CorderBL).className='bl';
			data2.appendChild(CorderBR).className='br';
		}
	}
}

function SousOnglet() {
	if(document.getElementById('SsOngletdata')) {
		var li = document.getElementById('SsOngletdata').getElementsByTagName('li');
		for(i=0; i<li.length; i++) {
			var Corner = document.createElement('div');
			if(i==li.length-1) li[i].appendChild(Corner).className='corner last';
			else li[i].appendChild(Corner).className='corner';
			if((li[i].className=='active') && (i>0)) {
				li[i-1].className='corner after';
			}
		}
		var div = document.getElementById('SsOngletdata');
		CorderTL = document.createElement('div');
		CorderTR = document.createElement('div');
		CorderBL = document.createElement('div');
		CorderBR = document.createElement('div');
		div.appendChild(CorderTL).className='tl';
		div.appendChild(CorderTR).className='tr';
		div.appendChild(CorderBL).className='bl';
		div.appendChild(CorderBR).className='br';
	}
}
function HeightBloc(div) {
	if(getElementsByClass(div)) {
		var Ligne = getElementsByClass('Ligne');
		var HeightLigne = new Array();
		for(i=0; i<Ligne.length; i++) {
			if(Ligne[i].className!='Ligne Intro') {
				if(!Ligne[i].id) {
					Ligne[i].id='Ligne'+(i+1);
				}
				HeightLigne.push(Ligne[i].offsetHeight);
			}
		}
		var Fils = getElementsByClass(div);
		for(i=0; i<Fils.length; i++) {
			if(Fils[i].className.indexOf('Ligne')) {
				var ArrayID = Fils[i].parentNode.id.substr(5,5);
				var parentHeight = HeightLigne[ArrayID-1];
				if(div=='bloc_3' || div=='bloc_5') {
					if (navigator.appName == "Microsoft Internet Explorer") var parentHeight = parentHeight - 10;
					else var parentHeight = parentHeight - 15;
					Fils[i].getElementsByTagName('div')[1].style.height=parentHeight - 20 + 'px';
				}
				if(div=='bloc_4') {
					var img = Fils[i].getElementsByTagName('a')[0];
					var marginTOP = (105 - img.offsetHeight)/2;
					var marginLEFT = (140 - img.offsetWidth)/2;
					img.style.marginTop = Math.floor(marginTOP) + 'px';
					img.style.marginLeft = Math.floor(marginLEFT) + 'px';
				}
				
				Fils[i].style.height = parentHeight + 'px';
			}
		}
	}
}

// scav
function CornerOnglet2(div) {
	if(getElementsByClass(div)) {
		var Getborder = getElementsByClass('border');
		var GetDiv = getElementsByClass(div);
		for(i=0; i<GetDiv.length; i++) {

			CorderTR = document.createElement('div');
			CorderTL = document.createElement('div');
			CorderBR = document.createElement('div');
			CorderBL = document.createElement('div');
			
			GetDiv[i].appendChild(CorderTR).className='tr';
			GetDiv[i].appendChild(CorderTL).className='tl';
			GetDiv[i].appendChild(CorderBR).className='br';
			GetDiv[i].appendChild(CorderBL).className='bl';
		}
	}
}
