// JavaScript Document

//=======================================================//
//=== FONCTION D'INITIALISATION DE L'EVENEMENT ONLOAD ===//
//=======================================================//

init_load();


//===============================================//
//=== FONCTION APPELEE PAR L'EVENEMENT ONLOAD ===//
//===============================================//

function Dinit(){
	//Initialisation des DSelect
	init_dselect();
	//Initialisation des input text
	init_input_text();
	//Initialisation de l'affichage des sousmenus
	initSousMenu();
	//Initialisation de l'affichage de la popin "code privilège"
	initPopinCodePrivilege();
	//Initalisation de l'affichage du bloc "affiner la recherche"
	initAffinerRecherche();
	//Initalisation des rollovers
	init_rollover();
	//Initialisation des effets de la page "projet immobilier"
	initOngletTxt();
	//Initialisation des "double curseur"
	initDCurseur();
	//Initialisation des input hidden
	initInputHidden();
	//Initialisation du layer "layerDisable"
	initAbleDisableCursorNbPieces();
	//Initialisation de la popin de la home
	initPopinHome();
	//Initialisation de la popin de la newsletter
	initPopinNewsL();
	//Initialisation de la popin gauche
	popinLeft();
}


		//==============================================//
		//==== FONCTIONS APPELEES A L'INITIALISATION ===//
		//==============================================//


/*********************************/
/*** INITALISATION DES DSELECT ***/
/*********************************/

function init_dselect(){
	var i = 1;
	var el_DS = document.getElementById('select_input'+i);
	while(el_DS){
		createDSelect(i);
		i++;
		el_DS = document.getElementById('select_input'+i);
	}
}


/************************************/
/*** INITALISATION DES INPUT TEXT ***/
/************************************/

function init_input_text(){
	//Initialisation de l'input "rappel_tel_gratuit"
	var el = document.getElementById('rappel_tel_gratuit');
	if(el){
		addMyEvent(el,'focus',function(){if(el.value=='Votre n° de téléphone') el.value = '';});
		addMyEvent(el,'blur',function(){if(el.value=='') el.value = 'Votre n° de téléphone';});
	}
	//Initialisation de l'input "newsletter_email"
	var el2 = document.getElementById('newsletter_email');
	if(el2){
		addMyEvent(el2,'focus',function(){if(el2.value=='Adresse E-mail') el2.value = '';});
		addMyEvent(el2,'blur',function(){if(el2.value=='') el2.value = 'Adresse E-mail';});
	}
	//Initialisation de l'input "rappel_tel_gratuit"
	var el3 = document.getElementById('newsletter_cp');
	if(el3){
		addMyEvent(el3,'focus',function(){if(el3.value=='Code postal') el3.value = '';});
		addMyEvent(el3,'blur',function(){if(el3.value=='') el3.value = 'Code postal';});
	}
	//Initialisation de l'input "surface_min"
	var surface_min = document.getElementById('surface_min');
	if(surface_min){
		addMyEvent(surface_min,'focus',function(){if(surface_min.value=='min') surface_min.value = '';});
		addMyEvent(surface_min,'blur',function(){if(surface_min.value=='') surface_min.value = 'min';});
	}
	//Initialisation de l'input "surface_max"
	var surface_max = document.getElementById('surface_max');
	if(surface_max){
		addMyEvent(surface_max,'focus',function(){if(surface_max.value=='max') surface_max.value = '';});
		addMyEvent(surface_max,'blur',function(){if(surface_max.value=='') surface_max.value = 'max';});
	}
	//Initialisation de l'input "budget_min"
	var budget_min = document.getElementById('budget_min');
	if(budget_min){
		addMyEvent(budget_min,'focus',function(){if(budget_min.value=='min') budget_min.value = '';});
		addMyEvent(budget_min,'blur',function(){if(budget_min.value=='') budget_min.value = 'min';});
	}
	//Initialisation de l'input "budget_max"
	var budget_max = document.getElementById('budget_max');
	if(budget_max){
		addMyEvent(budget_max,'focus',function(){if(budget_max.value=='max') budget_max.value = '';});
		addMyEvent(budget_max,'blur',function(){if(budget_max.value=='') budget_max.value = 'max';});
	}
}

/**********************************/
/*** INITALISATION DES ROLLOVER ***/
/**********************************/

function init_rollover(){
	//Initialisation de l'input "recherche"
	var recherche = document.getElementById('recherche');
	if(recherche){
		addMyEvent(recherche,'mouseover',rollover_recheche);
		addMyEvent(recherche,'mouseout',rollout_recheche);
	}
	//Initialisation du bouton "cliquez ici"
	var bt_cliquerici = document.getElementById('bt_cliquerici');
	if(bt_cliquerici){
		addMyEvent(bt_cliquerici,'mouseover',rollover_cliquerici_guide);
		addMyEvent(bt_cliquerici,'mouseout',rollout_cliquerici_guide);
	}
	//Initialisation du bouton "cliquez ici 2"
	var bt_cliquerici = document.getElementById('bt_cliquerici2');
	if(bt_cliquerici){
		addMyEvent(bt_cliquerici,'mouseover',rollover_cliquerici_lexique);
		addMyEvent(bt_cliquerici,'mouseout',rollout_cliquerici_lexique);
	}
	//Initialisation du bouton "En savoir plus"
	var bt_ensavoirplus = document.getElementById('bt_ensavoirplus');
	if(bt_ensavoirplus){
		addMyEvent(bt_ensavoirplus,'mouseover',rollover_bt_ensavoirplus);
		addMyEvent(bt_ensavoirplus,'mouseout',rollout_bt_ensavoirplus);
	}
	//Initialisation du bouton "cliquez ici" du bloc "Investissement Borloo-Robien"
	var bt_cliquezici_br = document.getElementById('bt_cliquezici_br');
	if(bt_cliquezici_br){
		addMyEvent(bt_cliquezici_br,'mouseover',rollover_bt_cliquezici_br);
		addMyEvent(bt_cliquezici_br,'mouseout',rollout_bt_cliquezici_br);
	}
	//Initialisation du bouton "valider" du formulaire "Rendez-Vous"
	var valider_rdv = document.getElementById('valider_rdv');
	if(valider_rdv){
		addMyEvent(valider_rdv,'mouseover',rollover_valider_rdv);
		addMyEvent(valider_rdv,'mouseout',rollout_valider_rdv);
	}
	//Initialisation du bouton "valider" du formulaire "Rendez-Vous"
	var bt_valider = document.getElementById('bt_valider');
	if(bt_valider){
		addMyEvent(bt_valider,'mouseover',rollover_bt_valider);
		addMyEvent(bt_valider,'mouseout',rollout_bt_valider);
	}
}


/**************************************************/
/*** INITALISATION DE L'AFFICHAGE DES SOUSMENUS ***/
/**************************************************/

function initSousMenu(){
	var i = 1;
	var el = document.getElementById('menu'+i);
	while(el){
		//Exception de correction de bogue sous Internet Explorer
		if(navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer"){
			el.onmousemove = showSousMenu;
		}
		el.onmouseover = showSousMenu;
		el.onmouseout = hideSousMenu;
		i++;
		el = document.getElementById('menu'+i);
	}
}


/***************************************************************/
/*** INITALISATION DE L'AFFICHAGE DE LA POPIN CODE PRIVILEGE ***/
/***************************************************************/

function initPopinCodePrivilege(){
	var el = document.getElementById('code_conf_popin');
	if(el){
		addMyEvent(el,'mouseover',showPopinCodePrivilege);
		addMyEvent(el,'mouseout',hidePopinCodePrivilege);
	}
	var el2 = document.getElementById('lbl_code_conf_popin');
	if(el2){
		addMyEvent(el2,'mouseover',showPopinCodePrivilege);
		addMyEvent(el2,'mouseout',hidePopinCodePrivilege);
	}
}


/*******************************************************************/
/*** INITALISATION DE L'AFFICHAGE DU BLOC "AFFINER LA RECHERCHE" ***/
/*******************************************************************/

function initAffinerRecherche(){
	var el = document.getElementById('bt_affiner_recherche');
	if(el){
		addMyEvent(el,'click',showAffinerRecherche);
	}
}


/*************************************************************/
/*** INITALISATION DES EFFETS DE LA PAGE PROJET IMMOBILIER ***/
/*************************************************************/

function initOngletTxt(){
	var i=1;
	var el = document.getElementById('onglet'+i);
	while(el){
		el.onmouseover=showOngletTxt;
		el.onmouseout=hideOngletTxt;
		i++;
		el = document.getElementById('onglet'+i);
	}
}


/******************************************/
/*** INITALISATION DES "DOUBLE CURSEUR" ***/
/******************************************/

function initDCurseur(){
	var i=1;
	var el = document.getElementById('cursor'+i+'_left');
	var idScrollBar = 'scrollbar'+i;
	while(el){
		updateBkgDiv('cursor'+i+'_left');
		applyDCurseur(idScrollBar);
		i++;
		el = document.getElementById('cursor'+i+'_left');
		idScrollBar = 'scrollbar'+i;
	}
}


/**************************************/
/*** INITALISATION DES INPUT HIDDEN ***/
/**************************************/

function initInputHidden(){	
	//Input de la liste des départements dans la recherche avancée
	var myInput = document.getElementById('departement_liste');
	if(myInput)
		myInput.value = '';
}

/*********************************************/
/*** INITALISATION DU LAYER "layerDisable" ***/
/*********************************************/

function initAbleDisableCursorNbPieces(){
	var el = document.getElementById('type_bien3');
	if(el){
		addMyEvent(el,'click',ableDisableCursorNbPieces);
	}
	var el2 = document.getElementById('avancee_type_log_3');
	if(el2){
		addMyEvent(el2,'click',ableDisableCursorNbPieces2);
	}
}


/********************************************/
/*** INITALISATION DE LA POPIN DE LA HOME ***/
/********************************************/

function initPopinHome(){
	//Bouton Fermer
	var Fermer = document.getElementById('bt_fermer_popin_home');
	if(Fermer){
		addMyEvent(Fermer,'click',closePopinHome);
	}
	//Bouton "Changer de Region"
	var ChangerdeRegion = document.getElementById('changer_region');
	if(ChangerdeRegion){
		addMyEvent(ChangerdeRegion,'click',showPopinHome);
	}
}


/********************************************/
/*** INITALISATION DE LA POPIN DE LA NEWSLETTER ***/
/********************************************/

function initPopinNewsL(){
	//Bouton Fermer
	var Fermer = document.getElementById('bt_fermer_popinsc_home');
	if(Fermer){
		addMyEvent(Fermer,'click',closePopinNewsL);
	}
}

