// JavaScript Document

<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function TCM_Refresh_Top_And_Left() {
	with (navigator) if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		alert(window.innerWidth);
		if(document.layers) { alert(document.layers["menu1"].left);}
	}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,d,obj,args=MM_showHideLayers.arguments;
  d='inline';
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; d=(v=='visible')?'inline':(v=='hidden')?'none':d; }
    else {d=(v=='show')?'inline':(v=='hide')?'none':d; }
    obj.visibility=v; 
    obj.display=d;}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
IE = navigator.appName=="Microsoft Internet Explorer";
NS = navigator.appName=="Netscape";
bVer = parseInt(navigator.appVersion);

var newWin=null;

function popup(loc, name, width, height) {
        var _params = "width="+width+",height="+height+",resizable=no,status=no,scrollbars=yes";

        // BROWSERS QUI SUPPORTENT JAVASCRIPT 1.2
        if (bVer >= 4) {
                 _left = ( (screen.width-width) >>1 );
                 _top = ( (screen.height-height) >>1 );
        } else {
                 _left = ( (800-width) >>1 );
                 _top = ( (600-height) >>1 );
        }

        if (IE) _params += ",top=" + _top + ",left=" + _left;
        else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;

        newWin = window.open(loc, name, _params);
        if ( newWin!=null && !(IE && bVer<5) )
                newWin.focus(); // MSIE4 PAS DE FOCUS WINDows
}

function popupHome(loc, name, width, height) {
        var _params = "width="+width+",height="+height+",resizable=no,status=no,scrollbars=no";

        // BROWSERS QUI SUPPORTENT JAVASCRIPT 1.2
        if (bVer >= 4) {
                 _left = ( (screen.width-width) >>1 );
                 _top = ( (screen.height-height) >>1 );
        } else {
                 _left = ( (800-width) >>1 );
                 _top = ( (600-height) >>1 );
        }

        if (IE) _params += ",top=" + _top + ",left=" + _left;
        else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;

        newWin = window.open(loc, name, _params);
        if ( newWin!=null && !(IE && bVer<5) )
                newWin.focus(); // MSIE4 PAS DE FOCUS WINDOWS
}
function popupsites(loc, name, width, height) {
        var _params = "width="+width+",height="+height+",resizable=no,status=no,scrollbars=yes";

        // BROWSERS QUI SUPPORTENT JAVASCRIPT 1.2
        if (bVer >= 4) {
                 _left = ( (screen.width-width) >>1 );
                 _top = ( (screen.height-height) >>1 );
        } else {
                 _left = ( (800-width) >>1 );
                 _top = ( (600-height) >>1 );
        }

        if (IE) _params += ",top=" + _top + ",left=" + _left;
        else if (NS) _params += ",screenX=" + _left + ",screenY=" + _top;

        newWin = window.open(loc, name, _params);
        if ( newWin!=null && !(IE && bVer<5) )
                newWin.focus(); // MSIE4 PAS DE FOCUS WINDOWS
}

function chg_prix(theForm)
	{
	var tempo = theForm.select.options(theForm.select.selectedIndex).value;
	var sep = tempo.indexOf("|"); 
	var conso = tempo.substring(0, sep);
	var moteur = tempo.substring(sep+1, tempo.length);
	if (moteur=='D')
		theForm.textfield2.value =  '';//'0.78';
	if (moteur=='E')
		theForm.textfield2.value =  ''; //'0.99';
	}

function calcul(theForm)
{
	var s = "";
	var result;
	var tempo = theForm.select.options(theForm.select.selectedIndex).value;
	var sep = tempo.indexOf("|"); 
	var conso = tempo.substring(0, sep);
	var moteur = tempo.substring(sep+1, tempo.length);
	result=parseFloat(theForm.select.options(theForm.select.selectedIndex).value) * parseFloat(theForm.textfield.value) * parseFloat(theForm.textfield2.value) / 100;
	//result=parseFloat(conso) * parseFloat(theForm.textfield.value) * parseFloat(theForm.textfield2.value) / 100;
	
	if (!isNaN(result))
		{
			s = "" + result;
			dotpos = s.indexOf('.');
			fix = result//s.slice(0,dotpos + 3);
			fix = FormatNumber(fix,2,true,true);
			//fix = s / 100;
			MM_findObj("resulteuro").innerHTML = fix + ' &euro;';
			MM_findObj("text_result").style.display = "inline";
		}
	else
		{
			MM_findObj("resulteuro").innerHTML = '';
			MM_findObj("text_result").style.display = "none";
		}
			
}

function FormatNumber(num, decimalNum, bolLeadingZero, bolParens)
   /* IN - num:            the number to be formatted
           decimalNum:     the number of decimals after the digit
           bolLeadingZero: true / false to use leading zero
           bolParens:      true / false to use parenthesis for - num

      RETVAL - formatted number
   */
   {
       var tmpNum = num;

       // Return the right number of decimal places
       tmpNum *= Math.pow(10,decimalNum);
       tmpNum = Math.floor(tmpNum);
       tmpNum /= Math.pow(10,decimalNum);

       var tmpStr = new String(tmpNum);

       // See if we need to hack off a leading zero or not
       if (!bolLeadingZero && num < 1 && num > -1 && num !=0)
           if (num > 0)
               tmpStr = tmpStr.substring(1,tmpStr.length);
           else
               // Take out the minus sign out (start at 2)
               tmpStr = "-" + tmpStr.substring(2,tmpStr.length);                        


       // See if we need to put parenthesis around the number
       if (bolParens && num < 0)
           tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")";


       return tmpStr;
   }

function readCookie(name) {
	var cookieValue = "";
	var search = name + "=";
	if(document.cookie.length > 0)   { 
		offset = document.cookie.indexOf(search);
		if (offset != -1)     { 
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1) end = document.cookie.length;
			cookieValue = unescape(document.cookie.substring(offset, end))
		}
	}
	return cookieValue;
}
function writeCookie(name, value, hours) {
	var expire = "";
	var path = ";path=/";
	if(hours != null)   {
		expire = new Date((new Date()).getTime() + hours * 3600000);
		expire = "; expires=" + expire.toGMTString();
	}
	document.cookie = name + "=" + escape(value) + expire + path;
}


function popupUnder() {
	//alert((readCookie('peugeot_satisfaction') == langue));
	var langue = 'fr';
	var txtUrl = document.location.href;
	if (txtUrl.indexOf('/fr/') != -1) langue = 'fr';
	if (txtUrl.indexOf('/en/') != -1) langue = 'en';
	
	//Parametre permettant d'activer [1] ou desactiver [0] l'enquete de satisfaction.
	var bool = 1;
	
	if(bool) {
	    // on regarde si le cookie est prsent
	    if (readCookie('peugeot_satisfaction') == langue) {
	        return;
	    } else {
	        // on cre un cookie ayant une dure de vie de 20 jours (=24*20=480 heures)
	        writeCookie('peugeot_satisfaction', langue, 480);
	    
	        // Window.onunload = function(){ if(self.screenTop>9000)window.open('http://www.yahoo.fr',null, null) }
	        window.open('/satisfaction/default.aspx?lng='+langue ,'satisfaction','width=480,height=550', true);
	        window.focus();
	    }
	}
}


//-->