<!-- //

function creerPiste(nom,secteur,couleur,alt_max,alt_min,denivelee,longueur,pente,etat,etat_texte){
	this.nom=nom;
	this.secteur=secteur;
	this.couleur=couleur;
	this.alt_max=alt_max;
	this.alt_min=alt_min;
	this.denivelee=denivelee
	this.longueur=longueur;
	this.pente=pente;
	this.etat=etat;
	this.etat_texte=etat_texte;
	return this;
}

Pistes=new Array(83)
Pistes[0]=new creerPiste("Aigle","Crey-du-Quart","Rouge","2417","1740","677","2000","33","1","Ouverte")
Pistes[1]=new creerPiste("Belette","Crey-du-Quart","Rouge","2417","2083","334","1200","22","1","Ouverte")
Pistes[2]=new creerPiste("Blanchon","Crey-du-Quart","Rouge","2417","2150","267","1260","21","1","Ouverte")
Pistes[3]=new creerPiste("Chamois","Crey-du-Quart","Rouge","1740","1420","320","1700","19","1","Ouverte")
Pistes[4]=new creerPiste("Crocus","Crey-du-Quart","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[5]=new creerPiste("Edelweiss","Crey-du-Quart","Rouge","1740","1420","320","1800","18","1","Ouverte")
Pistes[6]=new creerPiste("Escargot","Crey-du-Quart","Verte","2417","2100","317","2520","13","1","Ouverte")
Pistes[7]=new creerPiste("Gentianes","Crey-du-Quart","Rouge","2300","2100","200","760","19","1","Ouverte")
Pistes[8]=new creerPiste("Gerboise","Crey-du-Quart","Rouge","2524","2150","374","1520","25","1","Ouverte")
Pistes[9]=new creerPiste("Liaison Escargot","Crey-du-Quart","Verte","0","0","0","0","0","1","Ouverte")
Pistes[10]=new creerPiste("Liaison Valloire/Valmeinier","Crey-du-Quart","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[11]=new creerPiste("Lutins","Crey-du-Quart","Verte","1740","1420","320","3200","10","1","Ouverte")
Pistes[12]=new creerPiste("Martagon","Crey-du-Quart","Bleue","2083","1740","343","2100","16","1","Ouverte")
Pistes[13]=new creerPiste("Mérégers","Crey-du-Quart","Rouge","2113","1850","263","740","35","1","Ouverte")
Pistes[14]=new creerPiste("Mulots","Crey-du-Quart","Rouge","2150","1800","350","1000","35","1","Ouverte")
Pistes[15]=new creerPiste("Pervenche","Crey-du-Quart","Rouge","2417","2230","187","860","21","1","Ouverte")
Pistes[16]=new creerPiste("Primevère","Crey-du-Quart","Bleue","2524","2150","374","2000","18","1","Ouverte")
Pistes[17]=new creerPiste("Rose","Crey-du-Quart","Rouge","2417","2083","334","1660","20","1","Ouverte")
Pistes[18]=new creerPiste("Séa","Crey-du-Quart","Verte","2173","2143","30","400","8","1","Ouverte")
Pistes[19]=new creerPiste("Selles","Crey-du-Quart","Bleue","2417","1750","667","6700","10","1","Ouverte")
Pistes[20]=new creerPiste("Snowpark","Crey-du-Quart","Snowpark","2300","2230","70","120","0","1","Ouverte")
Pistes[21]=new creerPiste("Soldanelle","Crey-du-Quart","Bleue","2340","2163","177","880","20","1","Ouverte")
Pistes[22]=new creerPiste("Stade","Crey-du-Quart","Rouge","2300","2100","200","620","32","1","Ouverte")
Pistes[23]=new creerPiste("Arolles","La Sétaz","Noire","2200","2000","200","600","33","1","Ouverte")
Pistes[24]=new creerPiste("Bambins","La Sétaz","Verte","1918","1900","18","200","9","1","Ouverte")
Pistes[25]=new creerPiste("Blaireau","La Sétaz","Rouge","2021","1830","191","530","24","1","Ouverte")
Pistes[26]=new creerPiste("Bouquetin","La Sétaz","Rouge","2254","2018","236","1100","21","1","Ouverte")
Pistes[27]=new creerPiste("Campanule","La Sétaz","Bleue","1660","1500","160","600","26","1","Ouverte")
Pistes[28]=new creerPiste("Cascade","La Sétaz","Noire","2254","1750","504","1600","31","1","Ouverte")
Pistes[29]=new creerPiste("Chevreuil","La Sétaz","Rouge","2018","1920","98","400","25","1","Ouverte")
Pistes[30]=new creerPiste("Choucas","La Sétaz","Rouge","2010","1560","450","1800","25","1","Ouverte")
Pistes[31]=new creerPiste("Combe Thimel","La Sétaz","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[32]=new creerPiste("Dahu","La Sétaz","Noire","0","0","0","0","0","1","Ouverte")
Pistes[33]=new creerPiste("Joubarbe","La Sétaz","Verte","2021","1920","101","620","16","1","Ouverte")
Pistes[34]=new creerPiste("Linegrette","La Sétaz","Bleue","1800","1560","240","1600","15","1","Ouverte")
Pistes[35]=new creerPiste("Marmotte","La Sétaz","Rouge","1930","1420","510","1700","30","1","Ouverte")
Pistes[36]=new creerPiste("Mélèzes","La Sétaz","Noire","1930","1600","330","800","41","1","Ouverte")
Pistes[37]=new creerPiste("Myosotis - Bas","La Sétaz","Verte","1930","1420","510","5000","10","1","Ouverte")
Pistes[38]=new creerPiste("Myosotis - Haut","La Sétaz","Verte","1930","1420","510","5000","10","1","Ouverte")
Pistes[39]=new creerPiste("Olympique","La Sétaz","Noire","1930","1660","270","800","33","1","Ouverte")
Pistes[40]=new creerPiste("Perdrix","La Sétaz","Rouge","2430","2254","176","600","29","1","Ouverte")
Pistes[41]=new creerPiste("Rhodos","La Sétaz","Bleue","1930","1420","510","3000","17","1","Ouverte")
Pistes[42]=new creerPiste("Sétaz bleue","La Sétaz","Bleue","2254","1920","334","1680","20","1","Ouverte")
Pistes[43]=new creerPiste("Silène","La Sétaz","Rouge","1500","1420","80","400","30","1","Ouverte")
Pistes[44]=new creerPiste("Tétras","La Sétaz","Rouge","2200","2084","116","350","33","1","Ouverte")
Pistes[45]=new creerPiste("La Viclouse","Les Verneys","Verte","1674","1600","74","800","9","1","Ouverte")
Pistes[46]=new creerPiste("Le Moulin","Les Verneys","Verte","1500","1465","35","450","8","1","Ouverte")
Pistes[47]=new creerPiste("Les Verneys","Les Verneys","Verte","1674","1560","114","1000","11","1","Ouverte")
Pistes[48]=new creerPiste("Muguet","Les Verneys","Verte","1573","1560","13","50","9","1","Ouverte")
Pistes[49]=new creerPiste("Arméra","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[50]=new creerPiste("Bleuets","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[51]=new creerPiste("Chardons","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[52]=new creerPiste("Chaudannes","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[53]=new creerPiste("Choulet","Valmeinier","Noire","0","0","0","0","0","1","Ouverte")
Pistes[54]=new creerPiste("Combe","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[55]=new creerPiste("Comborsière","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[56]=new creerPiste("Coterieux","Valmeinier","Noire","0","0","0","0","0","1","Ouverte")
Pistes[57]=new creerPiste("Cyclamens","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[58]=new creerPiste("Eglantiers","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[59]=new creerPiste("Epilobes","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[60]=new creerPiste("Génépi","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[61]=new creerPiste("Genevriers","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[62]=new creerPiste("Goulet","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[63]=new creerPiste("Grandes Drozes","Valmeinier","Noire","0","0","0","0","0","1","Ouverte")
Pistes[64]=new creerPiste("Grapil","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[65]=new creerPiste("Iris","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[66]=new creerPiste("La Mine","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[67]=new creerPiste("Lacs","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[68]=new creerPiste("Lauzes","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[69]=new creerPiste("Les Arcosses","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[70]=new creerPiste("Lys","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[71]=new creerPiste("Myrtilles","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[72]=new creerPiste("Nevache","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[73]=new creerPiste("Perce-neige","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[74]=new creerPiste("Petit-déjeuner","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[75]=new creerPiste("Petites Anglaises","Valmeinier","Verte","0","0","0","0","0","1","Ouverte")
Pistes[76]=new creerPiste("Plan Palais","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[77]=new creerPiste("Praz Conduite","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[78]=new creerPiste("Praz Violette","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[79]=new creerPiste("Reine des Prés","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[80]=new creerPiste("Rhodos","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")
Pistes[81]=new creerPiste("Stade","Valmeinier","Rouge","0","0","0","0","0","1","Ouverte")
Pistes[82]=new creerPiste("Violettes","Valmeinier","Bleue","0","0","0","0","0","1","Ouverte")

function InfoPistes(template1,template2){
	
	var information;
	
	boolTemplate=false;	
	
	for(i=0;i<Pistes.length;i++){ 

		if (!boolTemplate)
		{	
			information=template1;
		}
		else
		{
			information=template2;
		}

		while(information.search(/#\w+#/i) != -1)
		{
			motcle = information.match(/#\w+#/i);

			if (motcle == "#nom#") {
				valeur=Pistes[i].nom;
			}
			else if (motcle == "#secteur#") {
				valeur=Pistes[i].secteur;
			}
			else if (motcle == "#couleur#") {
				valeur=Pistes[i].couleur;
			}
			else if (motcle == "#alt_max#") {
				valeur=Pistes[i].alt_max;
			}
			else if (motcle == "#alt_min#") {
				valeur=Pistes[i].alt_min;
			}
			else if (motcle == "#denivelee#") {
				valeur=Pistes[i].denivelee;
			}
			else if (motcle == "#longueur#") {
				valeur=Pistes[i].longueur;
			}
			else if (motcle == "#pente#") {
				valeur=Pistes[i].pente;
			}
			else if (motcle == "#etat#") {
				valeur=Pistes[i].etat;
			}
			else if (motcle == "#etat_texte#") {
				valeur=Pistes[i].etat_texte;
			}
			else {
				valeur="?";
			}
			
			information=information.replace(/#\w+#/i,valeur);
		}

		document.write(information);
		
		boolTemplate=!boolTemplate;
	}	
}

function InfoPistes(template1,template2,champsFiltre,valeurFiltre){
	
	var information;
	
	boolTemplate=false;	
	
	for(i=0;i<Pistes.length;i++){ 


		if (champsFiltre == "#nom#") {
			boolOk=(Pistes[i].nom == valeurFiltre);
		}
		else if (champsFiltre == "#secteur#") {
			boolOk=(Pistes[i].secteur == valeurFiltre);
		}
		else if (champsFiltre == "#couleur#") {
			boolOk=(Pistes[i].couleur == valeurFiltre);
		}
		else if (champsFiltre == "#alt_max#") {
			boolOk=(Pistes[i].alt_max == valeurFiltre);
		}
		else if (champsFiltre == "#alt_min#") {
			boolOk=(Pistes[i].alt_min == valeurFiltre);
		}
		else if (champsFiltre == "#denivelee#") {
			boolOk=(Pistes[i].denivelee == valeurFiltre);
		}		
		else if (champsFiltre == "#longueur#") {
			boolOk=(Pistes[i].longueur == valeurFiltre);
		}
		else if (champsFiltre == "#pente#") {
			boolOk=(Pistes[i].pente == valeurFiltre);
		}
		else if (champsFiltre == "#etat#") {
			boolOk=(Pistes[i].etat == valeurFiltre);
		}
		else if (champsFiltre == "#etat_texte#") {
			boolOk=(Pistes[i].etat_texte == valeurFiltre);
		}		
		else {
			boolOk=true;
		}

		if (boolOk) {

			
			if (!boolTemplate)
			{	
				information=template1;
			}
			else
			{
				information=template2;
			}

			while(information.search(/#\w+#/i) != -1)
			{
				motcle = information.match(/#\w+#/i);

				if (motcle == "#nom#") {
					valeur=Pistes[i].nom;
				}
				else if (motcle == "#secteur#") {
					valeur=Pistes[i].secteur;
				}
				else if (motcle == "#couleur#") {
					valeur=Pistes[i].couleur;
				}
				else if (motcle == "#alt_max#") {
					valeur=Pistes[i].alt_max;
				}
				else if (motcle == "#alt_min#") {
					valeur=Pistes[i].alt_min;
				}
				else if (motcle == "#denivelee#") {
					valeur=Pistes[i].denivelee;
				}
				else if (motcle == "#longueur#") {
					valeur=Pistes[i].longueur;
				}
				else if (motcle == "#pente#") {
					valeur=Pistes[i].pente;
				}
				else if (motcle == "#etat#") {
					valeur=Pistes[i].etat;
				}
				else if (motcle == "#etat_texte#") {
					valeur=Pistes[i].etat_texte;
				}
				else {
					valeur="?";
				}

				information=information.replace(/#\w+#/i,valeur);
			}

			document.write(information);
			
			boolTemplate=!boolTemplate;
		}
	}	
}

function StatPistes(template,secteur,couleur){
	
	var information=template;
	
	var nb_pistes=0;
	var nb_pistes_ouvertes=0;
	var nb_pistes_fermees=0;
	
	for(i=0;i<Pistes.length;i++){ 

		boolOk=true;
		
		if (secteur != "tous" )
		{
			boolOk=boolOk && (Pistes[i].secteur==secteur);
		}
		
		if (couleur != "toutes" )
		{
			boolOk=boolOk && (Pistes[i].couleur==couleur);
		}

		if (boolOk) {
			nb_pistes=nb_pistes+1;
			if ((Pistes[i].etat == 1)||(Pistes[i].etat == 3))
			{
				nb_pistes_ouvertes=nb_pistes_ouvertes+1;
			}
			else
			{
				nb_pistes_fermees=nb_pistes_fermees+1;
			}
		}
		
	}
		
	while(information.search(/#\w+#/i) != -1)
	{
		motcle = information.match(/#\w+#/i);

		if (motcle == "#nb_pistes#") {
			valeur=nb_pistes;
		}
		else if (motcle == "#nb_pistes_ouvertes#") {
			valeur=nb_pistes_ouvertes;
		}
		else if (motcle == "#nb_pistes_fermees#") {
			valeur=nb_pistes_fermees;
		}
		else if (motcle == "#%_pistes_ouvertes#") {
			if (nb_pistes>0) {
				valeur=Math.round((nb_pistes_ouvertes/nb_pistes)*100);
			}
			else
			{
				valeur="0";
			}
		}
		else {
			valeur="?";
		}

		information=information.replace(/#\w+#/i,valeur);
	}

	document.write(information);
			
}

//-->

