// menu deroulant compatibilité IE
sfHover = function() {
  var sfEls = document.getElementById("first_level").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
	   sfEls[i].onmouseover=function() {
	       this.className+=" sfhover";
	   }
	   sfEls[i].onmouseout=function() {
	       this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	   }
    }
}

// changements @ homepage
function home(){
	if ( document.getElementById("presentation") != null) {
	   // masque breadcrumb
		if ( document.getElementById("breadcrumb") != null)
      document.getElementById("breadcrumb").style.display = 'none';
		document.getElementById('contents').style.padding='0';
	}
}

// rajoute une image en début de TagName
function puce(tagname, file) {
  var titre = document.getElementById('contents').getElementsByTagName(tagname)
	for(i=0; i<titre.length; i++){
    	titre[i].innerHTML = '<div class="before"><img src="'+file+'"/></div><div class="content">' + titre[i].innerHTML + '</div>';
	}
}

// liens externes en popup
function popup4out() {
    var links = document.getElementsByTagName('a');
    for (var i=0; i<links.length; i++)
    {
        // url vers autre domaine ou vers une ressource
        if ( (links[i].href.indexOf('http://', 0) == 0 && links[i].href.indexOf(location.hostname, 7) == -1) || links[i].className.indexOf('LinkFile') != -1)
        {
            // passe en popup
            links[i].onclick = function() {
                window.open(this.href, '_blank'); return false;
            }
        }
    }
}

// forcing css form... :-/
function formsHelper() {
  var cv = document.getElementById('joindre_votre_cv');
  if (cv != null) {
    // input file en bas
    cv.parentNode.parentNode.style.float = 'none';
    cv.parentNode.parentNode.style.display = 'block';
    cv.parentNode.parentNode.style.clear = 'both';
    var motiv = document.getElementById('prsentez_vos_motivations_et_votre_parcours');
    motiv.parentNode.parentNode.getElementsByTagName('label')[0].style.float = 'none';
    motiv.parentNode.parentNode.getElementsByTagName('label')[0].style.display = 'block';
    motiv.parentNode.parentNode.getElementsByTagName('label')[0].style.width = 'auto';
    // largeur label radios département
    document.getElementById('dpartement17').parentNode.parentNode.getElementsByTagName('label')[0].style.width = 'auto';
  }
  if ( document.getElementById('cart_subscription') != null) {
    // éviter re-saisie
    document.forms[0].adr1.onchange = function() {
      if (this.form.adresse_livraison.value=='')
        this.form.adresse_livraison.value = this.value;
    }
    document.forms[0].cp.onchange = function() {
      if (this.form.cp_livraison.value=='')
        this.form.cp_livraison.value = this.value;
    }
    document.forms[0].ville.onchange = function() {
      if (this.form.ville_livraison.value=='')
        this.form.ville_livraison.value = this.value;
    }
  }
}

// mise en forme
function menu(){
    home();
    puce('h1', '/images/sbs_impression_numerique.gif');
    puce('h3', '/images/sbs_impression_numerique.gif');
}

// chargement des actions
if (window.addEventListener) {
    // methode W3C
    window.addEventListener('load', menu, true)
    window.addEventListener('load', popup4out, true)
    window.addEventListener('load', formsHelper, true)
    if (navigator.Name=='Netscape')
      window.addEventListener('load', sfHover);
} else if (window.attachEvent) {
    // methode Microsoft
    if (navigator.appVersion.indexOf('MSIE')!=-1)
      window.attachEvent('onload', sfHover);
    window.attachEvent('onload', menu)
    window.attachEvent('onload', popup4out)
    window.attachEvent('onload', formsHelper)
}

/* SHOWROOM XEROX --- */
OW_demoflash = function(url_link) {
	window.open(url_link,'_blank','scrollbars=0,width=450,height=300,toolbar=no,location=no,status=no,menubar=no,resizable=no');
}
popup = popUp = function(url, w, h) {
	x=(window.screen.width/2)-(w/2);
	y=(window.screen.height/2)-(h/2);
	window.open(url, '_blank','scrollbars=0,width='+w+',height='+h+',top='+y+',left='+x+', toolbar=no,location=no,status=no,menubar=no,resizable=no');
}
/* --- SHOWROOM XEROX */
