    
    var DLPreq;
    var diveType;
    
    function getRandomImages() {
	  document.getElementById('PicContainer').style.display = "none";
      try {
        if( window.XMLHttpRequest ) {
          DLPreq = new XMLHttpRequest();
        } else if( window.ActiveXObject ) {
          DLPreq = new ActiveXObject( "Microsoft.XMLHTTP" );
        } else {
          alert( "Ihr Webbrowser unterstuetzt leider kein Ajax!" );
        }
		var toOpen = "randomimages_xml.php?zn=" + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds();
        DLPreq.open( "POST", toOpen , true );
        DLPreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        DLPreq.onreadystatechange = fillNewImages;
        DLPreq.send( 'var=1' );
      } catch( e ) {
        alert( "Fehler: " + e );
      }
    }
	
	function getRandomVideos() {
	  document.getElementById('VidContainer').style.display = "none";
      try {
        if( window.XMLHttpRequest ) {
          DLPreq = new XMLHttpRequest();
        } else if( window.ActiveXObject ) {
          DLPreq = new ActiveXObject( "Microsoft.XMLHTTP" );
        } else {
          alert( "Ihr Webbrowser unterstuetzt leider kein Ajax!" );
        }
		var toOpen = "randomvideos_xml.php?zn=" + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds();
        DLPreq.open( "POST", toOpen , true );
        DLPreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        DLPreq.onreadystatechange = fillNewVideos;
        DLPreq.send( 'var=1' );
      } catch( e ) {
        alert( "Fehler: " + e );
      }
    }
    
    function getRandomDives(type) {
        if (type == 'withPictures') { document.getElementById('withPictures').innerHTML = '<img src="img/wait.gif" style="margin-left: 150px; margin-top: 50px;">' }
        if (type == 'withMaps') { document.getElementById('withMaps').innerHTML = '<img src="img/wait.gif" style="margin-left: 150px; margin-top: 50px;">' }
      try {       
        if( window.XMLHttpRequest ) {
          DLPreq = new XMLHttpRequest();
        } else if( window.ActiveXObject ) {
          DLPreq = new ActiveXObject( "Microsoft.XMLHTTP" );
        } else {
          alert( "Ihr Webbrowser unterstuetzt leider kein Ajax!" );
        }
		var toOpen;

		if (type == 'withPictures') toOpen = "randomdives_xml.php?type=withPictures&zn=" + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds();
		else if (type == 'withMaps') toOpen = "randomdives_xml.php?type=withMaps&zn=" + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds();
		
		//alert(toOpen);
        DLPreq.open( "POST", toOpen , true );
        DLPreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');        
        if (type == 'withPictures') { DLPreq.onreadystatechange = fillNewDivesPics; }
        if (type == 'withMaps') { DLPreq.onreadystatechange = fillNewDivesMaps; }
        DLPreq.send( 'var=1' );
		} catch( e ) {
        alert( "Fehler: " + e );
      }
    }
    
    
    function fillNewImages() {
      if( 4 == DLPreq.readyState ) {
        if( 200 != DLPreq.status ) {
          alert( "Fehler " + DLPreq.status + ": " + DLPreq.statusText );
        } else {
         
          var XML = DLPreq.responseXML
		  for (var i=0; i<XML.documentElement.childNodes.length; i++)
		  {
		    var identif = String('randomimage' + i);
          	document.getElementById(identif).innerHTML = '<img style="cursor: pointer;" src="thumb_gen_rand.jpg?pic=pictures/' + XML.documentElement.childNodes[i].getAttribute('user') + '/' + XML.documentElement.childNodes[i].getAttribute('filename') + '" onclick="showPic(\'randomimage' + i + '\',\'pictures/' + XML.documentElement.childNodes[i].getAttribute('user') + '/' + XML.documentElement.childNodes[i].getAttribute('filename') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('ort') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('tplatz') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('datum') + ' ' + XML.documentElement.childNodes[i].getAttribute('uhrzeit') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('picid') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('tgid') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('user') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('number') + '\')">';
			//alert(document.getElementById(identif).innerHTML);
          }
          //alert(document.getElementbyId('randomimages').innerHTML);
        }
      }
    }
    
	function fillNewVideos() {
      if( 4 == DLPreq.readyState ) {
        if( 200 != DLPreq.status ) {
          alert( "Fehler " + DLPreq.status + ": " + DLPreq.statusText );
        } else {
         
          var XML = DLPreq.responseXML
		  for (var i=0; i<XML.documentElement.childNodes.length; i++)
		  {
		    var identif = String('randomvideo' + i);

			document.getElementById(identif).innerHTML = '<img style="cursor: pointer; height: 90px;" src="' + XML.documentElement.childNodes[i].getAttribute('thumbnail') + '" onclick="showVid(\'randomimage' + i + '\', \'' + XML.documentElement.childNodes[i].getAttribute('video') + '\' , \'' + XML.documentElement.childNodes[i].getAttribute('type') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('ort') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('tplatz') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('datum') + ' ' + XML.documentElement.childNodes[i].getAttribute('uhrzeit') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('picid') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('tgid') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('user') + '\', \'' + XML.documentElement.childNodes[i].getAttribute('number') + '\')">';
          }
        }
      }
    }
	
    function fillNewDivesPics() {
      if( 4 == DLPreq.readyState ) {
                
        if( 200 != DLPreq.status ) {
          alert( "Fehler " + DLPreq.status + ": " + DLPreq.statusText );
        } else {  
          var XML = DLPreq.responseXML
		  var html;
		  html = '<ul>';
		  for (var i=0; i<XML.documentElement.childNodes.length; i++)
		  {
		   	  html = html + '<li style="margin-bottom: 5px;">';
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('profile') == '1') html = html + '<img src="img/prof_vorh.png" alt="profil" title="profil" border=0 style="vertical-align: text-bottom;">&nbsp;'
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('pictures') != '0') html = html + '<img src="img/foto_vorh.png" alt="pictures" title="pictures" border=0 style="vertical-align: text-bottom;">&nbsp;'
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('maps') == '1') html = html + '<img src="img/gmaps.png" style="vertical-align: text-bottom;" alt="Google map" title="Google map">&nbsp;'
			  
			  if (XML.documentElement.childNodes[i].getAttribute('videos') != '0') html = html + '<img src="img/video.png" style="vertical-align: text-bottom;" alt="Videos" title="Videos">&nbsp;'
				 
		      html = html + '<a href="tg.php?id=' + XML.documentElement.childNodes[i].getAttribute('tgid') + '">' +  XML.documentElement.childNodes[i].getAttribute('ort') + ' - ' + XML.documentElement.childNodes[i].getAttribute('tplatz') + '</a>';
		  }	
		  html = html + '</ul>'; 
          document.getElementById('withPictures').innerHTML = html;
        }
      }
    }
    
    function fillNewDivesMaps() {
      if( 4 == DLPreq.readyState ) {                
        if( 200 != DLPreq.status ) {
          alert( "Fehler " + DLPreq.status + ": " + DLPreq.statusText );
        } else {  
          var XML = DLPreq.responseXML
		  var html;
		  html = '<ul>';
		  for (var i=0; i<XML.documentElement.childNodes.length; i++)
		  {
		   	  html = html + '<li style="margin-bottom: 5px;">';
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('profile') == '1') html = html + '<img src="img/prof_vorh.png" alt="profil" title="profil" border=0 style="vertical-align: text-bottom;">&nbsp;'
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('pictures') != '0') html = html + '<img src="img/foto_vorh.png" alt="pictures" title="pictures" border=0 style="vertical-align: text-bottom;">&nbsp;'
		   	  
		   	  if (XML.documentElement.childNodes[i].getAttribute('maps') == '1') html = html + '<img src="img/gmaps.png" style="vertical-align: text-bottom;" alt="Google map" title="Google map">&nbsp;'
			  
			  if (XML.documentElement.childNodes[i].getAttribute('videos') != '0') html = html + '<img src="img/video.png" style="vertical-align: text-bottom;" alt="Videos" title="Videos">&nbsp;'
				 
		      html = html + '<a href="tg.php?id=' + XML.documentElement.childNodes[i].getAttribute('tgid') + '">' +  XML.documentElement.childNodes[i].getAttribute('ort') + ' - ' + XML.documentElement.childNodes[i].getAttribute('tplatz') + '</a>';
		  }	
		  html = html + '</ul>'; 
          document.getElementById('withMaps').innerHTML = html;
        }
      }
    }
    

