/*************************************************************
*  JavaScript to implement a slider
*  ================================
*  WEBSITE
*  
*
*  Function Written by Thijs van der Laan 6-12-2004
*	 version 1.1 dd 19-12-2004 (pijl links leeg update)
*
**************************************************************/
var	SliderEntry = "";
var BaseURL = "";
var URLExtention="";
var nrPages = 0;
var ImgPath = "";
var CurrPag = 0;		//current page

/*************************************************************
*  Function to write slider
*
*	parameter 1 = the width of the total slider
* parameter 2 = nr of selectionsquares -> nr of Pages
* parameter 3 = is path to images
* parameter 4 = path to base page name like ../pages/pagenr
* parameter 5 = extention like .htm or .html (or  php, summer 2006)
*
*	later it is edited as ../page/pagenr12.htm if the pagenr is 12
*
**************************************************************/
function WriteSlider(Breedte,Nr, Imgx,BasePage, Extend)
{
	BaseURL=BasePage;
	URLExtention= Extend;

	px=document.location.pathname
	pix=px.split(".");
	py=pix[0];
	
	CurrPag=+py.substr(py.length-2,2);
	
	if(Nr!="0")
	{
			
		Wd = Math.round(Breedte/Nr);
		if(Nr>0)
		{
	    sHTML='<td width="'+Breedte+'" height="14" align="left" valign="bottom" ID="yep"><table width="'+Breedte+'" border="0" cellpadding="0" cellspacing="0" background="'+Imgx+'schuifbalk_deel.gif" onMouseOut="OutTable()">'
      sHTML=sHTML+'<tr>';
	    xHTML="";
	    
   		for(i=0;i<Nr;i++)
   		{
      	xHTML=xHTML+'<td width="'+Wd+'"><a href="#"><img src="'+Imgx+'spacer.gif" width="'+Wd+'" height="14" border="0" usemap="#Map" onMouseOver="Ssx(\''+i+'\')" onMouseDown="Lp(\''+i+'\')"></a></td>';
      }
      document.write(sHTML+xHTML+"</tr></table></td>");
      if(CurrPag>0)
      {
      	document.write('<td width="10" height="14" align="left" valign="bottom"><a Href="javascript:SliderBack()"><img src="'+Imgx+'schuifbalk_pijl_links.gif" width="10" height="14" border="0"></a></td>');
      }
    	else
    	{
      	document.write('<td width="10" height="14" align="left" valign="bottom"><img src="'+Imgx+'schuifbalk_pijl_links_leeg.gif" width="10" height="14" border="0"></td>');
      }

     	document.write('<td width="16" height="14" align="center" valign="middle" background="'+Imgx+'schuifbalk_cijfer.gif" class="cijfer_blz" Id="sSlider"><a href="#">'+CurrPag+'</a>');

      if(CurrPag<Nr-1)
      {
      	document.write('<td width="17" height="14" align="left" valign="bottom"><a Href="javascript:SliderNext()"><img src="'+Imgx+'schuifbalk_pijl_rechts.gif" width="17" height="14" border="0"></a></td>');
      }
    	else
    	{
      	document.write('<td width="17" height="14" align="left" valign="bottom"><img src="'+Imgx+'schuifbalk_leeg_rechts.gif" width="17" height="14" border="0"></td>');
    	}
      nrPages = +Nr;
    }
   }
   OutTable();				//init pagenr in correct color
}
/*************************************************************
*  Function to Set Slider attributes
*
* it will search for the field to update the pagenumber, is innertext
* with id "sSlider". It will extract the current pagenumber from
* the name of the current page and put this in the page field
* The index to the object is saved in SliderEntry
**************************************************************/
function SetSlider()
{

  nrx = document.all.length;
	for(i=0;i<nrx;i++)
	{
			if(document.all[i].id=="sSlider")
			{
				SliderEntry = i;
				return;
			}
	}	
}
/*************************************************************
*  Function to display the pagenr in pagefield
*
*	parameter 1 = Pagenr to display
* The index to the object is present in SliderEntry
* If not the FindSlider routine is called
**************************************************************/
function Ssx(Nr)
{
	if(SliderEntry=="")
	{
		SetSlider();
	}
	
	document.all[SliderEntry].innerText=Nr;
}	

/*************************************************************
*  Function to load a page selected from slider
*
*	parameter 1 = Pagenumber
* The Base URL Path plus the pagenr .html is loaded
* The extention is taken from URLExtention
**************************************************************/
function Lp(PageNr)
{
	Pn=+PageNr;
	
	if(Pn<10)
	{
		Pn="0"+Pn;
	}
	window.location.href=BaseURL+Pn+URLExtention;
}
/*************************************************************
*  Function to load previous page
*
**************************************************************/
function SliderBack()
{
	CurrPag = +CurrPag-1;
	if(CurrPag <0)
	{ 
		CurrPag =0;
		return;
	}
	Lp(CurrPag);
}
/*************************************************************
*  Function to load previous page
*
**************************************************************/
function SliderNext()
{
	CurrPag = +CurrPag+1;
	if(CurrPag > +nrPages-1)
	{ 
		CurrPag = +nrPages-1;
		return;
	}
	Lp(CurrPag);
}	
/*************************************************************
*  Function called when mouse exists table
*
**************************************************************/
function OutTable()
{
	Ssx(CurrPag);
}