// JavaScript Document

<!--

/*menu gauche*/
function toggleMenu(myItem) {

var myParent = myItem.parentNode;
	if ( myParent.className == 'menu-top-open') {
		myParent.className = 'menu-top-closed';

		for (i=0; i<myParent.childNodes.length;i++) {
		if (myParent.childNodes[i].className == 'ss-menu-open') {
			//alert('check');
			myParent.childNodes[i].className = 'ss-menu-closed';
			}
		}
	}
	else if ( myParent.className == 'menu-top-closed') {
		myParent.className = 'menu-top-open';
	}

var myParent = myItem.parentNode;
	if ( myParent.className == 'menu-open') {
		myParent.className = 'menu-closed';

		for (i=0; i<myParent.childNodes.length;i++) {
		if (myParent.childNodes[i].className == 'ss-menu-open') {
			myParent.childNodes[i].className = 'ss-menu-closed';
			}

		}
	}
	else if ( myParent.className == 'menu-closed') {
		myParent.className = 'menu-open';
	}
}

function changeSsmenu(MySsmenu) {

var myParent = document.getElementById('menuList');

	for (i=0;i<myParent.childNodes.length;i++) {
		if (myParent.childNodes[i].nodeType == 1) {
			var totalLi = myParent.childNodes[i];
				for (t=0;t<myParent.childNodes.length;t++) {
					if (myParent.childNodes[t].nodeType == 1) {
						var mySsMenuParent = myParent.childNodes[t];
						var totalUl = mySsMenuParent;
						for (u=0;u<totalUl.childNodes.length;u++) {
							if (totalUl.childNodes[u].nodeType == 1 && totalUl.childNodes[u].tagName == 'UL') {
							var totalSsMenu = totalUl.childNodes[u];
							for (x=0;x<totalSsMenu.childNodes.length;x++) {
								if ((totalSsMenu.childNodes[x].nodeType == 1)
								&& (totalSsMenu.childNodes[x].tagName == 'LI')) {
									totalSsMenu.childNodes[x].className = 'off';
								}
							}
						}
					}
				}

			}
		}

	}
MySsmenu.className = 'on';


}

function resetSsmenu(myPosition) {
var mySsliste = myPosition.parentNode.childNodes;
	for (g=0;g<mySsliste.length;g++) {
		if (mySsliste[g].tagName == 'UL') {
			var mySilbing = mySsliste[g].childNodes;
			for (a=0;a<mySilbing.length;a++) {
				if (mySilbing[a].nodeType == 1 && mySilbing[a].tagName == 'LI') {
				mySilbing[a].className = 'off';
				//alert(mySilbing[1].tagName);
					if(navigator.appName == "Microsoft Internet Explorer") {
						mySilbing[0].className = 'on';
					}
					else {
						mySilbing[1].className = 'on';
					}

				}
			}
		}
	}
}

function highlightMenuItem(MySsmenu) {

var myParent = document.getElementById('menuList');
	for (i=0;i<myParent.childNodes.length;i++) {
		if (myParent.childNodes[i].nodeType == 1) {
			var totalLi = myParent.childNodes[i];
				for (t=0;t<myParent.childNodes.length;t++) {
					if (myParent.childNodes[t].nodeType == 1) {
						var mySsMenuParent = myParent.childNodes[t];
						var totalUl = mySsMenuParent;
						for (u=0;u<totalUl.childNodes.length;u++) {
							if (totalUl.childNodes[u].nodeType == 1 && totalUl.childNodes[u].tagName == 'UL') {
							var totalSsMenu = totalUl.childNodes[u];
							for (x=0;x<totalSsMenu.childNodes.length;x++) {
								if ((totalSsMenu.childNodes[x].nodeType == 1)
								&& (totalSsMenu.childNodes[x].tagName == 'LI')) {
									var mySibling = totalSsMenu.childNodes[x];
									for (n=0;n<mySibling.childNodes.length;n++) {
										if (mySibling.childNodes[n].tagName == 'UL') {
											var mySsLien = mySibling.childNodes[n];
												for (w=0;w<mySsLien.childNodes.length;w++) {
													if (mySsLien.childNodes[w].className == 'on'){
														mySsLien.childNodes[w].className = 'off';
													}

												}

											}

										}
								}
							}
						}
					}
				}

			}
		}

	}
MySsmenu.className = 'on';

}


/*Show layer according to tabs*/
function showHide(myLayer,myParent,nbOnglet) {
for (t=1;t<=nbOnglet;t++) {
    layers = 'layer'+t;
	document.getElementById(layers).style.display = 'none';
}
document.getElementById(myLayer).style.display = 'block';

var myNav = document.getElementById('form-nav');
for (i=0;i<myNav.childNodes.length;i++) {
	if (myNav.childNodes[i].className == 'tab-on');
	myNav.childNodes[i].className = 'tab';
	}
myParent.parentNode.className = 'tab-on';
}


function showDiv(myDiv) {
document.getElementById(myDiv).style.display = 'block';

}
function hideDiv(myDiv) {
document.getElementById(myDiv).style.display = 'none';

}

/*display panel according to option choice*/
function displayOptionChoice(mySelect) {
var totalOptions = mySelect.options;
	for (i=0;i<totalOptions.length;i++) {
		var totalLayers = (totalOptions[i].getAttribute('value'));
		document.getElementById(totalLayers).style.display = 'none';
	}
document.getElementById(mySelect.options[mySelect.selectedIndex].value).style.display = 'block';
}


/*If checkbox is checked, displays 1 Div*/
function isChecked(myInput,myDiv) {
if (myInput.checked == true) {
	document.getElementById(myDiv).style.display = 'block';
	}
if (myInput.checked == false) {
	document.getElementById(myDiv).style.display = 'none';
	}
}


/*If checkbox is checked, displays 1 Div and hide 1 div */
function isChecked2(myInput,myDiv1,myDiv2) {
if (myInput.checked == true) {
	document.getElementById(myDiv1).style.display = 'block';
	document.getElementById(myDiv2).style.display = 'none';
	}
if (myInput.checked == false) {
	document.getElementById(myDiv1).style.display = 'none';
	document.getElementById(myDiv2).style.display = 'block';
	}
}


function activateSelect(mySelect) {
	document.getElementById(mySelect).disabled = false;
	}
function disactivateSelect(mySelect) {
	document.getElementById(mySelect).disabled = true;
	}

function disableInput(myCheckbox,myInput) {
	if (myCheckbox.checked == true ) {
	document.getElementById(myInput).disabled = true;
	}
	if (myCheckbox.checked == false ) {
	document.getElementById(myInput).disabled = false;
	}

}


/*popup*/
var newWin = null;
function popUp(strURL,strScrollbars) {
if (newWin !== null) {
if(!newWin.closed) {
newWin.close();
}
}
var strOptions="";
strOptions="toolbar=no,menubar=no,scrollbars="+strScrollbars+",resizable,location=no";
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}

function popupResize () {
var pageHeight = document.getElementById('container').offsetHeight;
var pageWidth = document.getElementById('container').offsetWidth;
window.resizeTo(pageWidth+30,pageHeight+50);
document.body.style.backgroundImage = 'none';
}

//Check/Uncheck All checkboxes

function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}

function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}



/*open close panel*/
function togglePanel(myPosition,myPanel) {
var layer = document.getElementById(myPanel);
	if (layer.style.display == 'none') {
		layer.style.display = 'block';
		myPosition.src = '../images/picto-close-panel.gif';
	}
	else if (layer.style.display == 'block') {
		layer.style.display = 'none';
		myPosition.src = '../images/picto-open-panel.gif';
	}
}

/*D?tection du navigateur*/
function navigatorTest(navigatorType) {
	var strChUserAgent = navigator.userAgent;
	var intSplitStart = strChUserAgent.indexOf("(",0);
	var intSplitEnd = strChUserAgent.indexOf(")",0);
	var strChStart = strChUserAgent.substring(0,intSplitStart);
	var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
	var strChEnd = strChUserAgent.substring(strChEnd);

	if(strChMid.indexOf("MSIE 7") != -1 && navigatorType == "ie7")
	   return true;
	else if(strChMid.indexOf("MSIE 6") != -1 && navigatorType == "ie6")
	   return true;
	else if(strChEnd.indexOf("Firefox/2") != -1 && navigatorType == "firefox2")
	   return true;
	else if(strChEnd.indexOf("Firefox") != -1 && navigatorType == "firefox")
	   return true;
	else if(strChEnd.indexOf("Netscape/7") != -1 && navigatorType == "netscape7")
	   return true;
	else if(strChEnd.indexOf("Netscape") != -1 && navigatorType == "netscape")
	   return true;
	else if(strChStart.indexOf("Opera/9") != -1 && navigatorType == "opera9")
	   return true;
	else if(strChStart.indexOf("Opera") != -1 && navigatorType == "opera")
	   return true;
	else
	   return false;
}

/////////////////////////////////////////////Floating div////////////////////////////////////////////////

//------------------------------ATTENTE---------------------------------//
/*Transparent layer that makes the the popup parent window inactive*/
function overlay(popWidth, popHeight) {
	autoPositionLayer(popWidth, popHeight);
	el = document.getElementById("overlay");
    el.style.display = (el.style.display == "block") ? "none" : "block";
	var myPageHeight = document.getElementById('middle').offsetHeight;
	document.getElementById('overlay').style.height = myPageHeight + 200 + 'px';
}

/*Positionnement horizontal et vertical du Div container*/
function autoPositionLayer(popWidth, popHeight) {

	var myLayer = document.getElementById('container');
    var siteHeight = 760;
    var siteWidth = 1075;

	/*Positionnement horizontal du Div container par rapport a la taille de la fenetre*/
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth= window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	var newWidth = windowWidth / 2;
	myLayer.style.top = newWidth + 'px';
    var myContainerWidth = popWidth;
	var myContainerWidthPosition = myContainerWidth / 2;
	myLayer.style.left = newWidth - myContainerWidthPosition + 'px';


	/*Positionnement vertical du Div container par rapport a la taille de la fenetre*/
    var myContainerHeightPosition = (siteHeight - popHeight) / 2;
    if (navigatorTest("ie6")) {
        myLayer.style.marginTop = myContainerHeightPosition + 'px';
    } else {
        myLayer.style.top = myContainerHeightPosition + 'px';
    }
}

/*Reinitialization of Layer position on Window resize event*/
function initLayer() {
	if (document.getElementById('overlay') != "") {
		autoPositionLayer(popWidth, popHeight);
	}
}

//------------------------------POPUP---------------------------------//
/*Transparent layer that makes the the popup parent window inactive*/
function popupWrap(popWidth, popHeight) {
	autoPositionPopup(popWidth, popHeight);
	el = document.getElementById("popupWrap");
    el.style.display = (el.style.display == "block") ? "none" : "block";
	document.getElementById('popupWrap').style.height = 200 + 'px';
}

/*Positionnement horizontal et vertical du Div container*/
function autoPositionPopup(popWidth, popHeight) {

	var myLayer = document.getElementById('containerPopup');
    var siteHeight = 760;
    var siteWidth = 1075;

	/*Positionnement horizontal du Div container par rapport a la taille de la fenetre*/
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth= window.innerWidth;
	} else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		} else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	var newWidth = windowWidth / 2;
	myLayer.style.top = newWidth + 'px';
    var myContainerWidth = popWidth;
	var myContainerWidthPosition = myContainerWidth / 2;
	myLayer.style.left = newWidth - myContainerWidthPosition + 'px';


	/*Positionnement vertical du Div container par rapport a la taille de la fenetre*/
    var myContainerHeightPosition = (siteHeight - popHeight) / 2;
    if (navigatorTest("ie6")) {
        myLayer.style.marginTop = myContainerHeightPosition + 'px';
    } else {
        myLayer.style.top = myContainerHeightPosition + 'px';
    }
}

/*Reinitialization of Layer position on Window resize event*/
function initLayerPopup() {
	if (document.getElementById('popupWrap') != "") {
		autoPositionPopup(popWidth, popHeight);
	}
}
/////////////////////////////////////////////End Floating div////////////////////////////////////////////////


/*show or hide all panels*/
function showAll(myPanel,NbPanels) {
	for (i=0;i<NbPanels;i++) {
		var panel = myPanel + '-' + i;
		//alert(panel);
		if (document.getElementById(panel).style.display == 'none') {
			document.getElementById(panel).style.display = 'block';
		}
	}
}
function hideAll(myPanel,NbPanels) {
	for (i=0;i<NbPanels;i++) {
		var panel = myPanel + '-' + i;
		//alert(panel);
		if (document.getElementById(panel).style.display == 'block') {
			document.getElementById(panel).style.display = 'none';
		}
	}
}



/*Clausier next step*/
function clausierNextStep () {
mySelect =  document.getElementById('clausierType');
var selectedOption = mySelect.options[mySelect.selectedIndex].value;
	if (selectedOption==1) {
		window.location = 'clause-texte-fixe.htm';
	}
	if (selectedOption==2) {
		window.location = 'clause-text-champ-libre.htm';
	}
	if (selectedOption==3) {
		window.location = 'clause-text-champ-prevalorise.htm';
	}
	if (selectedOption==4) {
		window.location = 'clause-text-valeur-heritee.htm';
	}
	if (selectedOption==5) {
		window.location = 'clause-liste-choix-exclusif.htm';
	}
	if (selectedOption==6) {
		window.location = 'clause-liste-choix-cumulatif.htm';
	}
	if (selectedOption==7) {
		window.location = 'clause-tableau-prix.htm';
	}
}


//-->

