function initIndex() {
	if("" == document.getElementById("idProduct").value){
		switch(document.getElementById("sectionName").value){
			// news
			case "news":
				loadNews('', 0);
				break;

			// enterprise
			case "enterprise":
				loadEnterprise('', 1);
				break;

			// intranet_
			case "intranet_":
				loadIntranet();
				break;

			// services
			case "services":
				loadService('', 0);
				break;

			// psychology
			case "psychology":
				loadPsychology('', 1);
				break;

			// special
			case "special":
				loadSpecial('', 0);
				break;

			// form_
			case "form_":
				loadContact('form',0);
				break;

			// contact
			case "contact":
				loadContact('',0);
				break;

			// ""
			case "":
				loadHome();
				break;

		}

		//loadHome();
		//loadNews('', 0);
		//loadEnterprise('', 0);
		//loadProduct(1, '', '', 1, '', '', '', 0, 0);
		//loadIntranet();
		//loadService('', 0);
		//loadPsychology('', 0);
		//loadSpecial('', 0);
		//loadContact('form',0);
		//loadContact('',1);
	}else{
		idProduct = document.getElementById("idProduct").value
		index = getIndex(idProduct, '', '', 0, 0);
		idParent = getParentProduct(idProduct);

		loadProduct(1, idParent, idProduct, index, '', '', '', 0, 0);
	}
}

/*
 **********************************************
 ****************** FUNCTION ******************
 **********************************************
*/

function setNewProduct(visible){
	document.getElementById("divNewProduct").style.visibility = visible;
}

function setMenuClassName(sectionSelect){

	document.getElementById("sectionHome").className = "menu";
	document.getElementById("sectionNews").className = "menu";
	document.getElementById("sectionEnterprise").className = "menu";
	document.getElementById("sectionProduct").className = "menu";
	document.getElementById("sectionIntranet").className = "menu";
	document.getElementById("sectionService").className = "menu";
	document.getElementById("sectionPsychology").className = "menuSpecial";
	document.getElementById("sectionSpecial").className = "menu";
	document.getElementById("sectionForm").className = "menu";
	document.getElementById("sectionContact").className = "menu";

	document.frm.sectionSelect.value = sectionSelect;
	if("sectionPsychology" == document.frm.sectionSelect.value)
		className = "menuSpecialSelect";
	else
		className = "menuSelect";

	document.getElementById(sectionSelect).className = className

	if("sectionHome" == document.frm.sectionSelect.value)
		document.getElementById("divPlayer").style.display = "";
	else
		document.getElementById("divPlayer").style.display = "none";
}

function setCategoryMenuClassName(nameCategory){
	image_language = document.getElementById('image_language').value;
	document.getElementById("categorySelect").value = "";
	document.getElementById("produits_grands").src = "images/produits_grands" + image_language + ".jpg";
	document.getElementById("produits_petits").src = "images/produits_petits" + image_language + ".jpg";
	document.getElementById("produits_famille").src = "images/produits_famille" + image_language + ".jpg";
	document.getElementById("produits_accessoires").src = "images/produits_accessoires" + image_language + ".jpg";
	document.getElementById("produits_mobilier").src = "images/produits_mobilier" + image_language + ".jpg";
	document.getElementById("produits_complements").src = "images/produits_complements" + image_language + ".jpg";

	if("" != nameCategory){
		document.getElementById("categorySelect").value = nameCategory;
		document.getElementById(nameCategory).src = "images/" + nameCategory + image_language + "_hover.jpg";
	}
}

function setProductOffertClassName(nameCategory){
	image_language = document.getElementById('image_language').value;
	document.getElementById("productOffert").src = "images/Simexco_section_1_02.jpg";
	document.getElementById("productOffert").style.display = "none";
	if("" != nameCategory){
		document.getElementById("productOffert").style.display = "";
		document.getElementById("productOffert").src = "images/" + nameCategory + image_language + "_offert.jpg";
	}
}

function setSection3ClassName(index){
	for(i=0; i <= document.getElementById("nbSection3").value; i++){
		if(document.getElementById("listSection3" + i)){
			document.getElementById("listSection3" + i).className = "menu";
			if(i == index)
				document.getElementById("listSection3" + i).className = "menuSelect";
		}
	}
}

function setSection3ProductClassName(index){
	for(i=0; i<=document.getElementById("nbSection3").value; i++){
		if(document.getElementById("listSection3Product" + i)){
			document.getElementById("listSection3Product" + i).className = "menuProduct";
			if(i == index)
				document.getElementById("listSection3Product" + i).className = "menuProductSelect";
		}
	}
}

function setTdTitleHeight(){
	if(document.getElementById("tdTitle"))
		if(34 < document.getElementById("tdTitle").clientHeight)
			document.getElementById("divSectionText").style.height = "231";
		else if(17 < document.getElementById("tdTitle").clientHeight)
			document.getElementById("divSectionText").style.height = "248";
}

function setTdProductHeight(){
	height = 1;
	height = height + 10;
	height = height + 60;
	height = height + 10;

	if(document.getElementById("tdTitle")){
		height = height + document.getElementById("tdTitle").clientHeight;
		if(34 < document.getElementById("tdTitle").clientHeight){
			height = height - 1;
		}
	}

	height = height + 10;

	if(document.getElementById("tdBullet")){
		if(1 != document.getElementById("tdBullet").clientHeight){
			height = height + document.getElementById("tdBullet").clientHeight;
		}
	}

	height = height + 10;

	height = 377 - height;

	document.getElementById("divSectionText").style.height = height + "px";
	document.getElementById("divProductText").style.height = height + "px";
}

function enterPageSearch(e){
	if(window.event)
        //IE
        key = window.event.keyCode;
	else if(e)
	    //firefox
	    key = e.which;

	if (key == 13){
		loadSearch();
		//return !(window.event && window.event.keyCode == 13);
		return false;
	}
}

/*
 ******************************************
 ****************** HOME ******************
 ******************************************
*/

function loadHome() {
	loadAllSection = true;
	if("sectionHome" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionHome");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionHome1");
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.run();

	if(loadAllSection){
		// section 2
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex2");
		newsRequest.setParameters("userAction=sectionHome2");
		newsRequest.setLoadingHtml(loadingHtmlSection2);
		newsRequest.run();

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionHome3");
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}
	load_tooltips();
}

/*
 ******************************************
 ****************** NEWS ******************
 ******************************************
*/

function loadNews(id, index) {
	loadAllSection = true;
	if("sectionNews" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionNews");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	idNews = "";
	if("" != id)
		idNews = id;
	else{
		idFirst = getFirstIdNews();

		if(null !=idFirst & "" != idFirst){
			idNews = idFirst;
		}
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionNews1&idNews=" + idNews);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionNews2&idNews=" + idNews);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionNews3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);

}

function getFirstIdNews() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdNews");
	newsRequest.run();
	return newsRequest.getValue();
}

/*
 ************************************************
 ****************** ENTERPRISE ******************
 ************************************************
*/

function loadEnterprise(id, index) {
	loadAllSection = true;
	if("sectionEnterprise" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionEnterprise");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	idEnterprise = "";
	if("" != id)
		idEnterprise = id;
	else{
		idFirst = getFirstIdEnterprise();

		if(null !=idFirst & "" != idFirst){
			idEnterprise = idFirst;
		}
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionEnterprise1&idEnterprise=" + idEnterprise);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionEnterprise2&idEnterprise=" + idEnterprise);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionEnterprise3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);

	expandEnterpriseTree(index);

}

function getFirstIdEnterprise() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdEnterprise");
	newsRequest.run();
	return newsRequest.getValue();
}

function expandEnterpriseTree(id){
	for(i=0; i<=document.getElementById("nbSection3").value; i++)
		if(document.getElementById("tree" + i))
			document.getElementById("tree" + i).style.display = "none";

	if(document.getElementById("tree" + id))
		document.getElementById("tree" + id).style.display = "";

}

/*
 *************************************************
 ****************** REALISATION ******************
 *************************************************
*/

function loadEnterpriseRealisation(id, index) {
	idRealisation = id;

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionEnterpriseRealisation1&idRealisation=" + idRealisation);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionEnterpriseRealisation2&idRealisation=" + idRealisation);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	// set section3 className
	setSection3ClassName(index);

}

/*
 *********************************************
 ****************** PROJECT ******************
 *********************************************
*/

function loadEnterpriseProject(id, index) {
	idProject = id;

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionEnterpriseProject1&idProject=" + idProject);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionEnterpriseProject2&idProject=" + idProject);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	// set section3 className
	setSection3ClassName(index);

}

/*
 *********************************************
 ****************** PRODUCT ******************
 *********************************************
*/

function loadProduct(loadAll, idParent, idProduct, index, idCategory, nameCategory, search, isNew, isStar) {

	if(document.getElementById("divSectionText"))
		document.getElementById("divSectionText").style.height = "1px";
	if(document.getElementById("divProductText"))
		document.getElementById("divProductText").style.height = "1px";

	loadAllSection = true;
	if(0 == loadAll)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionProduct");

	// set category menu className
	setCategoryMenuClassName(nameCategory);

	// set product offert className
	setProductOffertClassName(nameCategory);

	if("" == search)
		document.getElementById("search").value = "";

	if("" == idProduct){
		idProduct = getFirstIdProduct(idCategory, search, isNew, isStar);
		idParent = idProduct;
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionProduct1");
	newsRequest.setLoadingHtml(loadingHtml);
	//newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.setWait(false);
	newsRequest.run();

	if("" != idProduct){
		// section title
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divProductTitle");
		newsRequest.setParameters("userAction=divProductTitle&idProduct=" + idProduct);
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();

		// section bullet
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divProductBullet");
		newsRequest.setParameters("userAction=divProductBullet&idProduct=" + idProduct);
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();

		// section text
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divProductText");
		newsRequest.setParameters("userAction=divProductText&idProduct=" + idProduct);
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	setTdProductHeight();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionProduct2&idProduct=" + idProduct + "&idCategory=" + idCategory);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// set category menu className
		setCategoryMenuClassName(nameCategory);

		// set product offert className
		setProductOffertClassName(nameCategory);

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionProduct3&idCategory=" + idCategory + "&search=" + search + "&isNew=" + isNew + "&isStar=" + isStar);
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3Product className
	setSection3ProductClassName(index);

	// set section3 className
	setSection3ClassName(index);

	// expand tree
	expandTree(index);

	// if parent
	if("" != idParent){
		indexParent = getIndex(idParent, idCategory, search, isNew, isStar);

		if(index != indexParent)
			// expand tree
			expandTree(indexParent);
	}
}

function loadProductTree(idParent, idProduct, index, idCategory) {

	if(document.getElementById("divSectionText"))
		document.getElementById("divSectionText").style.height = "1px";
	if(document.getElementById("divProductText"))
		document.getElementById("divProductText").style.height = "1px";

	// section title
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divProductTitle");
	newsRequest.setParameters("userAction=divProductTitle&idParent=" + idParent + "&idProduct=" + idProduct);
	newsRequest.setWait(false);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.run();

	// section bullet
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divProductBullet");
	newsRequest.setParameters("userAction=divProductBullet&idProduct=" + idProduct);
	newsRequest.setWait(false);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.run();

	// section text
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divProductText");
	newsRequest.setParameters("userAction=divProductText&idParent=" + idParent + "&idProduct=" + idProduct);
	newsRequest.setWait(false);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.run();

	setTdProductHeight();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionProduct2&idProduct=" + idProduct + "&idCategory=" + idCategory);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	// set section3Product className
	setSection3ProductClassName(index);

	// set section3 className
	setSection3ClassName(index);
}

function getFirstIdProduct(idCategory, search, isNew, isStar) {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdProduct&idCategory=" + idCategory + "&search=" + search + "&isNew=" + isNew + "&isStar=" + isStar);
	newsRequest.run();
	return newsRequest.getValue();
}

function getIndex(id, idCategory, search, isNew, isStar) {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=indexProduct&idProduct=" + id + "&idCategory=" + idCategory + "&search=" + search + "&isNew=" + isNew + "&isStar=" + isStar);
	newsRequest.run();
	return newsRequest.getValue();
}

function getParentProduct(idProduct) {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=parentProduct&idProduct=" + idProduct);
	newsRequest.run();
	return newsRequest.getValue();
}

function loadSearch(){
	document.getElementById("categorySelect").value = "";
	loadProduct(1, '', '', 1, '', '', document.getElementById("search").value, 0, 0);
}

function expandTree(id){
	for(i=0; i<=document.getElementById("nbSection3").value; i++)
		if(document.getElementById("tree" + i))
			document.getElementById("tree" + i).style.display = "none";

	if(document.getElementById("tree" + id))
		document.getElementById("tree" + id).style.display = "";

}

function loadStarProduct(idParent, idProduct){
	index = getIndex(idProduct, '', '', 0, 0);
	//loadProduct(1, idParent, idProduct, index, '', '', '', 0, 1);
	loadProduct(1, idParent, idProduct, index, '', '', '', 1, 0);
}

/*
 **********************************************
 ****************** INTRANET ******************
 **********************************************
*/

function loadIntranet() {

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionIntranet");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionIntranet1");
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionIntranet2");
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	// section 3
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex3");
	newsRequest.setParameters("userAction=sectionIntranet3");
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.run();

}

/*
 *********************************************
 ****************** SERVICE ******************
 *********************************************
*/

function loadService(id, index) {
	loadAllSection = true;
	if("sectionService" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionService");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	idService = "";
	if("" != id)
		idService = id;
	else{
		idFirst = getFirstIdService();

		if(null !=idFirst & "" != idFirst){
			idService = idFirst;
		}
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionService1&idService=" + idService);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionService2&idService=" + idService);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionService3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);

}

function getFirstIdService() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdService");
	newsRequest.run();
	return newsRequest.getValue();
}

/*
 ************************************************
 ****************** PSYCHOLOGY ******************
 ************************************************
*/

function loadPsychology(id, index) {
	loadAllSection = true;
	if("sectionPsychology" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionPsychology");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	idPsychology = "";
	if("" != id)
		idPsychology = id;
	else{
		idFirst = getFirstIdPsychology();

		if(null !=idFirst & "" != idFirst){
			idPsychology = idFirst;
		}
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionPsychology1&idPsychology=" + idPsychology);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionPsychology2&idPsychology=" + idPsychology);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionPsychology3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);

	// expand tree
	expandPsychologyTree(index);

}

function getFirstIdPsychology() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdPsychology");
	newsRequest.run();
	return newsRequest.getValue();
}

function expandPsychologyTree(id){
	for(i=0; i<=document.getElementById("nbSection3").value; i++)
		if(document.getElementById("tree" + i))
			document.getElementById("tree" + i).style.display = "none";

	if(document.getElementById("tree" + id))
		document.getElementById("tree" + id).style.display = "";

}

/*
 **********************************************************
 ****************** SOUS-TEXT PSYCHOLOGY ******************
 **********************************************************
*/

function loadPsychologyPsychology(id, index) {
	idPsychology = id;

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionPsychologyPsychology1&idPsychology=" + idPsychology);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionPsychologyPsychology2&idPsychology=" + idPsychology);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	// set section3 className
	setSection3ClassName(index);

}

/*
 *********************************************
 ****************** SPECIAL ******************
 *********************************************
*/

function loadSpecial(id, index) {
	loadAllSection = true;
	if("sectionSpecial" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	// set menu className
	setMenuClassName("sectionSpecial");

	// set category menu className
	setCategoryMenuClassName("");

	// set product offert className
	setProductOffertClassName("");

	idSpecial = "";
	if("" != id)
		idSpecial = id;
	else{
		idFirst = getFirstIdSpecial();

		if(null !=idFirst & "" != idFirst){
			idSpecial = idFirst;
		}
	}

	// section 1
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex1");
	newsRequest.setParameters("userAction=sectionSpecial1&idSpecial=" + idSpecial);
	newsRequest.setLoadingHtml(loadingHtml);
	newsRequest.setFunctionAfter(setTdTitleHeight);
	newsRequest.run();

	// section 2
	var newsRequest = new SimpleRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setTargetID("divIndex2");
	newsRequest.setParameters("userAction=sectionSpecial2&idSpecial=" + idSpecial);
	newsRequest.setLoadingHtml(loadingHtmlSection2);
	newsRequest.run();

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionSpecial3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);

}

function getFirstIdSpecial() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdSpecial");
	newsRequest.run();
	return newsRequest.getValue();
}

/*
 *************************************************
 ****************** FORMCONTACT ******************
 *************************************************
*/

// if form == id load formulaire
function loadContact(id, index) {
	loadAllSection = true;
	if("sectionForm" == document.frm.sectionSelect.value | "sectionContact" == document.frm.sectionSelect.value)
		loadAllSection = false;

	// set newProduct
	setNewProduct("visible");

	idContact = "";
	if("form" == id){
		// set menu className
		setMenuClassName("sectionForm");

		// set category menu className
		setCategoryMenuClassName("");

		// set product offert className
		setProductOffertClassName("");

		// section 1
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex1");
		newsRequest.setParameters("userAction=sectionForm1");
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.setFunctionAfter(setTdTitleHeight);
		newsRequest.run();

		// section 2
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex2");
		newsRequest.setParameters("userAction=sectionForm2");
		newsRequest.setLoadingHtml(loadingHtmlSection2);
		newsRequest.run();

	}else{
		// set menu className
		setMenuClassName("sectionContact");

		// set category menu className
		setCategoryMenuClassName("");

		// set product offert className
		setProductOffertClassName("");

		if("" != id)
			idContact = id;
		else{
			idFirst = getFirstIdContact();

			if(null !=idFirst & "" != idFirst){
				idContact = idFirst;
			}
		}

		// section 1
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex1");
		newsRequest.setParameters("userAction=sectionContact1&idContact=" + idContact);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.setFunctionAfter(setTdTitleHeight);
		newsRequest.run();

		// section 2
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex2");
		newsRequest.setParameters("userAction=sectionContact2&idContact=" + idContact);
		newsRequest.setLoadingHtml(loadingHtmlSection2);
		newsRequest.run();
	}

	if(loadAllSection){

		// section 3
		var newsRequest = new SimpleRequest();
		newsRequest.setActionPhp("indexAction.php");
		newsRequest.setTargetID("divIndex3");
		newsRequest.setParameters("userAction=sectionContact3");
		newsRequest.setWait(false);
		newsRequest.setLoadingHtml(loadingHtml);
		newsRequest.run();
	}

	// set section3 className
	setSection3ClassName(index);
}

function getFirstIdContact() {
	var newsRequest = new SimpleValueRequest();
	newsRequest.setActionPhp("indexAction.php");
	newsRequest.setParameters("userAction=firstIdContact");
	newsRequest.run();
	return newsRequest.getValue();
}
