// Twing IT 2009 010 - 433 43 16 info at twing nl
	  var allImages = new Array();
	  var imageBorders = new Array();
	  var superSizers = new Array();

	  // default
	  var pageCount=6;
      var iconwidth=100;
      var iconheight=100;
      var mainimagewidth=560;
      var mainimageheight=321;
	  var forcesize = 1;
	  var systempath="";

	  var startSeq=0;
	  var totalImages = 0;
	  var dicount=0;
	  var login_ok = false;

	  
	  function general_initialize(){
	    try {
		    if(initPopUp)
			  initPopUp();
			  
			if(setLinkState)
			  setLinkState();
			  
			  
		   if(text_select)
		    text_select(0);
		  
		  	if(homepage_start)
		    homepage_start();
		} catch(e) {
			// unhandled exception
		}
	  }
	  
	  window.onload=general_initialize;
	  

      function preloadImages(fromSeq, toSeq){

	    for(i=0;i<pageCount;i++){
	      //load mouse over images
	      var tmpImage = new Image();
		  tmpImage.src=iconMouseOverSrc(allImages[i]);
	    }
	  }

	  var dblClickCount = 0;
	  function OpenLoginDblClick(){
	    dblClickCount++;
		// no double double click needed when logged in
		if(login_ok || dblClickCount>=2){
		  //open admin window
          showPopWin(systempath+'_twing!/admin.php?pid='+pid, 540, 600, null);
		  dblClickCount=0;
		}
		
	  }
	  
	  function zoekWoorden() {
		showPopWin(systempath+'_twing!/adminkeywords.php?pid='+pid, 540, 300, null);
	  }

	  function deletePage(page_id, menu_id){
        showPopWin(systempath+'_twing!/admindelete.php?page_id='+page_id+'&menu_id='+menu_id, 540, 600, null);	    
	  }

	  function addPage(template){
        showPopWin(systempath+'_twing!/admin.php?page_action=add'+template, 540, 600, null);
	  }
	  
	  
	  function mainImageSrc(src, has_border, supersize){
	    return systempath+'images/get.php?mouseover=0&forcesize='+forcesize+'&width='+mainimagewidth+'&height='+mainimageheight+'&border='+has_border+'&supersize='+supersize+'&src='+src;	  
	  }
	  
	  function iconMouseOverSrc(src){
	    return systempath+'images/get.php?mouseover=1&width='+iconwidth+'&height='+iconheight+'&border=1&src='+src;
	  }

	  function iconNormalSrc(src){
	    return systempath+'images/get.php?mouseover=0&width='+iconwidth+'&height='+iconheight+'&border=1&src='+src;
	  }
	  
	  function dummyIconSrc(){
	    return systempath+'images/get.php?mouseover=0&width='+iconwidth+'&height='+iconheight+'&border=0&src=wit.gif';
	  }

	  function setMainImage(imgSeq){
	    if(allImages[imgSeq+startSeq-dicount]&&(imgSeq>=dicount)){
	    document.getElementById('mainimage').src=mainImageSrc(allImages[imgSeq+startSeq-dicount], imageBorders[imgSeq+startSeq-dicount], superSizers[imgSeq+startSeq-dicount]);
		
		}
	  }

	  function mouseOverIcon(imgSeq){
	    if(allImages[imgSeq+startSeq-dicount]&&(imgSeq>=dicount)){
	    var icoImage = document.getElementById('icon'+imgSeq);
		if(icoImage)
	       icoImage.src=iconMouseOverSrc(allImages[imgSeq+startSeq-dicount]);
		}
	  }

	  function mouseOutIcon(imgSeq){
	    if(allImages[imgSeq+startSeq-dicount]&&(imgSeq>=dicount)){
	    var icoImage = document.getElementById('icon'+imgSeq);

		if(icoImage)
	       icoImage.src=iconNormalSrc(allImages[imgSeq+startSeq-dicount]);
		}
	  }

	  function previousImages(){
	    startSeq+=-1*pageCount;
        reloadLib();  
	  }
	  
	  function nextImages(){
	  startSeq+=pageCount;
        reloadLib();
	  }
	  
	  function setLinkState(args){
	    var  bl = document.getElementById('backlink');
	    if(bl)
	      bl.style.display=(startSeq>=pageCount?'inline':'none');
		  var fl = document.getElementById('forwardlink');
		if(fl)
	      fl.style.display=((startSeq+pageCount)<totalImages?'inline':'none');


	  }
	  
	  

	  
	  function reloadLib(){

		dicount=0;
		setLinkState(true);
		
		if(startSeq+pageCount>=totalImages){
		  dicount=startSeq+pageCount-totalImages;

		  for(i=0;i<dicount;i++){
		     var tmpIcon = document.getElementById('icon'+i);
			  tmpIcon.src=dummyIconSrc();
			  tmpIcon.parentNode.style.cursor='default';
		   }
		}
	  
	  	for(i=(startSeq+dicount);i<(startSeq+pageCount);i++){
		  var tmpIcon = document.getElementById('icon'+(i%pageCount));

		  if(tmpIcon){
		    if(allImages[i-dicount]){
			  var preloadedImage = new Image();
			  preloadedImage.src=iconMouseOverSrc(allImages[i-dicount]);
		      tmpIcon.src=iconNormalSrc(allImages[i-dicount]);
			  tmpIcon.parentNode.style.cursor='hand';
			}else{
			  // create a dummy at last image
			  tmpIcon.src=dummyIconSrc();
			  tmpIcon.parentNode.style.cursor='default';
			  }
		  }
		}
	  }
	  
	
	var last_overviewblock = 0;
	function shoverview(block_id)
	{
		// Set selected textblock as active
		var newblock, oldblock;
		if(newblock = document.getElementById('overviewblock' + block_id)) {

		
			// Hide previous block
			if(oldblock = document.getElementById('overviewblock' + last_overviewblock)) {
				oldblock.style.display = 'none';
				last_overviewblock = block_id;
			}
			newblock.style.display = 'inline';
		}	
	}
	  
	  var last_textblock_id = 0;
	  



	  function text_select(id)
	  {

	    // Set selected textblock as active
		var newblock, oldblock;
		if(newblock = document.getElementById('textblock' + id)) {

		
			// Hide previous block
			if(oldblock = document.getElementById('textblock' + last_textblock_id)) {
				oldblock.style.display = 'none';
				last_textblock_id = id;
			}
			newblock.style.display = 'inline';
		}
		sync_project_text_nav();
		sync_text_nav_buttons();
	  }

	  function sync_text_nav_buttons() 
	  {

		try {
		    if(typeof(last_info_id)!="undefined"){
		  
				// Next page visible?
				if(last_textblock_id < last_info_id) {
					document.getElementById('pageforward').style.display = 'inline';
				} else {
					document.getElementById('pageforward').style.display = 'none';
				}
				
				// Prev page visible?
				if(last_textblock_id > 0) {
					document.getElementById('pageback').style.display = 'inline';
				} else {
					document.getElementById('pageback').style.display = 'none';
				}		
			}
		} catch(e) {
			// unhandled
		}			
	  }
	  
	  function pageBack()
	  {
		// Page back
		if(last_textblock_id > 0) {
			text_select(last_textblock_id - 1);
		}
	  }
	  
	  function pageForward()
	  {
		// Page back
		if(last_textblock_id < last_info_id) {
			text_select(last_textblock_id + 1);
		}
	  }


  
	  function sync_project_text_nav()
	  {
		try {
		    if(  typeof(first_info_id)!='undefined'){
			// Info should be active
			if(last_textblock_id < first_info_id) {
				document.getElementById('text_active').style.display = 'inline';
				document.getElementById('info_active').style.display = 'none';
			} else {
				// Projectinformatie should be active
				document.getElementById('text_active').style.display = 'none';
				document.getElementById('info_active').style.display = 'inline';
			}
			
			}
		} catch(e) {
			// unhandled
		}
	  }
	  
	  
	  function start_search()
	  {
		var searchtext = document.getElementById('searchword').value;
		if(searchtext == '') {
			return false;
		}
		var catselect = document.getElementById('cat');
		var catvalue = catselect.value;
		if(catvalue != '') {
			searchurl = systempath + 'zoek/' + catvalue + '/' + escape(searchtext);
		} else {
			searchurl = systempath  + 'zoek/' + escape(searchtext);
		}
		document.location = searchurl;
		
	  }
	  

	  