//*********************************
//VARIABLES ***********************
//*********************************
var currentRubriqueArray = new Array();
var rubriqueNiveauId2 = "0_0_0";
//*********************************
//CLASSE RUBRIQUE *****************
//*********************************
function rubrique(){
	this.alias = arguments[0];
	this.url = arguments[1];
	this.forceopen = arguments[2];
	this.niveau1 = arguments[3];
	this.niveau2 = arguments[4];
	this.niveau3 = arguments[5];
	if(typeof this.niveau2 == 'undefined') this.niveau2 = 0;
	if(typeof this.niveau3 == 'undefined') this.niveau3 = 0;
}

function getAlias(){
	return this.alias;
}
rubrique.prototype.getAlias = getAlias;

function getUrl(){
	return this.url;
}
rubrique.prototype.getUrl = getUrl;

function getForceOpen(){
	return this.forceopen;
}
rubrique.prototype.getForceOpen = getForceOpen;

function getNiveau1(){
	return this.niveau1;
}
rubrique.prototype.getNiveau1 = getNiveau1;

function getNiveau2(){
	return this.niveau2;
}
rubrique.prototype.getNiveau2 = getNiveau2;

function getNiveau3(){
	return this.niveau3;
}
rubrique.prototype.getNiveau3 = getNiveau3;

function getNiveauId(){
	return this.niveau1 + "_" + this.niveau2 + "_" + this.niveau3;
}
rubrique.prototype.getNiveauId = getNiveauId;

function getNiveau(){
	var result;
	if(this.getNiveau2() + this.getNiveau3() == 0){
		result = 1;
	}else if(this.getNiveau3() == 0){
		result = 2;
	}else{
		result = 3;
	}

	return result;
}
rubrique.prototype.getNiveau = getNiveau;

function hasChild(niveau){
	var tmpCurrentRubriqueArray = currentRubriqueArray;
	alert(niveau + tmpCurrentRubriqueArray.length);
	
	for(i=0;i<tmpCurrentRubriqueArray.length;i++){
		/*tmprubrique = tmpCurrentRubriqueArray[i];
		//alert(i + " - " + tmprubrique.getNiveauId() +" == " + this.getNiveauId() + "-" + this.getAlias());
		if(tmprubrique.getNiveauId() == this.getNiveauId()){
			//alert(i);
			if(i < tmpCurrentRubriqueArray.length-1){
				j = i+1;
				//alert(j);
				if(tmpCurrentRubriqueArray[j].getNiveau() == niveau-1){
					
				}
			}
		}*/
	}
}
rubrique.prototype.hasChild = hasChild;

function getParent(niveau){
	var tmpCurrentRubriqueArray = currentRubriqueArray;
	alert(niveau + tmpCurrentRubriqueArray.length);

}
rubrique.prototype.getParent = getParent;
//*********************************
//*********************************

//*********************************
//FONCTIONS AFFICHAGE *************
//*********************************
function mhHover(obj,className){
	//return;
	if(obj == null) return;
	obj.className = className;
}

//*********************************
//*********************************

//*********************************
//FONCTIONS NAVIGATION PRINCIPALE**
//*********************************
// BLOC1 : NIVEAU1
function getItemNavBloc1HtmlNiveau1(tmprubrique,etat,rubriqueArray,rubriqueNiveauId){
	var result = "";
	var result_div3 = "";
	var etatInv = "";
	
	if(etat == "on"){
		etatInv = "off";
	}else{
		etatInv = "on";
	}
	result += "<div id='bloc1rub"+tmprubrique.getNiveau1()+"' style='position: absolute; overflow: hidden; height:40px; z-index:1"+tmprubrique.getNiveau1()+"'> ";
	result += "<table border='0' cellspacing='0' cellpadding='0'>";
	result += "<tr>";
	result += "<td><a href='"+ tmprubrique.getUrl() + "' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage(\""+ tmprubrique.getAlias() +"\",\"\",\""+skinsPath +"images/shared/professionnels/"+ tmprubrique.getAlias() +"_on.gif\",1);RemoteExpand(\"bloc1\", \"bloc1rub"+tmprubrique.getNiveau1()+"\");'><img border=0 name=" + tmprubrique.getAlias() + " src ='"+skinsPath +"images/shared/professionnels/"+ tmprubrique.getAlias() +"_"+etat+".gif'></a></td>";
	result += "</tr>";
	result += "<tr>";
	result += "<td><img src='" + skinsPath + "images/shared/vide.gif' name='bloc1rub"+tmprubrique.getNiveau1()+"rh'></td>"; 
	result += "</tr>"; 

	//niveau2
	currentRubriqueArray2 = rubriqueArray;
	for(j=0;j<currentRubriqueArray2.length;j++){
		tmprubrique2 = currentRubriqueArray2[j];
		if(tmprubrique2.getNiveau() == 2 && tmprubrique2.getNiveau1()==tmprubrique.getNiveau1()){
			etat = "off";
			if(tmprubrique2.getNiveauId() == rubriqueNiveauId){
				etat = "on";
			}
			
			result += getItemNavBloc1HtmlNiveau2(tmprubrique2,etat,rubriqueArray);
		}
	}

	result += "<tr>";
	result += "<td><img src='" + skinsPath + "images/shared/vide.gif' name='bloc1rub"+tmprubrique.getNiveau1()+"eh'></td>";
	result += "</tr>";
	result += "</table>";
	result += " </div>";

	return result;
}


//BLOC1 : niveau2
function getItemNavBloc1HtmlNiveau2(tmprubrique,etat,rubriqueArray){
	var result = "";
	var etatInv = "";
	
	if(etat == "on"){
		etatInv = "off";
	}else{
		etatInv = "on";
	}

	result += "<tr>";
	result += "<td>";
	result += "<table border='0' cellspacing='0' cellpadding='0'>";
    result += "<tr>";
	result += "<td><a href='"+ tmprubrique.getUrl() + "' onMouseOut='MM_swapImgRestore()' onMouseOver='MM_swapImage(\""+ tmprubrique.getAlias() +"\",\"\",\""+skinsPath +"images/shared/professionnels/"+ tmprubrique.getAlias() +"_on.gif\",1);'><img border=0 name=" + tmprubrique.getAlias() + " src ='"+skinsPath +"images/shared/professionnels/"+tmprubrique.getAlias() +"_"+etat+".gif'></a></td>";
	result += "<td width=2 background='" + skinsPath + "images/shared/nav_rub_right.gif'><img src='" + skinsPath + "images/shared/vide.gif' width=2 height=1></td>";
	result += "</tr>";
	result += "<tr>";
	result += "<td colspan='2' align='right' background='" + skinsPath + "images/shared/nav_rub_sep.gif'><img src='" + skinsPath + "images/shared/nav_rub_right.gif' width=2 height=1></td>";
	result += "</tr>";
	result += "</table>";
	result += "</td>";
	result += "</tr>";
	
	return result;
}


function writeNavBloc1(rubriqueArray,rubriqueNiveauId){
	//alert(espace);
	var result = "";
	var result_div3 = "";
	var tmprubrique = "";
	var currentrubrique = new rubrique();
	var etat = "";
	
	currentRubriqueArray = rubriqueArray;
	
	//NIVEAUX 1
	for(i=0;i<currentRubriqueArray.length;i++){
		tmprubrique = currentRubriqueArray[i];
		if(tmprubrique.getNiveau() == 1 && tmprubrique.getNiveau1() != 0){
			etat = "off";
			if(tmprubrique.getNiveauId() == rubriqueNiveauId){
				etat = "on";
			}
			result += getItemNavBloc1HtmlNiveau1(tmprubrique,etat,rubriqueArray,rubriqueNiveauId);
			
		}
	}
	
	document.write(result);
	document.write(result_div3);
}

function writeNavBloc3(){
	document.write("<a href='professionnels.valeoclimservice.devenirpartenaire.php'><img src='"+ skinsPath + "images/shared/professionnels/nav_special.gif' border='0'></a>");
}

//*********************************
//*********************************


// **************************************************************************
// ***** FONCTION D'INITIALISATION DES CALQUES AU CHARGEMENT DE LA PAGE *****
// **************************************************************************
function InitCalages() {
// INITIALISATION DES CALQUES DES DIFFÉRENTS BLOCS DE NAVIGATION

// INITIALISATION DES COORDONNÉES Y DES CALQUES DE RUBRIQUES
var calageRubs = new Array();
// Détail des paramètres : ('calque conteneur','calque à caler', 'image référente')
// L'image référente est l'image 'remoted height' contenue dans le calque de rubrique
// situé au-dessus du calque à caler. La première rubrique n'ayant pas de calque
// supérieur, elle est calée à une image dans le titre de la navigation.

// INITIALISATION DE LA HAUTEUR DES CALQUES DE RUBRIQUES
var resizeRubs = new Array();
// Détail des paramètres : ('calque conteneur','calque à caler', 'image référente')
// L'image référente est l'image 'remoted height' contenue dans le calque à caler.

j=0;
for(i=0;i<rubriqueNav1.length;i++){
	tmprubrique = rubriqueNav1[i];
	if(tmprubrique.getNiveau() ==1 && tmprubrique.getNiveau1() != 0){
		if (tmprubrique.getNiveau1()==1) {	
			calageRubs[j] = calRubs('bloc1', 'bloc1rub'+tmprubrique.getNiveau1(), 'bloc1rub'+tmprubrique.getNiveau1()+'cal');
		}else{
			indice=tmprubrique.getNiveau1()-1;
			calageRubs[j] = calRubs('bloc1', 'bloc1rub'+tmprubrique.getNiveau1(), 'bloc1rub'+indice+'rh');
		}
		resizeRubs[j] = sizeRubs('bloc1', 'bloc1rub'+tmprubrique.getNiveau1(), 'bloc1rub'+tmprubrique.getNiveau1()+'rh');
		j++;
	}
}

resizeRubs[j] = sizeRubs('bloc1', 'bloc1foot', 'bloc1footrh');
indice=indice+1;
calageRubs[j] = calRubs('bloc1', 'bloc1foot', 'bloc1rub'+indice+'rh');


var calageBloc = new Array();
// Détail des paramètres : ('calque à caler', 'image référente dans le body ?', décalage en x, décalage en y)
//
// 'image référente dans le body ?' : si l'image référente est directement dans le body,
// le paramètre est 'le nom de l image référente'. Sinon indiquer 'no'. Exemple : pour caler le bloc 2
// par rapport au bloc 1, il faut que l'image référente du bloc 2 soit l'image référente de la dernière
// rubrique du bloc 1. Le script vérifie si cette dernière est expanded ou remoted.
// 
// L'image référente est située dans la page.
//
// 'décalage en x' et 'décalage en y' sont les distances en pixel entre 'image référente' et
//
// 'calque à caler'.

calageBloc[0] = calBloc('bloc1', 'bloc1cal', 0, 0);
calageBloc[1] = calBloc('bloc2', 'no', 0, 8);


if (rubriqueNiveauId2=="0_0_0") {
	rub_array=rubriqueNiveauId.split("_");
	if(rub_array[1]!="0") RemoteExpand('bloc1', 'bloc1rub'+rub_array[0]);
	}
}
//*********************************
//*********************************


