var v_Location=new String(document.location)
v_Location=v_Location.split("#", 1)[0]

function f_Action_Afficher(p_indice){

		for(var v_cpt = 0;v_cpt<document.getElementsByName('DIV_PRODUIT').length;v_cpt++) {
			document.getElementsByName('DIV_PRODUIT')[v_cpt].style.display='none';
		}
		
		document.getElementsByName('DIV_PRODUIT')[p_indice].style.display='block';
		
}

function f_ActionProduit(p_Action, p_Off_Id, p_Pro_Id){
	document.FORM_MULTIUSE.PRO_ID.value=p_Pro_Id
	f_Action(parseInt(p_Action))
}

function f_Action(p_Action){
	switch (parseInt(p_Action)){
		case 0 :
			return;
		break;
		
		// INSCRIPTION ETAPE 1
		case 1 :
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/Particulier/Asp/InscriptionParticulier.asp"
		break;
		// INSCRIPTION ETAPE 2
		case 2 :
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/Particulier/Asp/InscriptionParticulier2.asp"
		break;
		// INSCRIPTION ETAPE 3
		case 3 :
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/Particulier/Asp/InscriptionParticulier3.asp"
		break;
		// INSCRIPTION ETAPE 4
		case 4 :
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/Particulier/Asp/InscriptionParticulier4.asp"
		break;
		case 5 :	//Détail du produit exemple
			//PRODUIT DETAILLE
			document.FORM_MULTIUSE.target="_blank"
			document.FORM_MULTIUSE.action="/DD/Produit/Asp/VoirProduitImmobilierLight.asp"
		break;		
		case 6 :	//Repostage de la page index
			//PRODUIT DETAILLE
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/index.asp"
		break;		
		case 7 :
			// Assistant TMI
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="index.asp"
			window.showModalDialog('/DD/ContenuSimulateurs/Asp/AssistantTauxTMI.asp', document.FORM_MULTIUSE, 'center:yes;dialogWidth:400px;dialogHeight:500px;')
		break;
		case 14 :	//Repostage de la page index
			//Rafraichissement des calculs
			if (f_ControleSaisie(document.FORM_MULTIUSE)==true){
				document.FORM_MULTIUSE.target="_top"
				document.FORM_MULTIUSE.action="/DD/index.asp#Simulation"
			}
			else{
				alert("Le champ " + v_ChampErreur + " est mal renseigné")
				document.location=v_Bookmark
				return;
			}			
		break;
		case 15 :	//Positionnement du paramétrage aux valeurs par défaut
			f_Pardefaut(document.FORM_MULTIUSE);
			document.FORM_MULTIUSE.target="_top"
			document.FORM_MULTIUSE.action="/DD/index.asp#Simulation"
		break;		
		
	}
	
	document.FORM_MULTIUSE.submit()
}

function f_Pardefaut(p_Form){

	p_Form.DEM_TAUXINTERET_PRESENTATION.value=4
	p_Form.PARAM_TAUXCROISSANCEANNUELLEBIEN_PRESENTATION.value=1
	p_Form.PARAM_TAUXCROISSANCEANNUELLELOYER_PRESENTATION.value=2
	p_Form.DEM_DUREEEMPRUNT.value=15
	p_Form.DEM_REVENTEAUBOUTDE.value=11
	p_Form.DEM_TAUXTMI.value=3738
	p_Form.DEM_TYPEEMPRUNT.value=2
	
}

function f_ControleSaisie(p_Form){
	var v_Return=true
	var re
	var v_Chaine = ""
	var v_Nombre = 0
	
	v_Bookmark=""

	v_Return=f_CheckAll(p_Form.DEM_TAUXINTERET_PRESENTATION.value, "decimal")
	if (v_Return==false){
		v_ChampErreur="Taux d'emprunt"
		v_Bookmark=v_Location + "#DEM_TAUXINTERET_PRESENTATION"
		return(v_Return)
	}
	else {
		re = /,/g;
		v_Chaine = new String(p_Form.DEM_TAUXINTERET_PRESENTATION.value.replace(re,'.'));
		v_Nombre = parseFloat(v_Chaine);
		if (v_Nombre>7) {
			v_Return=false
			v_ChampErreur="Taux d'emprunt (doit être inférieur à 7%)"
			v_Bookmark=v_Location + "#DEM_TAUXINTERET_PRESENTATION"
			return(v_Return)
		}
	}

	v_Return=f_CheckAll(p_Form.PARAM_TAUXCROISSANCEANNUELLEBIEN_PRESENTATION.value, "decimalsigne")
	if (v_Return==false){
		v_ChampErreur="Revalorisation annuelle du bien"
		v_Bookmark=v_Location + "#PARAM_TAUXCROISSANCEANNUELLEBIEN_PRESENTATION"
		return(v_Return)
	}
	else {
		re = /,/g;
		v_Chaine = new String(p_Form.PARAM_TAUXCROISSANCEANNUELLEBIEN_PRESENTATION.value.replace(re,'.'));
		v_Nombre = parseFloat(v_Chaine);
		if (v_Nombre<-10 || v_Nombre>10) {
			v_Return=false
			v_ChampErreur="Revalorisation annuelle du bien (doit être comprise entre -10 et 10%)"
			v_Bookmark=v_Location + "#PARAM_TAUXCROISSANCEANNUELLEBIEN_PRESENTATION"
			return(v_Return)
		}
	}

	v_Return=f_CheckAll(p_Form.PARAM_TAUXCROISSANCEANNUELLELOYER_PRESENTATION.value, "decimalsigne")
	if (v_Return==false){
		v_ChampErreur="Croissance annuelle du loyer"
		v_Bookmark=v_Location + "#PARAM_TAUXCROISSANCEANNUELLELOYER_PRESENTATION"
		return(v_Return)
	}
	else {
		re = /,/g;
		v_Chaine = new String(p_Form.PARAM_TAUXCROISSANCEANNUELLELOYER_PRESENTATION.value.replace(re,'.'));
		v_Nombre = parseFloat(v_Chaine);
		if (v_Nombre<-10 || v_Nombre>10) {
			v_Return=false
			v_ChampErreur="Croissance annuelle du bien (doit être comprise entre -10 et 10%)"
			v_Bookmark=v_Location + "#PARAM_TAUXCROISSANCEANNUELLELOYER_PRESENTATION"
			return(v_Return)
		}
	}
	
	return(v_Return)
}
