
/***********************************************
* Set states script by J.C. Spelt (Hofstaete Kennisgroep B.V.)
***********************************************/

function hofPageStateObj() {
	/* variables */	
	this.debug=false;	
	this.paginaguid='';
	this.detailguid='';
	this.soort='';
	this.thema='';
	
	this.activeContentMenuId='';
	this.activeContentMenuImageSelectedTxt='';
	this.activeContentMenuImageMouseOverTxt='';
	
	this.activeNavMenuId='';	
	this.activeNavMenuImageSelectedTxt='';
	this.activeNavMenuImageMouseOverTxt='';
		
	this.pageHeaderImgId='';
	this.pageHeaderTxtId='';

	this.arSoort=new Array();
	this.arSoortMenuId=new Array();

	this.arThema=new Array();
	this.arThemaMenuId=new Array();
	this.arThemaMenuImg=new Array();
	this.arThemaHeaderImg= new Array();
	this.arThemaHeaderTxt= new Array();
	this.arThemaHoofdMenuId=new Array();
	
	this.arPage=new Array();
	this.arPageMenuId= new Array();
	this.arPageMenuImg= new Array();
	this.arPageHeaderImg= new Array();
	this.arPageHeaderTxt= new Array();
	this.arPageHoofdMenuId= new Array();
	
	/* functions */
	this.setPageGuid=hofSetPageGuid;
	this.addPage=hofAddPage;
	
	this.setDetailGuid=hofSetDetailGuid;
	
	this.setSoort=hofSetSoort;
	this.addSoort=hofAddSoort;

	this.setThema=hofSetThema;
	this.addThema=hofAddThema;
	
	this.setPageStates=hofSetPageStates;
	
	/* private functions */
	this.setObjectActive=hofSetObjectActive;
	this.setObjectNotActive=hofSetObjectNotActive;
	this.changeImage=hofChangeImage;
	this.changeTxt=hofChangeTxt
}

function hofSetPageGuid(guid) {
  this.paginaguid=guid;	
}

function hofAddPage(page, menuid, menuimg, headerimg, headertxt, hoofdmenuid) {
// eigenlijk 'page' nog even voorzien van accolades als dat nodig blijkt!
  var i = this.arPage.length;
  this.arPage[i]=page;
  this.arPageMenuId[i]=menuid;
  this.arPageMenuImg[i]=menuimg;  
	if(headerimg)this.arPageHeaderImg[i]=headerimg;
	if(headertxt)this.arPageHeaderTxt[i]=headertxt;
	if(hoofdmenuid)this.arPageHoofdMenuId[i]=hoofdmenuid;
}

function hofSetDetailGuid(guid) {
  this.detailguid=guid;	
}

function hofSetSoort(soort) {
  this.soort=soort;	
}

function hofAddSoort(soort, menuid) {
  this.arSoort[this.arSoort.length]=soort;
  this.arSoortMenuId[this.arSoortMenuId.length]=menuid;
}

function hofSetThema(thema) {
  this.thema=thema;	
}

function hofAddThema(thema, menuid, menuimg, headerimg, headertxt, hoofdmenuid) {
  var i = this.arThema.length;
  this.arThema[i]=thema;
  this.arThemaMenuId[i]=menuid;
  this.arThemaMenuImg[i]=menuimg;  
	if(headerimg)this.arThemaHeaderImg[i]=headerimg;
	if(headertxt)this.arThemaHeaderTxt[i]=headertxt;
	if(hoofdmenuid)this.arThemaHoofdMenuId[i]=hoofdmenuid;
}

function hofSetPageStates() {
	/* twee menu's instellen */
	var menu='';
	var menuimage='';
	var img;
	var s;
	
	/* Content Menu */
	if(this.soort!=''){
		for(i=0;i<this.arSoort.length;i++){
			if(this.arSoort[i]==this.soort){
				this.activeContentMenuId=this.arSoortMenuId[i];
			}
		}
	}
	if(this.activeContentMenuId==''){
		for(i=0;i<this.arSoortMenuId.length;i++){
			if(document.getElementById(this.arSoortMenuId[i])){
			  menu=this.arSoortMenuId[i];
			}
			if(menu!=''){
				this.activeContentMenuId=menu;
			}
		}
	}
	if(this.activeContentMenuId!='')SwitchContentMenu(this.activeContentMenuId);

	/* Navigation Menu */
	if(this.paginaguid!=''){
		for(i=0;i<this.arPage.length;i++){
			if(this.arPage[i]==this.paginaguid){
				this.activeNavMenuId=this.arPageMenuId[i];
				this.setObjectActive(this.arPageMenuImg[i], this.activeNavMenuImageSelectedTxt, '');				
				if((this.arPageHeaderImg.length>0)&&(this.arPageHeaderImg[i]!="")){				
  				this.changeImage(this.pageHeaderImgId, this.arPageHeaderImg[i]);					
				}				
				if((this.arPageHeaderTxt.length>0)&&(this.arPageHeaderTxt[i]!="")){
  				this.changeTxt(this.pageHeaderTxtId, this.arPageHeaderTxt[i]);					
				}				
				if(this.arPageHoofdMenuId.length>0){
				  this.setObjectActive(this.arPageHoofdMenuId[i], this.activeNavMenuImageSelectedTxt, '');
				}				
			}
		}
	} 
	if(this.thema!=''){
		for(i=0;i<this.arThema.length;i++){
			if(this.arThema[i]==this.thema){
				this.activeNavMenuId=this.arThemaMenuId[i];
				this.setObjectActive(this.arThemaMenuImg[i], this.activeNavMenuImageSelectedTxt, '');
				if((this.arThemaHeaderImg.length>0)&&(this.arThemaHeaderImg[i]!="")){
  				this.changeImage(this.pageHeaderImgId, this.arThemaHeaderImg[i]);					
				}				
				if(this.arThemaHeaderTxt.length>0){
  				this.changeTxt(this.pageHeaderTxtId, this.arThemaHeaderTxt[i]);					
				}				
				if(this.arThemaHoofdMenuId.length>0){
					this.setObjectActive(this.arThemaHoofdMenuId[i], this.activeNavMenuImageSelectedTxt, '');
			  }
			}
		}
	} 
	if(this.activeNavMenuId!='')SwitchNavMenu(this.activeNavMenuId);
}



function hofSetObjectActive(objId, selectedTxt, mouseoverTxt) {
	obj=document.getElementById(objId);
	if(obj){
  	if(obj.src){
  	  s = obj.src;
      if(s.substr(s.length-4-mouseoverTxt.length, mouseoverTxt.length)==mouseoverTxt) {
  	    obj.src=s.substr(0, s.length-4-mouseoverTxt.length)+selectedTxt+s.substr(s.length-4,5);
  	  } else {
  	    obj.src=s.substr(0, s.length-4)+selectedTxt+s.substr(s.length-4,5);
  	  }
  	} else {
  		if(obj.className!=''){
  	    s = obj.className;
  			obj.className=s+selectedTxt;
  		}
  	}
  }
}

function hofSetObjectNotActive(objId, selectedTxt, mouseoverTxt) {
	obj=document.getElementById(objId);
	if(obj){
  	if(obj.src){
  	  s = obj.src;
      if(s.substr(s.length-4-mouseoverTxt.length, mouseoverTxt.length)==mouseoverTxt) {
  	    obj.src=s.substr(0, s.length-4-mouseoverTxt.length)+selectedTxt+s.substr(s.length-4,5);
  	  } else {
  	    obj.src=s.substr(0, s.length-4-selectedTxt.length)+s.substr(s.length-4,5);
  	  }
  	} else {
  		if(obj.className!=''){
  	    s = obj.className;
  			obj.className=s.substr(0, s.length-selectedTxt.length);
  		}
  	}
  }
}

function hofChangeImage(objId, newSrc) {
	obj=document.getElementById(objId);
	if(obj){
  	if(obj.src){
  		obj.src=newSrc;
    } else {
    	if(obj.background){
    		obj.background=newSrc;
        } else {
    		if(obj.style.backgroundImage){
    			obj.style.backgroundImage="url("+newSrc+")";
        	}
	}
    }
	}
}

function hofChangeTxt(objId, newTxt) {
	obj=document.getElementById(objId);
	if(obj){
    obj.innerHTML=newTxt; 
	}
}

function SwitchNavMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
  	if(el) {
    	if ((el.style.display=="none")||(el.style.display=="")){
    	  var ar = document.getElementById("masternavdiv").getElementsByTagName("span"); //DynamicDrive.com change
    		if(el.style.display != "block"){ //DynamicDrive.com change
    			for (var i=0; i<ar.length; i++){
    				if (ar[i].className=="submenu") //DynamicDrive.com change
    				ar[i].style.display = "none";
    			}
    			el.style.display = "block";
    		}else{
    			el.style.display = "none";
    		}
    		
  	  }
	  }
  }
}

function CloseNavMenu(){
	if(document.getElementById){
	  if(document.getElementById("masternavdiv")){
      var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
  		for (var i=0; i<ar.length; i++){
  			if (ar[i].className=="submenu") //DynamicDrive.com change
  			ar[i].style.display = "none";
  		}
  	}
	}
}

function SwitchContentMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
    if(el) {
    	if ((el.style.display=="none")||(el.style.display=="")){
      	var ar = document.getElementById("mastercontentdiv").getElementsByTagName("span"); //DynamicDrive.com change
    		if(el.style.display != "block"){ //DynamicDrive.com change
    			for (var i=0; i<ar.length; i++){
    				if (ar[i].className=="submenu") //DynamicDrive.com change
    				ar[i].style.display = "none";
    			}
    			el.style.display = "block";
    		}else{
    			el.style.display = "none";
    		}
        if((hofPageState.activeContentMenuId!="")&&(hofPageState.activeContentMenuId!=obj)){ 
          hofPageState.setObjectNotActive("contentMenuHd_"+hofPageState.activeContentMenuId, hofPageState.activeContentMenuImageSelectedTxt, hofPageState.activeContentMenuImageMouseOverTxt);
        }
        hofPageState.setObjectActive("contentMenuHd_"+obj, hofPageState.activeContentMenuImageSelectedTxt, hofPageState.activeContentMenuImageMouseOverTxt);

        hofPageState.activeContentMenuId=obj;
      }
    }
	}
}

function HS_swapImage(imgId) {
	var img = document.getElementById(imgId);
	var s;
	if(img) {
   	s = img.src;
   	if(s.substr(s.length-4-hofPageState.activeContentMenuImageSelectedTxt.length, hofPageState.activeContentMenuImageSelectedTxt.length)!=hofPageState.activeContentMenuImageSelectedTxt) {
      img.src=s.substr(0, s.length-4)+hofPageState.activeContentMenuImageMouseOverTxt+s.substr(s.length-4,5);
    }
	}
}

function HS_swapImgRestore(imgId) {
	var img = document.getElementById(imgId);
	var s;
	if(img) {
   	s = img.src;
   	if(s.substr(s.length-4-hofPageState.activeContentMenuImageMouseOverTxt.length, hofPageState.activeContentMenuImageMouseOverTxt.length)==hofPageState.activeContentMenuImageMouseOverTxt) {
      img.src=s.substr(0, s.length-4-hofPageState.activeContentMenuImageMouseOverTxt.length)+s.substr(s.length-4,5);
    }
	}
}

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

var hofPageState = new hofPageStateObj();
