if ( location.protocol.substr( 0, 4 ) == "file" ) {
    document.write(
        'This example uses the XmlHttpRequest object and cannot be run locally.'
      + 'You must copy it to a web server and access it using HTTP.'
    );

} else {
    var bookmarkedSection = YAHOO.util.History.getBookmarkedState( "locatie" );
    var querySection = YAHOO.util.History.getQueryStringParameter( "section" );
    var initSection = bookmarkedSection || querySection || "1";
    YAHOO.util.History.register( "locatie", initSection, function( state ) {
        loadSection( state );
    } );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function allTogglesOnPage(HsectionID){
	var HsectionIDstripped = HsectionID.slice(0,1);
//	TogglesSlideshowDiv(HsectionIDstripped);
//	TogglesMeerbelastingmenuDiv(HsectionIDstripped);
}
function TogglesSlideshowDiv(HsectionID){
	if (HsectionID == 0){
		if (slideshowDivToggle == 0){
		new Effect.toggle($('slideshowDiv'),'blind',{duration:0.4});
		slideshowDivToggle = 1;
		}
	}
	 else if(slideshowDivToggle == 1){
		 new Effect.toggle($('slideshowDiv'),'blind',{duration:0.4});
		 slideshowDivToggle = 0;
	 }
}
function TogglesMeerbelastingmenuDiv(HsectionID){
	if (HsectionID == 6){
		if (meerbelastingmenuDivToggle == 0){
		new Effect.toggle($('meerbelastingmenuDiv'),'blind',{duration:0.4});
		meerbelastingmenuDivToggle = 1;
		}
	}
	 else if(meerbelastingmenuDivToggle == 1){
		 new Effect.toggle($('meerbelastingmenuDiv'),'blind',{duration:0.4});
		 meerbelastingmenuDivToggle = 0;
	 }
}



	function buildSection( section ) {
		var hoofd_sect = section.slice(0,section.indexOf("+"))
		var sub_sect = section.slice(section.indexOf("+")+1,section.length)
		
		var hoofd_sectie = hoofd_sect.slice(0,hoofd_sect.indexOf("-"))
		var hoofd_sectieId = hoofd_sect.slice(hoofd_sect.indexOf("-")+1,hoofd_sect.length)
		
		var sub_sectie = sub_sect.slice(0,sub_sect.indexOf("-"))
		var sub_sectieId = sub_sect.slice(sub_sect.indexOf("-")+1,sub_sect.length)
		
		if((slideshowDivToggle == 1)&&(hoofd_sectieId != 1)){new Effect.toggle($('slideshowDiv'),'blind',{duration:0.4});slideshowDivToggle = 0;}		
		if(plaatsArtikelScherm == 1){new Effect.toggle($('plaats_artikel'),'blind',{duration:0.4}); plaatsArtikelScherm = 0;}
		if(bewerkArtikelScherm == 1){new Effect.toggle($('Bewerk_artikel'),'blind',{duration:0.4}); bewerkArtikelScherm = 0;}
		if(plaatsReactieScherm == 1){new Effect.toggle($('plaats_reactie'),'blind',{duration:0.4}); plaatsReactieScherm = 0;}
		if(plaatsFilmpjeScherm == 1){new Effect.toggle($('plaats_filmpje'),'blind',{duration:0.4}); plaatsFilmpjeScherm = 0;}
		if(stuurdoorScherm == 1){new Effect.toggle($('stuurdoor_div'),'blind',{duration:0.4}); stuurdoorScherm = 0;}
		
		ajaxObj.format = "TEXT"; 
		//alert("sectie="+sectie +" en sectieId="+sectieId);
		
		
		//alert(hoofd_sectieId);
		
		if(hoofd_sectie == 'saveLink') {
			allTogglesOnPage(hoofd_sectieId);
		}
		
		if(hoofd_sectie == 'loadAccount') {
			allTogglesOnPage(hoofd_sectieId);
			//ajaxObj.format = "TEXT"; 
			if(hoofd_sectieId == 9)	ajaxObj.call("T=account_mijnaccount&accountid="+sub_sectie, load_artikelen_kolom_1);
			  else ajaxObj.call("T=loadAccount&accountid="+sub_sectie+"&melding=" + hoofd_sectieId, load_artikelen_kolom_1);
			  
			//ajaxObj.call("T=loadAccount", load_artikelen_kolom_1);
			ajaxObj.call("T=loged_status", loged_status_change);
			ajaxObj.call("T=loadAccountKol2", load_kolom_2);
			//loadAccount('');
/*			$('menu'+1).style.color='#ffffff';	
			$('menu'+2).style.color='#ffffff';	
			$('menu'+3).style.color='#ffffff';	
			$('menu'+5).style.color='#ffffff';	
			$('in_uitloggen').style.color='#CCCCCC';	
*/
}
		if(hoofd_sectie == 'account_mijnartikelen') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=account_mijnartikelen&CatID="+sub_sectieId, load_artikelen_kolom_1);
			ajaxObj.call("T=loadAccountKol2", load_kolom_2);
		}
		if(hoofd_sectie == 'account_mijnreacties') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=account_mijnreacties", load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'wachtwoord_vergeten') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=wachtwoord_vergeten", load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'wachtwoord_vergeten_verstuur') {
			allTogglesOnPage(hoofd_sectieId);
			var formVars = ajaxObj.getForm('wachtwoord_vergeten_verstuur');
			ajaxObj.call('T=wachtwoord_vergeten&'+formVars, load_artikelen_kolom_1);	
		}
		
		if (hoofd_sectie == 'categorie'){
			live_categorie = hoofd_sectieId;
			/*
			$('menu'+1).style.color='#ffffff';	
			$('menu'+2).style.color='#ffffff';	
			$('menu'+3).style.color='#ffffff';	
			$('menu'+5).style.color='#ffffff';	
			$('in_uitloggen').style.color='#ffffff';	
			$('menu'+hoofd_sectieId).style.color='#CCCCCC';	
			*/
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=loadArtikelen&section=" + hoofd_sectieId + "&pagina=" + sub_sectieId, load_artikelen_kolom_1); // zie onder yahoo gedeelte
			if(hoofd_sectieId!=1)ajaxObj.call("T=categorie_loadKolom2&section=" + hoofd_sectieId + "&pagina=" + sub_sectieId, load_kolom_2); // zie onder yahoo gedeelte
				else load_kolom_2('home');
			$('artikel_categorieID').value = hoofd_sectieId;
			$('reactie_categorieID').value = hoofd_sectieId;
		}
		if (hoofd_sectie == 'artikel') {
			$('reactie_artikelID').value = hoofd_sectieId;
			ajaxObj.call("T=loadArtikel_tekst&artikel_ID=" + hoofd_sectieId, load_artikelen_kolom_1);
			ajaxObj.call("T=loadArtikel_extra&artikel_ID=" + hoofd_sectieId, load_kolom_2);
		}
		if (hoofd_sectie == 'filmpje') {
			$('reactie_artikelID').value = hoofd_sectieId;
			ajaxObj.call("T=loadArtikel_tekst&filmpje_ID=" + hoofd_sectieId, load_artikelen_kolom_1);
			ajaxObj.call("T=loadArtikel_extra&filmpje_ID=" + hoofd_sectieId, load_kolom_2);
		}
		if (hoofd_sectie == 'profiel') {
			//alert("T=FillProfiel&profiel_ID=" + hoofd_sectieId);
			ajaxObj.call("T=FillProfiel&profiel_ID=" + hoofd_sectieId, load_artikelen_kolom_1);
			//ajaxObj.call("T=loadArtikel_extra&filmpje_ID=" + hoofd_sectieId, load_kolom_2);
		}
		if(hoofd_sectie == 'vindArtikel') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=vindArtikel&zoekwoord="+sub_sectie, load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'loadAccounts') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=loadAccounts&id="+hoofd_sectieId, load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'documentenlijst') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=documentenlijst", load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'documentenbeheer') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=documentenbeheer", load_artikelen_kolom_1);
		}
	}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    function loadSection( section ) {
			buildSection(section);
    }
  /*
  function initializeNavigationBar() {
        // Process links
        var anchors = YAHOO.util.Dom.get( "nav" ).getElementsByTagName( "a" );
        for ( var i=0, len=anchors.length; i<len; i++ ) {
            var anchor = anchors[i];
            YAHOO.util.Event.addListener( anchor, "click", function( evt ) {
                var href = this.getAttribute( "href" );
                var section = YAHOO.util.History.getQueryStringParameter( "section", href ) || "1";
                try {
                    YAHOO.util.History.navigate( "locatie", section );
                } catch ( e ) {
                    loadSection( section );
                }
                YAHOO.util.Event.preventDefault( evt );
            } );
        }

        var currentSection = YAHOO.util.History.getCurrentState( "locatie" );
        if ( location.hash.substr(1).length > 0 ) {
            if ( currentSection != querySection )
            loadSection( currentSection );
        }
    }
	*/
    YAHOO.util.History.onLoadEvent.subscribe( function() {
        initializeNavigationBar();
		//alert('1');
    } );
    try {
        YAHOO.util.History.initialize();
    } catch ( e ) {
        initializeNavigationBar();
    }
}
