/* si la 'page courante' est appelée hors de son contexte, c'est-à-dire hors de son frame parent, alors la page Main.htm est appelée avec la 'page courante' comme paramètre*/

//alert("Redirige avec location = " + self.location);
//ORIGINAL CODE WAS: if (top == self) {location.replace("main.htm?" + self.location)};

// To manage NL versions of Tibetathlon web site
//document.write(strPage + "<br />");
//document.write("Position:" + strPage.indexOf("_nl") + "<br />");
//document.write(strPage.substring(0,i) + "_nl.htm" + "<br />");


function FNTranslatedPages() {
  //Source: http://www.faqts.com/knowledge_base/view.phtml/aid/32196
  var arrayPages = new Array (
   ["http://www.zangdokpalri.net/tibetathlon/index.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/info_pratique.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/projet_extension.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/versement.htm"],  
   ["http://www.zangdokpalri.net/tibetathlon/animation.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/contact.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/esprit.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/inscription.php"],
   ["http://www.zangdokpalri.net/tibetathlon/lieu.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/parcours.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/acces.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/partenaire_sponsor.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/resultats_courses.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/resultats_courses_2006.htm"],
   ["http://www.zangdokpalri.net/tibetathlon/welcome_msg_by_rinpoche.htm"]);
  return( arrayPages );
	}

function FNArrayGetSearchLinearRowI( searchS, arrayPages ) {
	var I = 0;
 	var minI = 0;
 	var maxI = arrayPages.length - 1;
  
 	var s = "";
 	var foundB = false;
 	I = minI - 1;
 	while ( ( I <= maxI ) && ( !( foundB ) ) ) {
  	  	I = I + 1;
  	  	s = arrayPages[ I ];
  	  	foundB = ( searchS == s );
 						}
 	if ( foundB ) {
  	 	//alert('page found: ' + searchS);
  	 	return( I );
		
 			}
 	else {
  		return( -1000 ); // some negative number indicating not found
 		}
}


function FNredirectNL() {

	var strPage = String(self.location);
	var i = 0;
	var j = 0;
	var k = 0;
	
	// is current Page NL ?
	j = strPage.indexOf("_nl.htm");
	k = strPage.indexOf("nl_translation.htm")
	
	//if is translated, then quit
	if (j > 0) {
		return true;
	};
	
	if (k > 0) {
		return true;
	};
	
	
	// redirect only if not NL and not 'nl_translation.htm' and within translated pages
	if ((j == -1) && (k == -1) && (FNArrayGetSearchLinearRowI( strPage, FNTranslatedPages())>=0) ) {	 	
		
		i = strPage.indexOf(".htm");
		strPage = strPage.substring(0,i) + "_nl.htm";
		location.replace("../main.htm?" + strPage);
	}
	else {
		location.replace("../main.htm?" + "http://www.zangdokpalri.net/tibetathlon/nl_translation.htm");
	}

	return true;
   };


function FNredirectFR() {

	var strPage = String(self.location);
	var i = 0;
	var j = 0;
	
	// current Page is NL ?
	j = strPage.indexOf("_nl.htm");
	
	// redirect only if NL or nl_translation.htm
	if (j > 0)  {
		
		i = strPage.indexOf("_nl");
		strPage = strPage.substring(0,i) + ".htm"
		location.replace("../main.htm?" + strPage)
	};

	return true;
   };




//Main function here
if (top == self) {
	location.replace("../main.htm?" + self.location);
	};
if (self.name =="defaultmainframe") {
		location.replace("../main.htm?" + self.location);
		};
if (self.name =="topframe") {
		location.replace("../main.htm?" + self.location);
		};
if (self.name =="bottomframe") {
		location.replace("../main.htm?" + self.location);
		};