/**
* Copyright Patent Organizer Software 2007
* Do not copy without autorization from Patent Organizer Software
* Author: Pierre Conti 
*/
 var fr = 0;
 var en = 1;
 var de = 2;
 var es = 3;
 var lg = fr;

/* we may add as lang as we want */
var textLang = new Array('fr','en','de','es');
/* menu content are recorded within arrays filled within the html page */
var texts = {};
function toggleMenu(element){
	var m = document.getElementById(element);
	if ( m.style.display == "block"){
		m.style.display = "none" ;
	}else{
		m.style.display = "block";
	}
 // onClick="javascript:changecss('.sousMenu1','display','none')"
	
}
function switchLang(){
	var img = document.getElementById("flag");
	if ( lg == fr ) {
		img.src = "images/flags/png_150/flagfr.png";
		img.title="Permutter en Français";
		lg = en;		
	} else{
		img.src = "images/flags/png_150/flaggb.png";
		img.title="Switch to english";
		lg = fr;
	}
	setLang(lg);
}
function setLang(nbl){
  lg=nbl;
  initialize();
}

function mWrite(indice){
 document.write(texts[indice][lg]);
 return true;
}

function colorIn( elem, color){
     elem.style.color=color;
}

function colorOut( elem, color){
     elem.style.color=color;
}

/* function used to get the requested language */
function getLang(){
  var re = /^(.+)html\?lang=(.+)/;
  var str = parent.location.href ;
  //var str = window.location ;
  // alert(str);

  fromIntranet = 1;
  // test if got from a server or from file: 
 if ( str.search(/[h|H]/)==0){
    fromIntranet = 0; //alert("From server ");
  } else{
    fromIntranet = 1; //alert("From intranet ");
  }
  lang = 0;
  if ( re.test( str ) ){
    str = str.replace(/^(.+)html\?lang=(.+)/,"$2");
    if ( str.indexOf("fr")== 0){ lang = 0; } else
    if ( str.indexOf("en")== 0){ lang = 1; } else
    if ( str.indexOf("de")== 0){ lang = 2; } else 
    if ( str.indexOf("es")== 0){ lang = 3; }
 }
  lg = lang;
}


/* this function is used to replace all elements within the list by it's corresponding text 
 */
function initialize(){
  list = toInit; /* set at the end of the index.html page */
  /* getLang(); used only if lang is set within the html call*/  
  var el;
  var i;

  for ( i = 0 ; i < list.length ; i++){
    //alert ( "initialisation de "+list[i]);
    el = document.getElementById(list[i]);
    if (el != null){
      if ( texts[list[i]] != null){
          el.innerHTML = texts[list[i]][lg]; 
      }
      if ( texts[list[i]+"_TITLE"] != null){
          el.title = texts[list[i]+"_TITLE"][lg]; 
      }
    }

  } 

}

