var req=null;
var console=null;

function addNode(el,text,url) {
  var childElul=document.createElement("ul");
  el.appendChild(childElul);
  
  var childElli=document.createElement("li");
  childElul.appendChild(childElli);
  
  var childEla = document.createElement('a'); 
  childEla.setAttribute('href',url); 
  childElli.appendChild(childEla);
  
  var txtNode=document.createTextNode(text);
  childEla.appendChild(txtNode);
  
  return childElul;
}

function addNode3(el,text,url,bold,img) {
  var childElli=document.createElement("li");
  el.appendChild(childElli);
  
  var childEla = document.createElement('a'); 
  childEla.setAttribute('href',url); 
  childElli.appendChild(childEla);
  
  if ( bold == 1 ) {
   var childElbold = document.createElement("b");
   childEla.appendChild(childElbold);   
   var txtNode=document.createTextNode(text);
   childElbold.appendChild(txtNode);  
  } else {
   //var txtNode=document.createTextNode(text);
   //childEla.appendChild(txtNode);  
   if ( img == 1 ) {
      var childElimg = document.createElement("img");
      childElimg.src="/menu/img/vermeer1.gif";
      childElimg.border = "0"; 
      childEla.appendChild(childElimg);
      var txtNode=document.createTextNode(text);
      childEla.appendChild(txtNode);  
   } else {
      var txtNode=document.createTextNode(text);
      childEla.appendChild(txtNode);  
   }
   
  }  
  return childElli;
}

function addNode2(el,text,url,bold,img) {
  var childElli=document.createElement("li");
  el.appendChild(childElli);
  
  var childEla = document.createElement('a'); 
  childEla.setAttribute('href',url); 
  childElli.appendChild(childEla); 
 
  var txtNode=document.createTextNode(text);
  childEla.appendChild(txtNode);  
       
  return childElli;
}


function initXMLHTTPRequest() {
  var xRequest=null;
  
  if (window.XMLHttpRequest){

          // If IE7, Mozilla, Safari, etc: Use native object
          xRequest = new XMLHttpRequest();

  }
  else
  {
  if (window.ActiveXObject){

          // ...otherwise, use the ActiveX control for IE5.x and IE6
          xRequest = new ActiveXObject("Microsoft.XMLHTTP");
          }

  } 
  
  return xRequest;  
}
 function sendRequest(url,params,HttpMethod) {
  if ( !HttpMethod) {
      HttpMethod="GET";
  }
   req=initXMLHTTPRequest();
   if(req) {
 
     req.onreadystatechange=onReadyState;
     req.open(HttpMethod,url,true);
     req.setRequestHeader ("Content-Type","application/x-www-form-urlencoded");
     req.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
     
     var encoded = "";
     
     req.send(encoded);	 	     
   }
 }
 
 function onReadyState() {
    var ready=req.readyState;
    var data=null;
    
   
   
    if( ready==4) {
    
       
       var theAlert = new Array();
       var theUrl = new Array();
       
       theAlert[0] = 'Akhenaten-Tell El-Amarna';   
       theUrl[0]   = 'http://www.bergerfoundation.ch/Akhenaton/en/';   
       
       theAlert[1] = 'Abydos';   
       theUrl[1]   = 'http://www.bergerfoundation.ch/Abydos/';   
           
       theAlert[2] = 'Roman Portraits from Egypt';   
       theUrl[2]   = 'http://www.bergerfoundation.ch/Fayoum/';  
       
       theAlert[3] = 'Angkor: The Divine Breath of Stones';   
       theUrl[3]   = 'http://www.bergerfoundation.ch/Angkor/index_eng.html';   
       
       theAlert[4] = 'Borobudur';   
       theUrl[4]   = 'http://www.bergerfoundation.ch/Borobudur/E/';   
       
       theAlert[5] = 'The enchanted gardens of the Renaissance';   
       theUrl[5]   = 'http://www.bergerfoundation.ch/Jardin/index_english.html';  
       
       theAlert[6] = 'Sandro Botticelli';   
       theUrl[6]   = 'http://www.bergerfoundation.ch/Sandro/1frontispice_english.html';  
       
       theAlert[7] = 'Caravaggio - The Night Prince';   
       theUrl[7]   = 'http://www.bergerfoundation.ch/Caravage/E/index.html';  
             
       theAlert[8] = 'Johannes Vermeer';   
       theUrl[8]   = 'http://www.bergerfoundation.ch/Vermeer/english/';  
       
       theAlert[9] = 'G. de la Tour';   
       theUrl[9]   = 'http://www.bergerfoundation.ch/LaTour/english/';  
       
       theAlert[10] = 'Rococo';   
       theUrl[10]   = 'http://www.bergerfoundation.ch/Vertige/english/index.html';  
       
       theAlert[11] = 'The Enlightening Remarks on Painting by Shih-T\'ao';   
       theUrl[11]   = 'http://www.bergerfoundation.ch/Shitao/enlightening.html';  
       
       theAlert[12] = 'What is an amulet?';   
       theUrl[12]   = 'http://www.bergerfoundation.ch/Amulets/germondII.html';                      
             	     
       theAlert[13] = 'Japan';   
       theUrl[13]   = 'http://www.bergerfoundation.ch/wat4/Aload12Japon2?museum=Nara&genre=Tosh&babel=en&cd=8306-3301-1765:8306-3301-1764&country=Japon&col=pays';  
       
       theAlert[14] = 'Myanmar';   
       theUrl[14]   = 'http://www.bergerfoundation.ch/wat4/Aload12Myanmar2?museum=Yangoon&babel=en&cd=6316-3031-3122&country=Myanmar&col=pays';  
       
       theAlert[15] = 'India';   
       theUrl[15]   = 'http://www.bergerfoundation.ch/wat4/Aload12Inde2?museum=Hira&babel=en&cd=7219-3282-0151:7219-3282-0150&country=Inde&col=pays';  
       
       theAlert[16] = 'China';   
       theUrl[16]   = 'http://www.bergerfoundation.ch/wat4/Aload12Chine2?museum=Jinan&genre=Falais&babel=en&cd=9060-3072-1003&country=Chine&col=pays';  
       
       theAlert[17] = 'Indonesia';   
       theUrl[17]   = 'http://www.bergerfoundation.ch/wat4/Aload12Indonesia2?museum=Borobudur&babel=en&cd=6041-1632-1017:6041-1632-1013:6316-3031-3087:6316-3031-3077&country=Indonesia&col=pays';  
       
       theAlert[18] = 'Egypt';   
       theUrl[18]   = 'http://www.bergerfoundation.ch/wat4/Aload12Egypte2?museum=Sakkara&genre=Kagemni&babel=en&cd=8193-3271-0516&country=Egypte&col=pays';  
           
       theAlert[19] = 'Turkey';   
       theUrl[19]   = 'http://www.bergerfoundation.ch/wat4/Aload12Turquie2?museum=Istanbul&genre=citerne&babel=en&cd=7285-3251-3658&country=Turquie&col=pays';  
              
      
      data=req.responseText;
      var my_param = data.split(";");     
      var pg       = my_param[1];        
      var my_url   = theUrl[pg]; 
                        
              
      
      
      while (console.firstChild) {
         console.removeChild(console.firstChild);
      }
          
      var childEla2 = document.createElement('a');
     
      childEla2.setAttribute('href',my_url);
      console.appendChild(childEla2); 
          
      message =  theAlert[pg];
      var childEltxt = document.createTextNode(message);
      childEla2.appendChild(childEltxt);  
      
      var childEltxt2 = document.createElement("br");
      console.appendChild(childEltxt2); 
           
      var childEla = document.createElement('a');         
      childEla.setAttribute('href',my_url);
      console.appendChild(childEla); 
    
      var childElimg = document.createElement("img");
      var my_src="/cgi-bin/scale2.pl?ref=" + my_param[0] + "&scale=40x40";
      childElimg.src=my_src;
      childElimg.border = "0";
      childElimg.align  = "middle";
      childEla.appendChild(childElimg);             
    
      
     
    } 
 }

  

function my_init() {                
       console=document.getElementById('foo5');
       sendRequest("/wat1/Itineraries.pl",1);                    
   };   

