
// Fonctions générées par Dreamweaver

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_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 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_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function popUp(strURL,strHeight,strWidth) 
{
  var strOptions="";
  strOptions="scrollbars,resizable,top=40,left=40,height="+strHeight+",width="+strWidth;
  newWin = window.open(strURL, 'newWin', strOptions);
  newWin.focus();
}

function popup(url, width, height) 
{
  var params = "";
  if (width != 0 && height != 0) {
    params = "width=" + width + ",height=" + height + ",resizable=yes,scrollbars=yes";
  } else {
    params = "";
  }
  window.open(url, 'popup', params);
}


/****************************************************************/
/* [gpelletey] Mantis 24455, ajout d'une popunder sur la HPG ASN		*/
/* Fonction popUnder: 			Ouverture d'une popUnder		*/
/* Fonction scanCookie: 		Verifie si cookie existe			*/
/* Fonction loadPopUnderOnce: 	Charge la popUnder une seule fois 	*/
/****************************************************************/
function popUnder(strUrl, strWidth, strHeight) 
{
	var top=(screen.height-strHeight)/2;
	var left=(screen.width-strWidth)/2;
	var params = "";
	
	if (strWidth != 0 && strHeight != 0)
		params = "top="+top+",left="+left+",width="+strWidth+",height="+strHeight+",resizable=no,scrollbars=no";
	else
		params = "";
	
	popunder = window.open(strUrl,"", params);
	popunder.blur();
	window.focus();
}
function scanCookie(variable)
{
	cook = document.cookie;
	variable += "=";
	place = cook.indexOf(variable,0);
	
	if (place <= -1)
		return("0");
	else
	{
		end = cook.indexOf(";",place)
		if (end <= -1)
			return(unescape(cook.substring(place+variable.length,cook.length)));
		else
			return(unescape(cook.substring(place+variable.length,end)));
	}
}
function loadPopUnderOnce()
{
    if(scanCookie("dejapopup")==0)
	{
		popUnder('http://www.agence.francetelecom.com/vf/accueil/popunder/popunder_ipsos.htm', 300, 250);
		setCookieOneDay("dejapopup","oui");
    }
}
/* fin Mantis 24455 */

function changeContact(obj, urlName)
{

	if(urlName!="default")
	{
		window.location.href = urlName;
	}
	else
	  return false;
}

//Validation du formulaire d'identification de l'espace client.
function checkFormIdentEC()
{
    var nameForm = document.formIdentEC;
    if (nameForm.USER.value.length == 0)
    {
      	alert("Vous devez saisir votre identifiant espace client.");
      	nameForm.USER.focus();
      	return false;
    }
    else if (nameForm.PASSWORD.value.length == 0) 
    {
      	alert("Vous devez saisir votre mot de passe espace client.");
      	nameForm.PASSWORD.focus();
      	return false;
    }
    else
    {
        if (nameForm.checkboxSaveId.checked==true)
            setCookie("identEC",nameForm.USER.value);
        else
            delCookie("identEC");
        return true;
    }
}

function initFormIdentEC()
{
    var nameForm = document.formIdentEC;
    var identEC = getCookie("identEC");
    if (identEC.length>0)
    {
        nameForm.USER.value=identEC;
	      nameForm.checkboxSaveId.checked="true";
	  }
}

function getCookie(name) {
	var value = getValueCookie(name);
	return value;
}

function getValueCookie(name) {
   var search = name + "="
   if (document.cookie.length > 0) {
      var offset = document.cookie.indexOf(search)
	  if (offset != -1) {
	    offset += search.length
		end = document.cookie.indexOf(";", offset)
		if (end == -1)
		  end = document.cookie.length
		var value = unescape(document.cookie.substring(offset, end));
		return value;	  }
   }
   return "";
}

function setCookie(name,value)
{
    var expire = new Date();
    var delay = expire.getTime() + (365*24*60*60*1000);
    expire.setTime(delay);
    document.cookie = name + "=" + value + "; expires=" + expire.toGMTString() + "; path=/;";
}

function setCookieOneDay(name,value)
{
    var expire = new Date();
    var delay = expire.getTime() + (24*60*60*1000);
    expire.setTime(delay);
    document.cookie = name + "=" + value + "; expires=" + expire.toGMTString() + "; path=/;";
}

function delCookie(name)
{
    var expire = new Date();
    var delay = expire.getTime() - 1;
    expire.setTime(delay);
    document.cookie = name + "=; expires=" + expire.toGMTString() + "; path=/;";
}

/*	
Mantis 24204 - gpelletey
2004/03/07
ajout fonction lauch_catalogue+lauchwin (nécessaire pour launch_catalogue() ) pour permettre l'ouverture de la popup "catalogue intéractif" PRO sur la page d'accueil
*/

//récuperation des variables définies dans le script d'origine (appli.js)
var WidthCata = 1000;
var HeightCata = 670;
var page = "";
var onglet = "";
var idprod = "";
var urlSuppl = "";
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var dom = (document.getElementById)? true:false;
var DefaultWidth = 1024;
var DefaultHeight = 768;

if (ie4 || dom)
{
	xMax = screen.width;
	yMax = screen.height;
}
else if (ns4)
{
	xMax = window.outerWidth;
	yMax = window.outerHeight;
}
else
{
	xMax = DefaultWidth;
	yMax = DefaultHeight;
}

function launchwin(winurl,winname,winWidth,winHeight)
{
	var xMax, yMax, xOffset, yOffset;
	if (ie4 || dom)
	{
		xMax = screen.width;
		yMax = screen.height;
	}
	else if (ns4)
	{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	}
	else
	{
		xMax = 800;
		yMax = 600;
	}
	xOffset = (xMax - winWidth)/2;
	yOffset = (yMax - winHeight)/2;
	ktawin=window.open(winurl,winname,'width='+winWidth
	+',height='+winHeight
	+',screenX='+xOffset
	+',screenY='+yOffset
	+',top='+yOffset
	+',left='+xOffset
	+',scrollbars=no,resizable=no,status=no,menubar=no');
	ktawin.focus();
}

function launch_catalogue(urlbasekta,param)
{   
	if(!urlbasekta) urlbasekta="appli.htm";
	if (urlbasekta.indexOf("appli")<0) urlbasekta=urlbasekta+"appli.htm";
	if(!param)
	{launchwin(urlbasekta+'?onglet='+onglet+'&page='+page,'catalogue',WidthCata,HeightCata);}
	else
	{launchwin(urlbasekta+'?'+param,'catalogue',WidthCata,HeightCata);}
}

/* fin Mantis 24204 */

//ajout suite à mantis 25728
//fonction crée pour les besoins de refonte du header BDS
//la nouvelle fenetre doit: 	s'ouvrir au 2/3 de la taille de la page
//					paraitre identique a une fenetre habituelle (avec menu, barre url ect...)
function launchNewWin(winurl,winname)
{
	var xMax, yMax, xOffset, yOffset;
	if (ie4 || dom)
	{
		xMax = screen.width;
		yMax = screen.height;
	}
	else if (ns4)
	{
		xMax = window.outerWidth;
		yMax = window.outerHeight;
	}
	else
	{
		xMax = 800;
		yMax = 600;
	}
	//on définie la taille de la popup au 2/3 de la taille de l'ecran
	winWidth = (2*xMax)/3;
	winHeight = (2*yMax)/3;
	
	//on fait en sorte que la popun saffiche au centre
	xOffset = (xMax - winWidth)/2;
	yOffset = (yMax - winHeight)/2;
	ktawin=window.open(winurl,winname,'width='+winWidth
	+',height='+winHeight
	+',screenX='+xOffset
	+',screenY='+yOffset
	+',top='+yOffset
	+',left='+xOffset
	+',scrollbars=yes,resizable=yes,status=yes,menubar=yes,location=yes,toolbar=yes');
	ktawin.focus();
}
//fin Mantis 25728
