window.onload = init ;
var panier = new Array();
function init()
{
	Chargement();
	ficheOnglet();
	mentionsLegales();
	addActionsToSelect();
	addActionsToCheckbox();
	o_bodyOnLoad(); //Wallgarden
}
function openPopup(url, name, w, h)
{
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=yes');
  win.resizeTo(w, h);
  win.moveTo(wleft, wtop);
  win.focus();
}

function popup(page, width, height)
{
	window.open(page,'', 'resizable=yes, location=no, width='+width + ', height='+ height +', menubar=no, status=no, scrollbars=no, menubar=no');
}

/************************************************************************
* GUIDE MARIE
************************************************************************/
function ajouterGuideMarie()
{
	if(document.getElementById("LA_DialogLayer"))
	{
		var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="200" height="350" align="middle" id="FLASH_DIALOG_ID">';
        flash += '<param name="allowScriptAccess" value="sameDomain" />';
        flash += '<param name="movie" value="../include/marie/Marie_Wanadoo_Dialog.swf" />';
        flash += '<param name="wmode" value="transparent" />';
        flash += '<embed src="../include/marie/Marie_Wanadoo_Dialog.swf" width="200" height="350" align="middle" quality="high" salign="l" wmode="transparent" bgcolor="#ffffff" name="FLASH_DIALOG_ID" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        flash += '</object>';
        document.getElementById("LA_DialogLayer").innerHTML = flash ;
	}
	if(document.getElementById("LA_ProgressBarLayer"))
	{
		var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="175" height="30" align="middle" id="FLASH_PROGRESSBAR_ID">';
		flash += '<param name="allowScriptAccess" value="sameDomain" />';
		flash += '<param name="movie" value="../include/marie/LivingActorProgressBar.swf" />';
		flash += '<param name="wmode" value="transparent" />';
		flash += '<embed src="../include/marie/LivingActorProgressBar.swf" width="175" height="30" align="middle" quality="high" salign="l" wmode="transparent" bgcolor="#ffffff" name="FLASH_PROGRESSBAR_ID" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		flash += '</object>';
        document.getElementById("LA_ProgressBarLayer").innerHTML = flash ;
	}
	if(document.getElementById("LA_ActorLayer"))
	{
		var flash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0" width="162" height="232" id="FLASH_PLAYER_ID">';
		flash += '<param name="allowScriptAccess" value="sameDomain" />';
		flash += '<param name="movie" value="../include/marie/LivingActorPlayer61004.swf" />';
		flash += '<param name="wmode" value="transparent" />';
		flash += '<embed src="../include/marie/LivingActorPlayer61004.swf" width="162" height="232" quality="high" salign="l" wmode="transparent" bgcolor="#ffffff" name="FLASH_PLAYER_ID" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		flash += '</object>';
        document.getElementById("LA_ActorLayer").innerHTML = flash ;
	}
}


/************************************************************************
* PANIER
************************************************************************/
function ajouterAuPanier()
{
	var p = strGenererPanier();
	if (p != "")
		AjouterOffres(p);
}

function ajouterAuPanierForfait(forfait)
{
	panier[0] = forfait;
	if(strGenererPanier() != "")
		AjouterOffres(strGenererPanier());
}

function ajouterAuPanierModem(modem)
{
	panier[1] = modem;
	if(strGenererPanier() != "")
		AjouterOffres(strGenererPanier());
}

function ajouterAuPanierTelephone()
{
	if(panier[1] != null && panier[1] != "")
	{
		AjouterOffres(panier[1]);
		panier[1] = null;
	}
}

function strGenererPanier()
{
	var strPanier = "" ;
	if(panier[0] != null && panier[0] != "")
	{
		strPanier = panier[0] ;
		if (panier[1] != null && panier[1] != "")
		{
			strPanier += "," + panier[1] ;
		}	
	}
	return strPanier;
}

function ajouterALaVariablePanier(offre)
{
	var index = getTypeIndexFromString(offre);
	var id = getIdFromString(offre);
	if(index != null)
	{
		panier[index] = id;
	}
}

function getIdFromString(chaine)
{
	var id = null;
	if(chaine == "1MegaMax") id = 12; 
	else if(chaine == "8MegaMax") id = 13; 
	else if(chaine == "18MegaMax") id = 14; 
	else if(chaine == "8MegaMaxEtudiant") id = 25; 
	else if(chaine == "1MegaMaxEtudiant") id = 26; 
	else if(chaine == "Livebox") id = 48; 
	else if(chaine == "USB") id = 49; 
	else if(chaine == "Ethernet") id = 50; 
	else if(chaine == "LiveboxPro") id = 51; 
	else if(chaine == "USBPro") id = 52; 
	else if(chaine == "EthernetPro") id = 53; 
	else if(chaine == "Router") id = 54; 
	else if(chaine == "fidelite6h") id = 7; 
	else if(chaine == "fidelite30h") id = 8; 
	else if(chaine == "fidelite60h") id = 9; 
	else if(chaine == "fidelite90h") id = 10; 
	else if(chaine == "fideliteIllimite") id = 84; 
	else if(chaine == "basDebit5h") id = 2; 
	else if(chaine == "basDebit25h") id = 3; 
	else if(chaine == "basDebit50h") id = 4; 
	else if(chaine == "basDebit75h") id = 5; 
	else if(chaine == "basDebitIllimite") id = 6; 
	else if(chaine == "fidelite6hPro") id = 32; 
	else if(chaine == "fidelite30hPro") id = 33; 
	else if(chaine == "fidelite60hPro") id = 34; 
	else if(chaine == "fidelite90hPro") id = 35; 
	else if(chaine == "fideliteIllimitePro") id = 36; 
	else if(chaine == "basDebit5hPro") id = 27; 
	else if(chaine == "basDebit25hPro") id = 28; 
	else if(chaine == "basDebit50hPro") id = 29; 
	else if(chaine == "basDebit75hPro") id = 30; 
	else if(chaine == "basDebitIllimitePro") id = 31; 
	else if(chaine == "Visiophone") id = 104; 
	else if(chaine == "Deja") id = null; 
	else if(chaine == "serieLimitee1") id = 114; 
	else if(chaine == "serieLimitee8") id = 115; 
	else if(chaine == "Thomson") id = 111; 
	else if(chaine == "Sagem") id = 117; 
	return id ;
}

function getTypeIndexFromString(chaine)
{
	var id = null;
	if(chaine == "1MegaMax") id = 0; 
	else if(chaine == "8MegaMax") id = 0; 
	else if(chaine == "18MegaMax") id = 0; 
	else if(chaine == "8MegaMaxEtudiant") id = 0; 
	else if(chaine == "1MegaMaxEtudiant") id = 0; 
	else if(chaine == "Livebox") id = 1; 
	else if(chaine == "USB") id = 1; 
	else if(chaine == "Ethernet") id = 1; 
	else if(chaine == "LiveboxPro") id = 1; 
	else if(chaine == "USBPro") id = 1; 
	else if(chaine == "EthernetPro") id = 1; 
	else if(chaine == "Router") id = 1; 
	else if(chaine == "fidelite6h") id = 0; 
	else if(chaine == "fidelite30h") id = 0; 
	else if(chaine == "fidelite60h") id = 0; 
	else if(chaine == "fidelite90h") id = 0; 
	else if(chaine == "fideliteIllimite") id = 0; 
	else if(chaine == "basDebit5h") id = 0; 
	else if(chaine == "basDebit25h") id = 0; 
	else if(chaine == "basDebit50h") id = 0; 
	else if(chaine == "basDebit75h") id = 0; 
	else if(chaine == "basDebitIllimite") id = 0; 
	else if(chaine == "fidelite6hPro") id = 0; 
	else if(chaine == "fidelite30hPro") id = 0; 
	else if(chaine == "fidelite60hPro") id = 0; 
	else if(chaine == "fidelite90hPro") id = 0; 
	else if(chaine == "fideliteIllimitePro") id = 0; 
	else if(chaine == "basDebit5hPro") id = 0; 
	else if(chaine == "basDebit25hPro") id = 0; 
	else if(chaine == "basDebit50hPro") id = 0; 
	else if(chaine == "basDebit75hPro") id = 0; 
	else if(chaine == "basDebitIllimitePro") id = 0; 
	else if(chaine == "Visiophone") id = 1; 
	else if(chaine == "Deja") id = 1; 
	else if(chaine == "serieLimitee1") id = 0; 
	else if(chaine == "serieLimitee8") id = 0; 
	else if(chaine == "Thomson") id = 1; 
	else if(chaine == "Sagem") id = 1; 
	return id ;
}


/**********************************************************************************
/* SELECT
/**********************************************************************************/
function addActionsToSelect()
{
	var selects = document.getElementsByTagName("select");
	for(i=0; i<selects.length; i++)
	{
		// Actions pour un select
		var selectClass =selects[i].className ;
		var selectClasses= selectClass.split(" ");
		for(j=0; j< selectClasses.length; j++)
		{
			if(selectClasses[j] == "URLRedirector")
			{
				selects[i].onchange = function() {
					var url = this.options[this.selectedIndex].value ;
					if(url != "")
						window.location = url ;
				}
			}
			else if(selectClasses[j] == "modemSelectorN1")
			{
				setSelectDefault(selects[i]);
				selects[i].onchange = function() {
					bindSelectToDiv(this, "modem");
					bindSelectToDiv(this, "detailModem");
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(selectClasses[j] == "modemSelectorN2")
			{
				setSelectDefault(selects[i]);
				selects[i].onchange = function() {
					bindSelectToDiv(this, "modem");
					bindSelectToDiv(this, "detailModem");
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(selectClasses[j] == "selectVisiophone")
			{
				setSelectDefault(selects[i]);
				selects[i].onchange = function() {
					bindSelectToDiv(this, "detailModem");
					ajouterALaVariablePanier(this.value);
				}
			}
		}	
	}
}

// Permet de lier les options d'une SELECT à un ensemble de div
// Pour chaque option, il doit exister une div avec pour id : idDiv + select.options[i]
function bindSelectToDiv(select, idDiv)
{
	var selectedValue = select.options[select.selectedIndex].value ;
	if (selectedValue == "") return false;
	for(i=0; i < select.options.length; i++)
	{
		var currentValue = select.options[i].value ;
		if(currentValue != "")
		{
			if (!document.getElementById(idDiv + currentValue))
				return false;
			if(currentValue == selectedValue)
			{
				document.getElementById(idDiv + currentValue).style.display = "block";
			}
			else 
			{
				document.getElementById(idDiv + currentValue).style.display = "none";
			}
		}
	}
	return true;
}

// Masque toutes les divs idDiv associées aux valeurs d'une liste de choix select
function hideAllDivsFromSelect(select, idDiv)
{
	for(i=0; i < select.options.length; i++)
	{
		var currentValue = select.options[i].value ;
		if(currentValue != "")
		{
			if (!document.getElementById(idDiv + currentValue))
				return false;
			document.getElementById(idDiv + currentValue).style.display = "none";
		}
	}
	return true;
}

// Retourne un objet HTML SELECT de classe CSS myClass
function getSelectByClassName(myClass)
{
	var selects = document.getElementsByTagName("select");
	for(i=0; i<selects.length; i++)
	{
		// Actions pour un select
		var selectClass =selects[i].className ;
		var selectClasses= selectClass.split(" ");
		for(j=0; j< selectClasses.length; j++)
		{
			if(selectClasses[j] == myClass)
				return selects[i];
		}
	}
	return null;
}

// Applique les valeurs des modems dans la liste de choix pour l'offre myValue
function setModemValuesFor(myValue)
{
	if(myValue == "1MegaMax")
	{
		var modemSelectorN1 = getSelectByClassName("modemSelectorN1");
		if(modemSelectorN1)
		{
			hideAllDivsFromSelect(modemSelectorN1, "modem");
			hideAllDivsFromSelect(modemSelectorN1, "detailModem");
			modemSelectorN1.options.length = 0;
			modemSelectorN1.options[0] = new Option("livebox", "Livebox");
			modemSelectorN1.options[1] = new Option("modem ethernet", "Ethernet");
			modemSelectorN1.options[2] = new Option("modem USB", "USB");
			modemSelectorN1.options[3] = new Option("J'ai d\351j\340 un modem", "Deja");
			setSelectDefault(modemSelectorN1);
			bindSelectToDiv(modemSelectorN1, "modem");
			bindSelectToDiv(modemSelectorN1, "detailModem");
		}
	}
	else if(myValue == "8MegaMax")
	{
		var modemSelectorN1 = getSelectByClassName("modemSelectorN1");	
		if(modemSelectorN1)
		{
			hideAllDivsFromSelect(modemSelectorN1, "modem");
			hideAllDivsFromSelect(modemSelectorN1, "detailModem");
			modemSelectorN1.options.length = 0;
			modemSelectorN1.options[0] = new Option("livebox", "Livebox");
			modemSelectorN1.options[1] = new Option("modem ethernet", "Ethernet");
			modemSelectorN1.options[2] = new Option("J'ai d\351j\340 un modem", "Deja");
			setSelectDefault(modemSelectorN1);
			bindSelectToDiv(modemSelectorN1, "modem");
			bindSelectToDiv(modemSelectorN1, "detailModem");
		}
	}
	else if(myValue == "18MegaMax")
	{
		var modemSelectorN1 = getSelectByClassName("modemSelectorN1");
		if(modemSelectorN1)
		{
			hideAllDivsFromSelect(modemSelectorN1, "modem");
			hideAllDivsFromSelect(modemSelectorN1, "detailModem");
			modemSelectorN1.options.length = 0;
			modemSelectorN1.options[0] = new Option("livebox", "Livebox");
			modemSelectorN1.options[1] = new Option("J'ai d\351j\340 un modem", "Deja");
			setSelectDefault(modemSelectorN1);
			bindSelectToDiv(modemSelectorN1, "modem");
			bindSelectToDiv(modemSelectorN1, "detailModem");
		}
	}
	else if(myValue == "8MegaMaxEtudiant")
	{
		var modemSelectorN1 = getSelectByClassName("modemSelectorN1");	
		if(modemSelectorN1)
		{
			hideAllDivsFromSelect(modemSelectorN1, "modem");
			hideAllDivsFromSelect(modemSelectorN1, "detailModem");
			modemSelectorN1.options.length = 0;
			modemSelectorN1.options[0] = new Option("livebox", "Livebox");
			modemSelectorN1.options[1] = new Option("modem ethernet", "Ethernet");
			modemSelectorN1.options[2] = new Option("J'ai d\351j\340 un modem", "Deja");
			setSelectDefault(modemSelectorN1);
			bindSelectToDiv(modemSelectorN1, "modem");
			bindSelectToDiv(modemSelectorN1, "detailModem");
		}
	}
	else if(myValue == "1MegaMaxEtudiant")
	{
		var modemSelectorN1 = getSelectByClassName("modemSelectorN1");
		if(modemSelectorN1)
		{
			hideAllDivsFromSelect(modemSelectorN1, "modem");
			hideAllDivsFromSelect(modemSelectorN1, "detailModem");
			modemSelectorN1.options.length = 0;
			modemSelectorN1.options[0] = new Option("livebox", "Livebox");
			modemSelectorN1.options[1] = new Option("modem Ethernet", "Ethernet");
			modemSelectorN1.options[2] = new Option("modem usb", "USB");
			modemSelectorN1.options[3] = new Option("J'ai d\351j\340 un modem", "Deja");
			setSelectDefault(modemSelectorN1);
			bindSelectToDiv(modemSelectorN1, "modem");
			bindSelectToDiv(modemSelectorN1, "detailModem");
		}
	}
}

// Selectionne dans la liste de choix la premiere valeur non nulle
function setSelectDefault(select)
{
	var indexByDefault = 0;
	while(select.options[indexByDefault].value == "")
		indexByDefault++;
	select.selectedIndex = indexByDefault;
	ajouterALaVariablePanier(select.options[select.selectedIndex].value);
}

/**********************************************************************************
/* CHECKBOX
/**********************************************************************************/

function addActionsToCheckbox()
{
	var checkbox = getAllCheckbox();
	for(i=0; i < checkbox.length; i++)
	{
		var checkboxClass =checkbox[i].className ;
		var checkboxClasses= checkboxClass.split(" ");
		for(j=0; j< checkboxClasses.length; j++)
		{
			if(checkboxClasses[j] == "forfaitHDN1")
			{
				if(checkbox[i].checked == true)
				{
					ajouterALaVariablePanier(checkbox[i].value);
				}
				else
				{
					checkbox[i].checked = false;
				}
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					bindCheckboxToSelect(this);
					bindCheckboxToDiv(this, "detailForfait") ;
					ajouterALaVariablePanier(this.value);
					bindCheckboxToSingleDiv(this, "btAjoutPanier") ;
				}
			}	
			else if(checkboxClasses[j] == "forfaitBDFideliteN1")
			{
				if(!checkbox[i].checked == "checked")
					checkbox[i].checked= false;
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(checkboxClasses[j] == "forfaitBDN1")
			{
				if(!checkbox[i].checked == "checked")
					checkbox[i].checked= false;
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(checkboxClasses[j] == "forfaitBDN2")
			{
				if(!checkbox[i].checked == "checked")
					checkbox[i].checked= false;
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					bindCheckboxToDiv(this, "detail") ;
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(checkboxClasses[j] == "ficheSerieLimitee")
			{
				if(checkbox[i].checked == true)
				{
					ajouterALaVariablePanier(checkbox[i].value);
				}
				else
				{
					checkbox[i].checked = false;
				}
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					bindCheckboxToDiv(this, "prix") ;
					bindCheckboxToDiv(this, "detail") ;
					ajouterALaVariablePanier(this.value);
				}
			}
			else if(checkboxClasses[j] == "ficheTelephone")
			{
				if(!checkbox[i].checked == "checked")
				{
					checkbox[i].checked= false;
				}
				if(checkbox[i].checked)
					ajouterALaVariablePanier(checkbox[i].value);
				checkbox[i].groupName = checkboxClasses[j] ;
				checkbox[i].onclick = function() {
					uncheckAllButThis(this);
					bindCheckboxToDiv(this, "prix") ;
					bindCheckboxToDiv(this, "detail") ;
					if(this.checked)
						ajouterALaVariablePanier(this.value);
					else panier[1] = null;
				}
			}
		}
	}
}

// Permet de lier une Checkbox à une liste de choix
function bindCheckboxToSelect(myCheckbox)
{
	var myClass = myCheckbox.className;
	var classes= myClass.split(" ");
	for(i=0; i< classes.length; i++)
	{
		if(classes[i] == "forfaitHDN1")
		{
			var select = getSelectByClassName("modemSelectorN1");
			setModemValuesFor(myCheckbox.value);
		}
	}
}

// Permet de lier une Checkbox à une liste de div
// Il doit exister une div avec pour id : idDiv + checkbox.value
function bindCheckboxToDiv(myCheckbox, idDiv)
{
	var currentValue = myCheckbox.value;
	hideAllDivsFromCheckbox(myCheckbox,idDiv);
	if(document.getElementById(idDiv + currentValue))
	{
		if(myCheckbox.checked)
			document.getElementById(idDiv + currentValue).style.display = "block";
		else
			document.getElementById(idDiv).style.display = "block";
		return true;
	}
	return false;
}

// Permet de lier une Checkbox à une simple div
// Elle s'affiche si la case est cochée
function bindCheckboxToSingleDiv(myCheckbox, idDiv)
{
	if(myCheckbox.checked)
	{
		document.getElementById(idDiv).style.display = "block";
	}
	else
	{
		document.getElementById(idDiv).style.display = "none";
	}
	return true;
}

// Renvoie toutes les checkbox sur la page
function getAllCheckbox()
{
	// On recupere tous les inputs, puis toutes les checkbox
	var inputs = document.getElementsByTagName("input");
	var checkbox = new Array();
	for(i=0; i < inputs.length; i++)
		if(inputs[i].type == "checkbox")
			checkbox.push(inputs[i]);
	return checkbox;
}

// Decoche toutes les checkbox sauf myCheckbox
function uncheckAllButThis(myCheckbox)
{
	var checkbox = getCheckboxByClassName(myCheckbox.groupName);
	for(i=0; i < checkbox.length; i++)
	{
		if(checkbox[i] != myCheckbox)
			checkbox[i].checked = false;
	}
}

// Renvoie les checkbox de la classe myClass
function getCheckboxByClassName(myClass)
{
	var checkbox = getAllCheckbox();
	var checkboxByClass = new Array();
	for(i=0; i<checkbox.length; i++)
	{
		var checkboxClass =checkbox[i].className ;
		var checkboxClasses= checkboxClass.split(" ");
		for(j=0; j< checkboxClasses.length; j++)
		{
			if(checkboxClasses[j] == myClass)
				checkboxByClass.push(checkbox[i]);
		}
	}
	return checkboxByClass;
}

// Masque toutes les divs idDiv associées aux valeurs de checkbox de classes myCheckboxClass
function hideAllDivsFromCheckbox(myCheckbox, idDiv)
{
	var checkbox = getCheckboxByClassName(myCheckbox.groupName);
	for(i=0; i < checkbox.length; i++)
	{
		var currentValue = checkbox[i].value ;
		if(currentValue != "")
		{
			if (!document.getElementById(idDiv + currentValue))
				return false;
			document.getElementById(idDiv + currentValue).style.display = "none";
		}
	}
	if(document.getElementById(idDiv) != null)
		document.getElementById(idDiv).style.display = "none";
	return true;
}


/************************************************************************
* SELECT										_deprecated 26/05/2006 
************************************************************************/
/* Fonction d'ajout d'un modem via une liste de choix */ 
function selectModem()
{
	if(document.getElementById("selectModem") != null)
	{
		var select = document.getElementById("selectModem") ;
		var indexParDefaut = 0;
		while(select.options[indexParDefaut].value == "")
			indexParDefaut++;
		select.selectedIndex = indexParDefaut;
		ajouterModem(select.options[indexParDefaut].value);
		select.onchange = function() {
				ajouterModem(this.value)
			};
	}
}

function ajouterModem(modem)
{	
	panier[1] = getIdFromString(modem);
	if(modem != "" && document.getElementById("selectModem") != null)
	{
		var select = document.getElementById("selectModem") ;
		for(i=0; i < select.length; i++)
		{
			var modemSelect = select.options[i].value + "";
			if(modemSelect != "")
			{
				if(modemSelect == modem) /* Modem choisi */
				{
					document.getElementById("modem" + modem).style.display = "block"; 
					document.getElementById("detailModem" + modem).style.display = "block";
					document.getElementById("imgModem").src = "http://images.eto.fr/abonnez-vous/img/hd/accueilHD" + modem + ".jpg" ;
					document.getElementById("imgModem").alt = modem;
					document.getElementById("imgModem").title = modem;
				}
				else /* Les autres modems */
				{
					document.getElementById("modem" + modemSelect).style.display = "none"; 
					document.getElementById("detailModem" + modemSelect).style.display = "none";
				}
			}
		}
	}
		var select = document.getElementById("selectVisiophone") ;
	if (modem != "" && document.getElementById("selectVisiophone") != null)
	{
		var select = document.getElementById("selectVisiophone") ;
		for(i=0; i < select.length; i++)
		{
			var modemSelect = select.options[i].value + "";
			if(modemSelect != "")
			{
				if(modemSelect == modem) /* Modem choisi */
				{
					document.getElementById("modem" + modem).style.display = "block"; 
					document.getElementById("detailModem" + modem).style.display = "block";
				}
				else /* Les autres modems */
				{
					document.getElementById("modem" + modemSelect).style.display = "none"; 
					document.getElementById("detailModem" + modemSelect).style.display = "none";
				}
			}
		}
	}
}

/************************************************************************
* SELECT (REDIRECTION)								_deprecated 26/05/2006
************************************************************************/
function redirectionVersFicheProduit() {
    configurerSelect(document.getElementById('promoModemUSB'));
    configurerSelect(document.getElementById('promoModemEthernet'));
    configurerSelect(document.getElementById('promoLivebox'));   
    configurerSelect(document.getElementById('promoOffre'));   
    
    if(document.getElementById('lienDecouvrir') != undefined)
        document.getElementById('lienDecouvrir').href = "javascript:lien()";
}

function configurerSelect(select) {
    if(select != undefined && select.tagName == "SELECT")
        select.onchange = 
        function() {
            parent.location = select.value ;
        }
}

function redirect(page)
{
    parent.location = page;
}

function lien()
{
    if(document.getElementById('selectLivebox') != undefined)
    {
		if(document.getElementById('selectLivebox').value != "")
			redirect(document.getElementById('selectLivebox').value);
    }
    if(document.getElementById('promoOffre') != undefined)
    {
		if(document.getElementById('promoOffre').value != "")
			redirect(document.getElementById('promoOffre').value);
    }
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


/************************************************************************
* CHECKBOX										_deprecated 26/05/2006
************************************************************************/
/* Fonction d'ajout d'un forfait via une suite de checkbox */ 
function checkboxForfait()
{
	var inputs = document.getElementsByTagName("input");
	var checkbox = new Array();
	for (i=0; i < inputs.length; i++)
	{
		if (inputs[i].type == "checkbox" && inputs[i].className == "checkbox forfait")
			checkbox.push(inputs[i]);
	}
	for (i=0; i < checkbox.length; i++)
	{
		checkbox[i].checked = false;
		checkbox[i].onclick = function() {
				ajouterForfait(this); 
			};
	}
}

function ajouterForfait(chkbForfait)
{
	panier[0] = getIdFromString(chkbForfait.value);
	var inputs = document.getElementsByTagName("input");
	var noCheck = false; 
	for (i=0; i < inputs.length; i++)
	{
		if (inputs[i].type == "checkbox" && inputs[i].className == "checkbox forfait")
		{
			var checkbox = inputs[i] ;
			var forfait = checkbox.value ; 
			if (checkbox.value != chkbForfait.value)
			{
				checkbox.checked = false;
				document.getElementById("detailForfait" + forfait).style.display = "none"; 
			}
			else
			{
				if(!checkbox.checked)
				{
					panier[0]= "";
					document.getElementById("detailForfait" + forfait).style.display = "none"; 
				}
				else 
				{
					noCheck =true;
					document.getElementById("detailForfait" + forfait).style.display = "block"; 
				}
			}
		}
	}
	if (noCheck == false)
	{
		document.getElementById("detailForfaitAucun").style.display = "block"; 
		document.getElementById("btAjoutPanier").style.display = "none"; 
	}
	else 
	{
		document.getElementById("detailForfaitAucun").style.display = "none"; 
		document.getElementById("btAjoutPanier").style.display = "block"; 
	}
}


/* Fonction d'ajout d'un forfait via une suite de checkbox POUR LE BAS DEBIT */ 
function checkboxForfaitBD()
{
	var inputs = document.getElementsByTagName("input");
	var checkbox = new Array();
	for (i=0; i < inputs.length; i++)
	{
		if (inputs[i].type == "checkbox" && inputs[i].className == "checkbox forfaitBD")
			checkbox.push(inputs[i]);
	}
	for (i=0; i < checkbox.length; i++)
	{
		checkbox[i].checked = false;
		checkbox[i].onclick = function() {
				ajouterForfaitBD(this); 
			};
	}
}

function ajouterForfaitBD(chkbForfait)
{
	panier[0] = getIdFromString(chkbForfait.value);
	var inputs = document.getElementsByTagName("input");
	for (i=0; i < inputs.length; i++)
	{
		if (inputs[i].type == "checkbox" && inputs[i].className == "checkbox forfaitBD")
		{
			if (inputs[i].value != chkbForfait.value)
				inputs[i].checked = false;
			else if(!inputs[i].checked)
				panier[0]= "";
		}
	}
}


/************************************************************************
* [+] ONGLETS N-2 
************************************************************************/
function ficheOnglet()
{
	masquerTousLesOnglets();
	var i = 1;
	var onglets = new Array();
	while (document.getElementById("ficheOnglet" + i) != undefined)
	{
		var div = document.getElementById("showOnglet" + i);
		div.id = i ;
		div.onclick = function() { 
					changerPictoPlusMoins(this);
					changerTitreTexte(this);
					changerOnglet(this.id);
			} ;
		i++;
	}
}

function changerPictoPlusMoins(source)
{
	if(source.style.backgroundImage.search("pictoMoins.gif") > 0)
		source.style.backgroundImage = "url(http://images.eto.fr/abonnez-vous/img/commun/pictoPlus.gif)";
	else source.style.backgroundImage = "url(http://images.eto.fr/abonnez-vous/img/commun/pictoMoins.gif)";
}

function changerTitreTexte(source)
{
	if(source.style["color"] == "#ff6600" || source.style["color"] == "rgb(255, 102, 0)")
		source.style["color"] = "#9a9a9a";
	else source.style["color"] = "#ff6600";
}

function changerOnglet(i)
{
	var div = "contenuFicheOnglet" + i;
	if(isVisible(div))
		masquerOnglet(div);
	else afficherOnglet(div);
}

function masquerTousLesOnglets()
{
	var i = 1;
	while (document.getElementById("contenuFicheOnglet" + i) != undefined)
	{
		masquerOnglet("contenuFicheOnglet" + i);
		i++;
	}
}

function afficherOnglet(div)
{
	document.getElementById(div).style.display = "block";
}

function masquerOnglet(div)
{
	document.getElementById(div).style.display = "none";
}

function isVisible(div)
{
	if(document.getElementById(div).style.display == "none")
		return false;
	else return true;
}

/************************************************************************
* MENTIONS LEGALES
************************************************************************/
function mentionsLegales()
{
	masquerToutesLesMentions();
	if (document.getElementById("showMentions") != undefined)
	{
		var mentions = document.getElementById("showMentions") ;
		mentions.style.width = (mentions.offsetWidth - 40) + "px";
		mentions.onclick = afficherMentions ;
		mentions.onmouseover =  function() { changerTitreTexteSouligne(mentions);} ;
		mentions.onmouseout =  function() { changerTitreTexteSouligne(mentions);} ;
	}
}

function masquerToutesLesMentions()
{
	if (document.getElementById("ficheMention") != undefined)
		document.getElementById("ficheMention").style.display = "none" ;
}

function afficherMentions()
{
	var div = "ficheMention";
	if (document.getElementById("showMentions"))
	{
		var mentions = document.getElementById("showMentions") ;
	    changerPictoPlusMoins(mentions); 
		if(isVisible(div))
		{
			masquerOnglet(div);
		}
		else 
		{
			afficherOnglet(div);
		}
	}
}

function changerTitreTexteSouligne(source)
{
	if(source.style["color"] == "#ff6600" || source.style["color"] == "rgb(255, 102, 0)")
	{
		source.style["color"] = "#333333";
		source.style["textDecoration"] = "none";
	}
	else 
	{
		source.style["color"] = "#ff6600";
		source.style["textDecoration"] = "underline";
	}
}



/************************************************************************
* MENU
************************************************************************/
function len(s) 
{

    if (document.getElementById) 
    {
        var rulerSpan = document.getElementById("ruler");
        rulerSpan.innerHTML = s;
        return(rulerSpan.offsetWidth);   
    }
    
}


var detect = navigator.userAgent.toLowerCase();
function Chargement() 
{
var margingtop = -3;
var margingleft = -2;
var i=1;
var j=0;
var longueur=0;

    if (checkIt('safari'))
    {
            var margingtop = 2;
    }

    while (document.getElementById("SousMenu" + i)!= undefined){
          with(document.getElementById("SousMenu"+i).style) {
            j=0;
            longueur=document.getElementById("Menu" + i).offsetWidth - margingleft;
            position="absolute";
            top = (document.getElementById("Menu"+i).offsetHeight+findPosY(document.getElementById("Menu"+i))+margingtop)+"px";
	        left = (findPosX(document.getElementById("Menu"+i))+margingleft)+"px";
            margin="0";
            padding="0";
            zIndex="3";
                while (document.getElementById("SousMenu" + i).childNodes[j] != undefined)
                {
                    if (longueur < len(document.getElementById("SousMenu" + i).childNodes[j].id)+9)
                    {
                        longueur = len(document.getElementById("SousMenu" + i).childNodes[j].id)+9;
                    }
                    j++;
                }
                
            width = longueur+"px";
            }
           i++;
          len("");
          }
    CacherMenus();
  }


var ssmenuwidth ="";
function MontrerMenu(strMenu) {

  CacherMenus(); 
 // document.getElementById(strMenu).style.display="block";
        
    // test si c'est un menu actif
	/**
    if (document.getElementById(strMenu).className=="ssmenu hide active")
    {
            // si oui, descendre le ssmenu de 1px
            ssmenuwidth=strMenu;
            var topW = findPosY(document.getElementById(ssmenuwidth));
            topW+=1;
            document.getElementById(ssmenuwidth).setAttribute("top","300px");
            document.getElementById(strMenu).style.top=top;
            alert(document.getElementById(strMenu).style.top);
    }  */
}

function CacherMenus() {

    if (ssmenuwidth!="")
    {
            // remonter le ssmenu qui a été descendu de 1px
            var topW = findPosY(document.getElementById(ssmenuwidth));
            topW-=1;
            document.getElementById(ssmenuwidth).setAttribute("top","2250px");
            document.getElementById(ssmenuwidth).style.top=top;
            ssmenuwidth="";
    }

var i=1;
while (document.getElementById("SousMenu" + i)!= undefined)
        {
        document.getElementById("SousMenu"+i).style.display="none";
         i++;
        }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function redirectionVersFicheProduit() {
    configurerSelect(document.getElementById('promoModemUSB'));
    configurerSelect(document.getElementById('promoModemEthernet'));
    configurerSelect(document.getElementById('promoLivebox'));   
    configurerSelect(document.getElementById('promoOffre'));   
    
    if(document.getElementById('lienDecouvrir') != undefined)
        document.getElementById('lienDecouvrir').href = "javascript:lien()";
}

function configurerSelect(select) {
    if(select != undefined && select.tagName == "SELECT")
        select.onchange = 
        function() {
            parent.location = select.value ;
        }
}

function redirect(page)
{
    parent.location = page;
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
