// last update 24 January 2012
//	-----------------------------------------

// controleer de validatie
// tekst niet meer nodig in versie 2 check ook de selection pages huidige PHP werkt misschien ook als de extra validatie wordt toegevoegd

	function valCode()
	{
		cv=document.emailform.ctrlveld.value ;
	  	if (cv == "AA2401"){
	  	return true                       ;
	    }else
		return false                      ;
}



// -----------------------------------------------------------------------------
// display number of CheckBoxes that are checked in a form for picture selection
// highlite the selcted boxes
 
function dispSelected ()
{
  var totalChecked = 0;
  var selectedPix = "";
  var hiLite = "yellow";
 	var tr = document.getElementsByTagName('label');


  var color1='silver';    // original background 
  var color2='#eee';      // original text 

// loop through all checkboxes	
 	
for (var i = 0; i < document.forms[0].elements['ckbox[]'].length; i++)
    {

        if (document.forms[0].elements['ckbox[]'][i].checked == true) 		//check the state
        {
           totalChecked += 1;
           
// make string with the selected filenames	           
// selectedPix = selectedPix  + document.forms[0].elements['ckbox[]'][i].value + ", ";

           if		(totalChecked <= 5)       {hiLite='#ddffee';}                      
           else if	(totalChecked <= 10)  {hiLite='#ffffcc';} 
           else                           {hiLite='#ffbbaa';}

// selected: update the [i] item           
        tr[i].style.color="black";             
        document.getElementById('dispCount').style.backgroundColor=hiLite;                                 
        }  // end selected block
	
		else
        {
// not-selected: update the [i] item
        tr[i].style.color=color1;
        hiLite=           color2;		
        }
		
        tr[i].style.backgroundColor=hiLite;
    } // end loop
    
           if		(totalChecked == 0)  document.getElementById('dispCount').style.backgroundColor=hiLite;			

//alert (totalChecked);
	
document.getElementById('dispCount').innerHTML = totalChecked;

}
 
 
//  09-01-2011
//
//  This function calculates space needed by Tumbnails
//  and sets the DIV width for an integer number of of thumbs
//  Thus as the DIV is centered, also the thumbs are
//  Content   is the div to be resized
//  Container is the reference size
//
//  SHOULD BE POSSIBLE TO GET THUMB WIDTH + MARGIN + PADDING + BORDER
 
function DivCenter(param1,param2){
  

	var tmb_w		= param1;                                  // get thumb width
	var tmb_total	= param2;                                  // get total number of thumbs
	
 	tmb_total		= Math.max  (3,tmb_total);				// force a minimum width to accomodate header
//c

//document.write (' thumb width: ' + tmb_w + ' number of thumbs: ' + tmb_total  + '<br>' );

    var DivContainer = document.getElementById("Container");    // object Container
    var ContainerWidth = DivContainer.offsetWidth;	

//document.write ('Container width: ' + ContainerWidth +  '<br>' );	
	 
    var DivContent = document.getElementById("Content");    // object Content
    	    
    var initDivWidth = DivContent.offsetWidth;				// there may be small diferences invarious browsers,
													// due to implmentation of the box-model padding, border

	
	var myWidth = (ContainerWidth * .99 );			// use 99% of the window ***
		
	var tmb_fit = Math.floor (myWidth / tmb_w);		// rounded number of thumbs fitting in row (myWidth)
	var tmb_row = Math.min  (tmb_fit,tmb_total);	// use actual number of thumbs if it is less	
	
	var div_w = tmb_w * tmb_row;                    // exact width needed for one row 
	
	div_w = div_w + 5;                               // add the right padding (see css)
                
    DivContent.style.width = (div_w) +"px";
	
//document.write ('<p>Recalculated window width: ' + tmb_row + ' ' + div_w +  '</p><br>' );	
      	
    }

