﻿var n = navigator.userAgent.toLowerCase();

if (n.indexOf('msie')>=0 && n.indexOf('opera')<0) browser = "explorer"
else if (n.indexOf('gecko')>=0 && !navigator.savePreferences) browser = "mozilla"
else browser = "nav"

if(browser=="nav" || browser=="mozilla") window.addEventListener("resize", redim, true)
else window.onresize = redim;


function redim() {
	
	if(browser == "explorer") {

		/*  n° de la premiere regle */
		var i = 1; 
		/*  nb de regles auquel correspondent les regles 14 et 15 (5 elements par ligne) */
		var nbRegles = 10
		
		/*  collection d'objets faisant reference aux regles de la feuille de style */
		if (document.styleSheets[0].cssRules) {
			/* IE Mac */
			var rl = document.styleSheets[0].cssRules
			}
		else var rl = document.styleSheets[0].rules
		

		/*  taille de la fenetre */
		var h = 0; var v = 0;

		if(document.documentElement && document.documentElement.clientWidth) {
    		/* IE 6+ */
    		h = document.documentElement.clientWidth;
    		v = document.documentElement.clientHeight;
			}
	  	else if(document.body)  {
			/* IE 4 compat */
			h = document.body.clientWidth
			v = document.body.clientHeight
			}
		if(h==0) {
			/* IE 5.0b Mac bugg */
			h = screen.width
			v = screen.height-screen.height/6
			}
			
		/* correction pour prendre en compte la largeur de l'ascensseur d'explorer */
		h = h-17
		}
		
	else{
		var i = 1
		var nbRegles = 2
		var rl = document.styleSheets[0].cssRules

		var h=window.innerWidth
		var v=window.innerHeight
		}
	
	
	/* effets pour limiter les distorsions */
	var l_theor = rapport*v
	var variation = tolerance*h
	var l_reel = h
		
	if(h>(l_theor+variation)) {
		var trop = (h-variation)-l_theor
		var marge_droite = Math.round((trop/3)*2)
		h = h - trop
		}
	else {
		if(h<(l_theor-variation)) {var v = (h+variation)/rapport}
		var marge_droite = 0
		var trop = 0
		}
	
	
	/* calculs */
	var larg1 = Math.round((30/1280)*h)
	var larg2 = Math.round((212/1280)*h)
	var haut1 = Math.round((170/1024)*v)
	var haut2 = Math.round((110/1024)*v)
	
	var haut3 = Math.round((115/1024)*v)
	var haut4 = Math.round((165/1024)*v)
	
	var haut5 = v-(haut1+haut2+haut3+haut4)
	
	var larg3_esp = Math.round(25/1280*h)
	var larg3_cont = Math.round(202/1280*h)
	
	var marge=l_reel-((2*larg1+larg2+2*2)+(larg3_cont*4+larg3_esp*5+(2*2*4))+marge_droite)
	
	
	/* application à la feuille de style */

	/* table */
	rl[i].style.width = marge+"px"
	//rl[i].style.clip = "rect(0px, "+l_reel+"px, "+v+"px, 0px)"

	/* 2e colonne */
	rl[i+1].style.width = ((2*larg1)+larg2)+"px"
	rl[i+1].style.height = haut1+"px"
	
	rl[i+2].style.width = larg1+"px"
	rl[i+2].style.height = haut2+"px"
	
	rl[i+3].style.width = larg2+"px"
	
	rl[i+4].style.height = haut3+"px"
	
	rl[i+5].style.height = haut4+"px"
	
	rl[i+6].style.height = haut5+"px"
	
	/* 3e colonne */
	rl[i+8].style.width = larg3_esp+"px"
	
	rl[i+9].style.width = larg3_cont+"px"

	/* 4e colonne */
	rl[i+13].style.width = marge_droite+"px"

	/* texte */
	taillePol = Math.round(20/1280*h)
	tailleMargin = Math.round(10/1280*h)
	rl[i+14+nbRegles].style.fontSize = taillePol + "px"
	rl[i+14+nbRegles].style.margin = tailleMargin + "px"
	rl[i+15+nbRegles].style.fontSize = taillePol + "px"

	/* img.vignette*/
	rl[i+16+nbRegles].style.width = (larg1*2+larg2+4)+"px"
	rl[i+16+nbRegles].style.height = (Math.round(278/1024*v))+"px"
	if(location.href.indexOf("frame")<=0) rl[i+16+nbRegles].style.left = marge+"px"
	else rl[i+16+nbRegles].style.left = marge+"px"
	rl[i+16+nbRegles].style.top = (haut1+haut2)+"px"
	
	/* img.logo */
	larg_logo = Math.round(310/1280*h)
	haut_logo = Math.round(76/310*larg_logo)
	rl[i+17+nbRegles].style.width = larg_logo+"px"
	rl[i+17+nbRegles].style.height = haut_logo+"px"
	rl[i+17+nbRegles].style.left  = Math.round(marge-(20/1280*h))+"px"
	rl[i+17+nbRegles].style.top = Math.round(haut1 + haut2 - haut_logo - 5)+"px"
		
	/* img.gdlogo */
	larg_gdlogo = l_reel
	haut_gdlogo = (Math.round(340/1280*larg_gdlogo))
	if(haut_gdlogo>haut5) haut_gdlogo = haut5
	if(location.href.indexOf("frame")<=0) rl[i+18+nbRegles].style.left = "0px";
	//else if(browser=="mozilla") rl[i+18+nbRegles].style.left = "0px"
	rl[i+18+nbRegles].style.width = larg_gdlogo +"px"
	rl[i+18+nbRegles].style.height = haut_gdlogo+"px"
	rl[i+18+nbRegles].style.top = (Math.round(v - (haut_gdlogo+10)))+"px"		
	
	/* img.fond  */
	rl[i+19+nbRegles].style.width = ((larg3_esp*5)+(larg3_cont*4)+(2*2*4))+"px"
	rl[i+19+nbRegles].style.height = (haut3+haut4+haut5)+"px"

	/* iframe  */
	rl[i+20+nbRegles].style.width = ((larg3_esp*5)+(larg3_cont*4)+(2*2*4))+"px"
	rl[i+20+nbRegles].style.height = (haut4+haut5)+"px"

	/* choix d'option du menu  */

	if(location.href.indexOf("frame")>0){
		rl[i+21+nbRegles].style.marginTop = (Math.round(haut2*1/4))+"px"
		rl[i+22+nbRegles].style.fontSize = (taillePol)+"px"
		rl[i+22+nbRegles].style.marginBottom = tailleMargin+"px"
		rl[i+22+nbRegles].style.marginLeft = tailleMargin+"px"
		}

	}