var listeActuelle = 7;
var time = new Date();
randnum= (time.getTime());
        

// fonctions pour critères par région de france
function doSubmit(){
    document.forms.choix.submit();
}
     

// fonctions pour critères par pays
function doSubmitm(){

    document.forms.mchoix.submit();

}


// fonctions pour critères pour producteurs
function doSubmitp(){

    document.forms.pchoix.submit();

}


function goto_location(code,pays,bourse,categorie) {
  if(code=='')
     {location.href="/resultat_recherche_code.phtml";return false;}
  if(parent!=null)
     parent.location.href='/cours.phtml?code='+escape(code)+'&choix_bourse='+escape(bourse)+'&categorie='+escape(categorie);
  else
     location.href='/cours.phtml?code='+escape(code)+'&choix_bourse='+escape(bourse)+'&categorie='+escape(categorie);
  return false;
}


function select_value(select,value){
   for(i=0;i<select.options.length;i++){
      if(select.options[i].value==value){
         select.options[i].selected=true;
         return;
	  }
   }
}


function select_radio(radio,value){
   for(i=0;i<radio.length;i++){
      if(radio[i].value==value){
         radio[i].checked=true;
         return;
	  }
   }
}


function popup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=yes,top='+top+',left='+left +',width=' + w + ',height=' + h );
   myWin.focus();
}


function tinypopup(f,nom, w, h) {
   var top=0;
   var left=0;
   if (self.screen)
      left=(screen.width-(w+((screen.width*1)/100)));
   myWin = window.open(f, nom, 'resizable,screenX=0,screenY=0,scrollbars=yes,menubar=no,top='+top+',left='+left +',width=' + w + ',height=' + h );
   myWin.focus();

}


function lien(url) {
  var maitre; 
  if (opener.closed) {
    // si la fenêtre principale est fermée
    maitre=window.open('','nomprincipal','toolbar=yes, location=yes,status=yes,menubar=yes, scrollbars=yes,resizable=yes,copyhistory=no');
    maitre.location.href = url;
  } else {
    // Si la fenêtre principale est ouverte
    opener.location.href = url;
  }
  // Ferme le pop-up automatiquement
  // nomdupop=window.close()
}


function changeParent(url)
{
   if(document.opener) 
      opener.document.location.href(url);
   else
      window.open(url,'nouveau');
   return false;
}


function BrowserCheck() {
	var b = navigator.appName;
	if (b=="Netscape") this.b = "ns";
	else if (b=="Microsoft Internet Explorer") this.b = "ie";
	else this.b = b;
	this.version = navigator.appVersion;
	this.userAgent = navigator.userAgent;
	this.v = parseInt(this.version);
	this.ns = (this.b=="ns" && this.v>=5);
	this.ns4 = (this.b=="ns" && this.v==4);
	this.ns5 = (this.b=="ns" && this.v==5);
	this.ns6 = (this.b=="ns" && this.v==6);
	this.ie = (this.b=="ie" && this.v>=4);
	this.ie4 = (this.version.indexOf('MSIE 4')>0);
	this.ie5 = (this.version.indexOf('MSIE 5.0')>0);
	this.ie55 = (this.version.indexOf('MSIE 5.5')>0);
	this.ie6 = (this.version.indexOf('MSIE 6.0')>0);
	this.min = (this.ns||this.ie);
}
is = new BrowserCheck();  /* automatically create the "is" object*/

if(document.cookie.indexOf('NAVVER=')<0)
{
   if(is.min)
      document.cookie = 'NAVVER=OK';
   else
      document.cookie = 'NAVVER=NOK';
}


function show_layer(layer) {
   var elm;
   if (is.ns4){
      elm = document.layers[layer];
   }
   else if (is.ie4) {
      elm = document.all[layer];
   }
   else if(document.getElementById(layer)) {
      elm = document.getElementById(layer);
   }
   elm.style.visibility = "visible";
}


function hide_layer(layer) {
   var elm;
 
   if (is.ns4){
      elm = document.layers[layer];
   }
   else if (is.ie4) {
      elm = document.all[layer];
   }
   else if (document.getElementById(layer)) {
      elm = document.getElementById(layer);
   }
   if(elm) { elm.style.visibility = "hidden"; }
}


function reload_layer(layer) {
   var elm;
   
   if (is.ns4){
      elm = document.layers[layer];
   }
   else if (is.ie4) {
      elm = document.all[layer];
   }
   else if (document.getElementById(layer)) {
      elm = document.getElementById(layer);
   }
   if(elm) { elm.location.reload(); }
}


function ereg_replace(tx,rg,ch) { 
   var regEx = new RegExp(rg,"g") 
   return tx.replace(regEx,ch) 
}


function checkIdentifiant(login,password,formulaire)
{
  if(login=='')
  {
     alert('Vous devez renseigner votre login.');
     return false;
  }
  else if(password=='')
  {
     alert('Vous devez renseigner votre mot de passe.');
     return false;
  }
  else
  {
     if( login.match(/^[0-9]+$/) || login.match(/^[0-9][0-9][0-9][0-9][0-9][a-zA-Z][a-zA-Z]$/) || login.match(/^[Ww][Ee][Bb][0-9]+$/) )
     {
        formulaire.action = ereg_replace(formulaire.action,'http://','https://');
     }
     return true;
  }
}