/*
*	Copyright © 2005-2006 JP Productions
*	Auteur: Jean-Paul Lankhorst
*/

//================================
//var url = "http://www.haphaphap.nl/infolinx/site/random_images/"; //zonder slash ( / ) aan het eind
var plaatjesPerMap = 9; // -1 rekenen
var slideShowSpeed = 500;
var crossFadeDuration = 3;
var adb = -1;

var algemeneteller = 0;
//================================

var Pic = new Array(); 


var sShow = new Array(4);
sShow[0] = new Array(5);
sShow[0][0] = 1 
sShow[0][1] = 1;
sShow[0][2] = 'j'; // indicator of het plaatje mag faden (de 1e x begint plaatje 1)

sShow[1] = new Array(5);
sShow[1][0] = 2;
sShow[1][1] = 1;
sShow[1][2] = 'n'; // indicator of het plaatje mag faden

sShow[2] = new Array(5);
sShow[2][0] = 3;
sShow[2][1] = 1;
sShow[2][2] = 'n'; // indicator of het plaatje mag faden


sShow[3] = new Array(5);
sShow[3][0] = 4;
sShow[3][1] = 1;
sShow[3][2] = 'n'; // indicator of het plaatje mag faden


function runSlideShow(a){
	
	//if (document.all){
	 // alert(document.getElementById(sShow[a][0]).src);

		adb =a;
		
		if(a == 3)
		{
			slideShowSpeed = 1500;
		}
		
		algemeneteller++;
		
			//alert("1: "+sShow[0][3]+" - 2: "+sShow[1][3]+" - 3: "+sShow[2][3]+" - Aantal: "+z);

			nieuwGetal(sShow[0][3],sShow[1][3],sShow[2][3],sShow[3][3],z);			
			
			
			
	if (document.all){
	  document.getElementById(sShow[a][0]).style.filter="blendTrans(duration=2)"
	  document.getElementById(sShow[a][0]).style.filter="blendTrans(duration=crossFadeDuration)"
	  document.getElementById(sShow[a][0]).filters.blendTrans.Apply()      
	}
      
	  
   document.getElementById(sShow[a][0]).src = Pic[sShow[a][3]];
   
   	 // alert(document.getElementById(sShow[a][0]).src);

   
   if (document.all){
      document.getElementById(sShow[a][0]).filters.blendTrans.Play()
   }
   
   
   
   if (sShow[a][1] > (sShow[a][2]-1))    sShow[a][1]=1

   
   sShow[a][2] = 'n';
   
   
   	if(sShow.length == a+1)
	{
		sShow[0][2] = 'j';
		t = setTimeout("runSlideShow(0)", slideShowSpeed);
	}
	else
	{
		sShow[a+1][2] = 'j';
		t = setTimeout("runSlideShow("+(a+1)+")", slideShowSpeed);	
	}	    
      
}

	function runSlideShows(dir)
	{
	var s
  	 s = setTimeout("runSlideShow(0,'"+dir+"')", slideShowSpeed);
	}
	
	function createImage(dir)
	{
	//document.writeln("<img src='"+url+"/"+dir+"/"+start+"/c_"+checkRandom()+".jpg' id='"+start+"' width='51' height='51'>");
	//document.writeln("<td height='51' rowspan='2'><img src='"+url+"/"+dir+"/"+start+"/c_"+checkRandom()+".jpg' id='"+start+"' width='51' height='51'></td>");
	
	//document.getElementById(id).src = url+"/"+dir+"/"+start+"/c_"+checkRandom()+".jpg";
	}
	
	//Controleert of het gekozen random nr valide is
	function checkRandom()
	{
		var randomNr;	
		randomNr = Math.round(Math.random()*plaatjesPerMap);

		if(randomNr == 0)
		{
		randomNr = 1;
		}
		return randomNr;
	}	
	
	
        var url= ""; // The server-side script 
		var http = getHTTPObject(); // We create the HTTP Object 
		
       function handleHttpResponse() 
	   {    
			if (http.readyState == 4) 
			{ 
				  if(http.status==200) 
				  { 
					var results=http.responseText;
					
					
						if(results != "")
						{
							
							sShow[adb][3] = results;
							
						}
					  
				  } 
			}
        }
		

		
		function nieuwGetal(a,b,c,d,aantal) {   
		
			url =  "getrand1.php";
					
			parameters = "aantal="+aantal+"&a="+a+"&b="+b+"&c="+c+"&d="+d;
			

			
			
			http.open("POST",url, true);
            
            http.onreadystatechange = handleHttpResponse; 
			
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length", parameters.length);
			http.setRequestHeader("Connection", "close");
			http.send(parameters); 					
        } 
		
			function getHTTPObject() { 
		  var xmlhttp; 
		
		  if(window.XMLHttpRequest){ 
			xmlhttp = new XMLHttpRequest(); 
		  } 
		  else if (window.ActiveXObject){ 
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
			if (!xmlhttp){ 
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
			} 
		} 
		  return xmlhttp; 
		} 
		
