var currentPage=window.location.href;
    currentPage=currentPage.substring(currentPage.lastIndexOf("/")+1);
	if (currentPage.lastIndexOf("?")>0){currentPage=currentPage.substring(0,currentPage.lastIndexOf("?"));}
	if (currentPage.lastIndexOf("#")>0){currentPage=currentPage.substring(0,currentPage.lastIndexOf("#"));}

// retourne les paramètres passé dans l'url
// toujours utile à avoir sous la main...
function get_urlarg(){
   var url_param = window.location.search;
   if (url_param = url_param.substring(1)) {return(url_param);}
}

function urlArgs(){
  if (url=window.location.search)
  { url=url.substring(1);
    var urlTab=url.split(new RegExp('[&]'));
	this[0]=urlTab.length;
    for (var i=0;i<urlTab.length;i++)
	{ this[urlTab[i].substring(0,urlTab[i].indexOf('='))]=urlTab[i].substring(urlTab[i].indexOf('=')+1);
	  this[i+1]=urlTab[i].substring(urlTab[i].indexOf('=')+1); }
  } else {this[0]=false;}
}

// affiche un portail selon les paramètres url
// utilisé par les pages partagées...
function urlArg_selectPortail(){
  var args=new urlArgs();
  switch (args['port']){
    case 'nvetu': portail_accueil(args['hl']); return(true);
    case 'etu': portail_etudiants(args['hl']); return(true);
    case 'rech': portail_recherche(args['hl']); return(true);
    case 'soc': portail_societe(args['hl']); return(true);
    case 'chiphy': portail_chiphy(args['lang'],args['hl']); return(true);
    default: return(false);
  }
}

// crée un tableau (utilisé par les fonctions "portail_*")
// contient le nom de la classe ("portail" ou "portail_active" du fichier chimie.css), le titre et les rubriques
function css_box(){
  var reg=new RegExp(currentPage,"");
  var domain='http://www.unige.ch/sciences/chimie';
  var domain_tmp='http://www.unige.ch/sciences/devlo';
  var domain2='http://www.unige.ch/sciences';

// test + de 0 paramètre *
  if (css_box.arguments.length>0) {
  document.write('<table class="'+css_box.arguments[0]+'" border="0" cellpadding="0" cellspacing="0" style="font-size:-1" >');

// titre de la rubrique & nouvelle fenêtre pour pages exterieures
  var target_window='target="_blank"';
  if ((css_box.arguments[2].search('http://') != 0)||
      (css_box.arguments[2].substring(0,domain.length)==domain)||
      (css_box.arguments[2].substring(0,domain_tmp.length)==domain_tmp)||
      (css_box.arguments[2].substring(0,domain2.length)==domain2))
         {target_window='target="_self"';};
  document.write('<tr><th style="align:left">::</th><th style="align:left"><a href="'+css_box.arguments[2]+'" '+target_window+'>'+css_box.arguments[1].toUpperCase()+'</a></th><th style="align:right"></th></tr>');
  document.write('<tr><td height="4"></td><td height="4"></td><td height="4"></td></tr>');

// boucle pour crée les cellules des sous-rubriques
  for (var i=3; i<css_box.arguments.length; i=i+2){

    // test la page en cours pour la sous-rubriques en cours (effet "strong")
	if (reg.test(css_box.arguments[i+1])) {var label_strong = new Array('<strong>','</strong>');}
    else {var label_strong = new Array('','');}

// la "sécurité" en rouge...
    var label_color='';
    if ((css_box.arguments[i]=='sécurité') || (css_box.arguments[i]=='security')) {label_color='style="color:#FF0000"';};

// recup' l'extension de l'adresse & nouvelle fenêtre pour fichier *.pdf
    var file_type=css_box.arguments[i+1].substring(css_box.arguments[i+1].length-4);
    var target_window='';
    if (file_type=='.pdf') {target_window='target="_blank"';}

// nouvelle fenêtre pour pages exterieures à la section chimie
// test l'url de la sous-rubrique par rapport à la variable "domain" (http://www.unige.ch/science/chimie)
    var target_window='target="_blank"';
    if ((css_box.arguments[i+1].search('http://') != 0)||
        (css_box.arguments[i+1].substring(0,domain.length)==domain)||
        (css_box.arguments[i+1].substring(0,domain_tmp.length)==domain_tmp)||
        (css_box.arguments[i+1].substring(0,domain2.length)==domain2))
       {target_window='target="_self"';}

    if (css_box.arguments[i]) { // test si le titre de rubrique est present (pour des cellules vide...)
	  document.write('<tr><td>&#8226;</td><td width="100%">'+label_strong[0]+'<a '+label_color+' href="'+css_box.arguments[i+1]+'" '+target_window+'>'+css_box.arguments[i]+'</a>'+label_strong[1]+'</td>');
    } else { document.write('<tr><td></td><td width="100%" height="8"></td>'); }

    if (file_type=='.pdf') { // utilise une image si le fichier est pdf
      document.write('<td><img border="0" src="../pics/pdf_ico.gif" width="18" height="18" align="top"></td></tr>')
    } else { document.write('<td></td></tr>') }

  }
  // cellule de remplissage et fin ;)
  document.write('<tr><td colspan="3" height="100%"></td></tr>');
  document.write('</table>');}
}

// className en rapport avec le fichier CSS "../css/chimie.css"
var classUnactive='portail';
var classActive='portail_active';
var tableSize='650';
// var tableSize='100%';
var className='';

// *****************************************************************************************
// crée un tableau contenant 4 css_box -> function css_box()
// FUTUR ETUDIANT
// **************
function portail_accueil(num_active_portail){

  document.write('<table width="'+tableSize+'" border="0" cellspacing="0" cellpadding="0">');

  // AVANT-GOUT
  document.write('<tr><td valign="top">');
  if (num_active_portail==1) {className=classActive}
  else {className=classUnactive}
  // première ligne: titre de rubrique - ensuite: sous-rubriques ['label','url',]
  css_box(className,'avant-goût','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout_fr.htm',
                    //'','', // une ligne d'espace au-dessus des rubriques...
                    'la nuit de la science','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout/ndls_fr.htm',
                    'passeport-vacances','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout/passeport_fr.htm',
                    'la science appelle les jeunes','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout/science_jeunes_fr.htm',
                    'visites et stages','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout/visites_fr.htm',
                    'autres activités','#.htm',
                    'quelques chiffres','http://www.unige.ch/sciences/devlo/futur_etudiant/avant_gout/chiffres_fr.htm',
					'colloques publics','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=nvetu&hl=1&pres=list&dept=gen',
                    '',''); // ligne d'espace en-dessous des rubriques, ne pas oublier la syntaxe de dernière ligne-> );

  // PARCOURS GUIDE
  document.write('</td><td valign="top">');
  if (num_active_portail==2) {className=classActive}
  else {className=classUnactive}
  css_box(className,'parcours guidé','http://www.unige.ch/sciences/devlo/futur_etudiant/parcours_guide_fr.htm',
                    //'','',
                    'chimie ou biochimie','http://www.unige.ch/sciences/devlo/futur_etudiant/parcours_guide/chimie_biochimie_fr.htm',
                    'titres décernés','http://www.unige.ch/sciences/devlo/futur_etudiant/parcours_guide/titres_fr.htm',
                    'déclaration de Bologne','http://www.unige.ch/sciences/devlo/futur_etudiant/parcours_guide/bologne_fr.htm');

  // ENTRER A LA SECTION
  document.write('</td><td valign="top">');
  if (num_active_portail==3) {className=classActive}
  else {className=classUnactive}
  css_box(className,'entrer à la section','http://www.unige.ch/sciences/devlo/futur_etudiant/entrer_section_fr.htm',
                    //'','',
                    'exigences d\'entrée','http://www.unige.ch/sciences/devlo/futur_etudiant/entrer_section/exigences_fr.htm',
                    'équivalences','#',
                    'démarches administratives','#',
                    'conditions de vie à Genève','#');

  // ...ET APRES
  document.write('</td><td valign="top">');
  if (num_active_portail==4) {className=classActive}
  else {className=classUnactive}
  css_box(className,'...et après','http://www.unige.ch/sciences/devlo/futur_etudiant/apres_fr.htm',
                    //'','',
                    'mobilité tous azimuts','http://www.unige.ch/sciences/devlo/futur_etudiant/apres/apres_fr-old.htm',
                    'formation pour la science','#',
                    'formation par la science','#');
                                  
  document.write('</td></tr></table>');
}

// *****************************************************************************************
// crée un tableau contenant 4 css_box -> function css_box()
// ESPACE ETUDIANT
// ***************
function portail_etudiants(num_active_portail){
  document.write('<table width="'+tableSize+'" border="0" cellspacing="0" cellpadding="0">');
  
  // DOCS & INFOS
  document.write(' <tr><td valign="top">'); 
  if (num_active_portail==1) {className=classActive} 
  else {className=classUnactive} 
  css_box(className,'docs & infos','http://www.unige.ch/sciences/devlo/espace_etudiant/doc_info_fr.htm',
                    //'','',
                    'bachelor (BSc)','http://www.unige.ch/sciences/devlo/espace_etudiant/doc_info/bachelor_fr.htm',
                    'master (MSc)','http://www.unige.ch/sciences/devlo/espace_etudiant/doc_info/master_fr.htm',
                    'doctorat (PhD)','http://www.unige.ch/sciences/devlo/espace_etudiant/doc_info/doctorat_fr.htm',
                    '','',
                    'enseignants','http://www.unige.ch/sciences/devlo/partages/contacts_fr.htm?port=etu&hl=1#ensei',
                    'e-learning (dokeos)','http://www.unige.ch/sciences/devlo/partages/elearning_fr.htm?port=etu&hl=1',
                    'guichet étudiants','#.htm');
                                       
  // RESSOURCES EN COMMUN
  document.write(' </td><td valign="top">');
  if (num_active_portail==2) {className=classActive}
  else {className=classUnactive}  
  css_box(className,'en commun','http://www.unige.ch/sciences/devlo/espace_etudiant/commun_fr.htm',
                    //'','',
                    'bibliothèque','http://www.unige.ch/biblio/sciences2/', 
                    'magasin central','http://www.unige.ch/sciences/chimie/magasin/',
					'webmail unige','https://www.etu.unige.ch/',
                    '','', 
                    'affaires étudiantes UniGE','http://www.unige.ch/dase/',
                    '','',
                    'sécurité','http://www.unige.ch/sciences/devlo/partages/securite_fr.htm?port=etu&hl=2');
    
  // CONFERENCES
  document.write(' </td><td valign="top">');
  if (num_active_portail==3) {className=classActive}
  else {className=classUnactive}
  css_box(className,'conférences','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list',
                    //'','',
                    'biochimie','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list&dept=bioch', 
                    'chimie organique','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list&dept=chior',
                    'chimie physique','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list&dept=chiphy', 
                    'chimie minérale, analytique et appliquée','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list&dept=chiam',
                    '','',
                    'colloques publics','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=etu&pres=list&dept=gen');
                 
  // SUPPLEMENTS
  document.write(' </td><td valign="top">');
  if (num_active_portail==4) {className=classActive}
  else {className=classUnactive}
  css_box(className,'les extras','http://www.unige.ch/sciences/devlo/espace_etudiant/extras_fr.htm',
                    //'','',
                    "Prix d'excellence",'#.htm',
                    "visites d'entreprises",'#.htm',
                    'mobilité tous azimuts','#.htm',
                    "...et après l'Uni ?",'#.htm',
                    '','',
                    "associations d'étudiants",'#.htm',
                    'sociétés savantes','#.htm',
                    '','',
                    'votre opinion','#.htm');

  document.write('</td></tr></table>');
}

// *****************************************************************************************
// crée un tableau contenant 4 css_box -> function css_box()
// PORTAIL RECHERCHE
// *****************
function portail_recherche(num_active_portail){
  document.write('<table width="'+tableSize+'" border="0" cellspacing="0" cellpadding="0">');
  
  // DEPARTEMENTS
  document.write('<tr><td valign="top">');
  if (num_active_portail==1) {className=classActive}
  else {className=classUnactive}  
  css_box(className,'les départements','http://www.unige.ch/sciences/devlo/recherche/departements_fr.htm',
                    //'','',
                    'biochimie','http://www.unige.ch/sciences/biochimie/', 
                    'chimie organique','http://www.unige.ch/sciences/chiorg/', 
                    'chimie physique','http://www.unige.ch/sciences/chifi/', 
					'chimie minérale, analytique et appliquée','http://www.unige.ch/sciences/chiam/',
					'','',
					'professeurs','http://www.unige.ch/sciences/devlo/partages/contacts_fr.htm?port=rech&hl=1#prof');             
  
  // SECTION
  document.write('<td valign="top">');
  if (num_active_portail==2) {className=classActive}
  else {className=classUnactive}  
  css_box(className,'la section','#.htm',
                    //'','',
                    'performances','#.htm', 
                    "Prix d'excellence",'#.htm',
                    '','',
                    'post-doc à la Section','#.htm',
                    '','',
                    'associations et sociétés savantes','#.htm');             
  
  // CONFERENCES
  document.write('</td><td valign="top">');
  if (num_active_portail==3) {className=classActive}
  else {className=classUnactive}
  css_box(className,'conférences','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=rech&hl=3&pres=list',
                    //'','',
                    'biochimie','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=rech&hl=3&pres=list&dept=bioch',
                    'chimie physique','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=rech&hl=3&pres=list&dept=chiphy',
                    'chimie organique','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=rech&hl=3&pres=list&dept=chior',
                    'chimie minérale, analytique et appliquée','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=rech&hl=3&pres=list&dept=chiam');
                                        
  // EN COMMUN
  document.write(' </td><td valign="top">');
  if (num_active_portail==4) {className=classActive}
  else {className=classUnactive}  
  css_box(className,'en commun','#.htm',
                    //'','',
                    'bibliothèque','http://www.unige.ch/biblio/sciences2/', 
                    'magasin central','http://www.unige.ch/sciences/chimie/magasin/',
                    'audio-visuel','#.htm',
                    'salles de cours','#.htm',
                    'problèmes techniques','#.htm',
                    '','',
                    'sécurité','http://www.unige.ch/sciences/devlo/partages/securite_fr.htm?port=rech&hl=4');
  

  document.write('</td></tr></table>');
}

// *****************************************************************************************
// crée un tableau contenant 4 css_box -> function css_box()
// SOCIETE
// *******
function portail_societe(num_active_portail){
  document.write('<table width="'+tableSize+'" border="0" cellspacing="0" cellpadding="0">');
  
  // VOUS ET NOUS
  document.write('<tr><td valign="top">');
  if (num_active_portail==1) {className=classActive}
  else {className=classUnactive}  
  css_box(className,'vous & nous','#.htm',
                    //'','',
                    "visites d'entreprises",'#.htm',
                    'tête-à-têtes','#.htm',
                    'revue de presse','#.htm',
                    'dernières nouvelles','#.htm',
                    'colloques publics','http://www.unige.ch/sciences/devlo/partages/conferences.php?port=soc&hl=1&pres=list&dept=gen');
                                        
  // QUELQUES CHIFFRES
  document.write('</td><td valign="top">');
  if (num_active_portail==2) {className=classActive}
  else {className=classUnactive}
  css_box(className,'quelques chiffres','#.htm',
                    //'','',
                    'étudiants & enseignants','#.htm', 
                    'chercheurs & publications','#.htm', 
                    'horizon 2010','#.htm');             
  
  document.write('</td><td valign="top">');
  if (num_active_portail==3) {className=classActive}
  else {className=classUnactive}
  css_box(className,'','#',
                    '','',
                    '','#',
                    '','#',
                    '','#');
  
  document.write('</td><td valign="top">');
  if (num_active_portail==4) {className=classActive}
  else {className=classUnactive}
  css_box(className,'','#',
                    '','',
                    '','#',
                    '','#',
                    '','#');
  

  document.write('</td></tr></table>');
}

// *****************************************************************************************
// crée un tableau contenant 2 css_box -> function css_box()
// PORTAIL MOBILE (RESOLUTION < 800/600)
// *************************************
function portail_pda(){
  document.write('<table width="320" border="0" cellspacing="0" cellpadding="0">');
  
  // CONFERENCES
  document.write('<tr><td valign="top">');  
  css_box(classUnactive,'conférences','http://www.unige.ch/sciences/chimie/conferences.php?pres=line', 
                        'biochimie','http://www.unige.ch/sciences/chimie/conferences.php?pres=line&dept=bioch', 
                        'chimie physique','http://www.unige.ch/sciences/chimie/conferences.php?pres=line&dept=chiphy', 
                        'chimie organique','http://www.unige.ch/sciences/chimie/conferences.php?pres=line&dept=chior',
                        'chimie minérale, analytique et appliquée','http://www.unige.ch/sciences/chimie/conferences.php?pres=line&dept=chiam');

                         
  
  // HORAIRES
  document.write('</td><td valign="top">');  
  css_box(classUnactive,'horaires pdf','#',
                        'BSc 1er','../pdf/grilles_horaires/BSc-1ere-hiver-2005-2006.pdf',
						'BSc 2er','../pdf/grilles_horaires/BSc-2eme-hiver-2005-2006.pdf',
						'BSc 3er biochimie','../pdf/grilles_horaires/BSc-chimie-3eme-hiver-2005-2006.pdf',
						'BSc 3er chimie','../pdf/grilles_horaires/BSc-biochimie-3eme-hiver-2005-2006.pdf',
                        'MSc en biochimie','../pdf/grilles_horaires/Cours-MSc-chimie-2005-2006.pdf',						
						'MSc en chimie','../pdf/grilles_horaires/Cours-MSc-biochimie-2005-2006.pdf');                                       
						 
  document.write('</td></tr></table>');
}

