﻿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";
 }
}
addToStart(externalLinks);

window.name = "Garage Normandie Autos";
function win(fileName,largeur,hauteur) 
	{
  window.open(fileName,'',"width=" + largeur + ",height=" + hauteur +",top=" + (screen.height-hauteur)/2 +",left=" + (screen.width-largeur)/2 +",scrollbars=1, status=0, resizable=1");
  }
function winno(fileName,largeur,hauteur) 
	{
  window.open(fileName,'',"width=" + largeur + ",height=" + hauteur +",top=" + (screen.height-hauteur)/2 +",left=" + (screen.width-largeur)/2 +",scrollbars=0, status=0, resizable=0");
  }


//ouvre en popup l'image pass裠en parametre
function DoPopUpPath(imgtoload) 
	{
		wPopup = window.open('', 'img_popup', 'width=300, height=100, top='+(screen.height-30)/2+', left='+(screen.width-200)/2+', status=yes, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, resizable=yes');
		// On 袲it le contenu de la fen鳲e popup
		wPopup.document.clear();
		
		wPopup.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml-dtd/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"><head><meta http-equiv="content-Type" content="text/html; charset=utf-8" /><title>Garage Normandie Autos</title>');
		wPopup.document.write('<style type=\"text/css\">\n'+
		'<!--\n'+
		'body {margin:0; padding:0;}\n}'+
		'img {border:0;}\n'+
		'.conteneur{text-align:center; margin:0; padding:0;}\n'+
		'.chargement{visibility:visible;}\n'+
		'.illustration{visibility:hidden; margin:15px 15px 0 15px;}\n'+
		'.fermer{margin:10px 0 20px 0;}\n'+
		'a { font-family:Arial; font-size: 12px; color:#C22D00; text-decoration: none;}\n'+
		'a:hover {color:#E83700; text-decoration: underline;}\n'+
		'--!>\n'+
		'<\/style>');
		
		wPopup.document.write('</head><body  style="background-color:#F7F7F7; margin:0; padding:0; " onLoad="checkSize();">'); 
		// La fonction qui attend que l'image soit charg裠et affich裠pour redimensionner la fen鳲e �a bonne taille
		wPopup.document.write('<script type="text/javascript"> //<![CDATA[\nfunction checkSize() { if(document.images && document.images[1].complete) { w = document.images[1].width+60; h = document.images[1].height+135; if(h>screen.height) {h=screen.height;hp=screen.height-50}else hp=h; if(w>screen.width) w=screen.width; window.resizeTo(w, hp); window.moveTo((screen.width-w)/2, (screen.height-h)/2); document.images[0].style.display = "none"; document.images[1].style.visibility = "visible"; window.focus();}else { setTimeout("checkSize()", 250); }}\n //]]></'+'script>');
		wPopup.document.write('<div class="conteneur"><img class="chargement" src="images/chargement.gif" alt="chargement" /><img class="illustration" src="' + imgtoload +'" onclick="javascript:self.close();" title="Cliquez pour fermer la fen&ecirc;tre" alt="" /><br /><a href="javascript:self.close();" title="Cliquez pour fermer la fen&ecirc;tre"><br />Fermer la fen&ecirc;tre</a></div>');
		wPopup.document.write('</body></html>');
		wPopup.document.close();
	}
	
function DoPopUp(imgtoload) 
	{
		var wPopup;
				
		// Si la fen鳲e n'existe pas ou est ferm裬 on la r讵vre
		if(!wPopup || wPopup.closed) 
		{
			wPopup = window.open('', 'img_popup', 'width=200, height=100,status=0,scrollbars=0, top='+(screen.height-350)/2+', left='+(screen.width-400)/2);
		}
	
		// On 袲it le contenu de la fen鳲e popup
		wPopup.document.clear();
		wPopup.document.write("<html><head><title>Illustration</title>");
		wPopup.document.write("</HEAD>"); 
		// La fonction qui attend que l'image soit charg裠et affich裠pour redimensionner la fen鳲e �a bonne taille
		wPopup.document.write('<script type="text/javascript">\nfunction checkSize() { if(document.images && document.images[1].complete) { w = (document.images[1].width)+12; h = (document.images[1].height)+30; window.resizeTo(w,h); window.moveTo((screen.width-w)/2, (screen.height-h)/2); document.images[0].style.display = "none"; document.images[1].style.visibility = "visible";this.focus(); }else { setTimeout("checkSize()", 250); }}\n</'+'script>');
		
		wPopup.document.write('<script type="text\/javascript">\n'+
		'function resizeWinTo() {\n'+
		'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
		'var oH = document.images[0].height, oW = document.images[0].width;\n'+
		'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
		'window.doneAlready = true;\n'+ //for Safari and Opera
		'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
		'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
		'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
		'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
		'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
		'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
		'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
		'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
		'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
		'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
		'}\n'+
		'<\/script>');
		
		wPopup.document.write('<body style="background-color:#F7F7F7; margin:0; padding:0; ">');
		wPopup.document.write('<p style="margin:0; padding:0; font-size:0; overflow:hidden; text-align:center; vertical-align:middle;"><img src="images/chargement.gif" alt="" /><img src="' + imgtoload +'" style="margin:0; padding:0; cursor:pointer; visibility:hidden; vertical-align:middle;" alt="" onLoad="checkSize()" onclick="javascript:self.close();" Title="Cliquez pour fermer la fenetre" alt="Cliquez pour fermer la fenetre"/></p>');
		//wPopup.document.write('<div style="position:absolute;left:0px;top:0px;"><img src="images/chargement.gif" alt="" /><img src="' + imgtoload +'" style="margin:0; padding:0; cursor:pointer; visibility:hidden; vertical-align:middle;" alt="" onLoad="checkSize()" onclick="javascript:self.close();" Title="Cliquez pour fermer la fenetre" alt="Cliquez pour fermer la fenetre"/></div>');
		wPopup.document.write('</body></html>');
		wPopup.document.close();
	}
	
//------------------------ Fonctions pour le menu ---------------------------------------------
	function hover(obj,mv){
	  if(document.all)
	  {
	    UL = obj.getElementsByTagName('ul');
	    if(UL.length > 0){
	      sousMenu = UL[0].style;
	      if(sousMenu.display == 'none' || sousMenu.display == ''){
	        sousMenu.display = 'block';
	      }else{
	        sousMenu.display = 'none';
	      }
	    }
	    /*(pour que l'onglet passe dans l'賡t "survol" (et y reste tant qu'on est dans le sous-menu) */
	    /*autre m賨ode : utilisation de onglets=obj.getElementsByTagName('a');  if(onglets.length > 0)  { ong = onglets[0].style; ...*/	    
	    onglets=obj.firstChild;
	    
	    if(onglets)
	    {	      
	    	ong = onglets.style;
				if(onglets.className)
				{
					if(onglets.className.search(/onglet/)!= -1)	
					{
						// survol de l'onglet 
						if(mv=='over')//ong.backgroundPosition == "0px 0px" || ong.backgroundPosition == "")
						{
							ong.background = 'url(images/menu/fond_hover.gif)';
						}
						else
						{
							ong.background = 'url(images/menu/fond.gif)';
						}	
						
					}
	      		      	
	      }
	     }
	    
	  }
	}
	
	function setHover(){
	  LI = document.getElementById('menu').getElementsByTagName('li');
	  nLI = LI.length;
	  for(i=0; i < nLI; i++){
	    LI[i].onmouseover = function(){
	      hover(this,"over");
	    }
	    LI[i].onmouseout = function(){
	      hover(this,"out");
	    }
	  }
	}	
	//script pour cacher tous les sous-menus (par d襡ut ils sont tous visibles au cas ou le JS est d財ctiv种
	function CacheMenus()
	{
		if(document.all)//v豩fication si le navigateur est bien IE ou Op象
		{
			
			//on cache tous les menus
			pt=document.getElementById('menu').getElementsByTagName('ul');
			if(pt.length!=0)
			{	
				for(i=0; i < pt.length; i++)
					pt[i].style.display="none";
			}
		}
		document.getElementById('header').style.marginBottom=0;
	}
