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 == 1){
		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 ) {
		
		//alert(section.indexOf("/"));
		var mysection = section;
		//makemysection(mysection);
		
		
		mysectionX = section;
		sliceIndex1 = section.indexOf("/");
		mysection2 = section.slice(0,sliceIndex1);
		//alert(mysection2+ " = 1<br />");
		sliceIndex2 = section.indexOf("/",sliceIndex1+1);
		mysection3 = mysectionX.slice(sliceIndex1+1,mysectionX.indexOf("/",sliceIndex1+1));
		if(mysection2 == mysection3){
			//alert("Ga verder met huidig script!");
			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);
		}else{
			//alert(mysection3 + " = 5<br />");
			sliceIndex3 = section.indexOf("/",sliceIndex2+1);
			mysection4 = mysectionX.slice(sliceIndex2+1,mysectionX.indexOf("/",sliceIndex3));
			if(mysection4 == '')mysection4 = "";
			//alert(mysection4 + " = 7<br />");
			sliceIndex4 = section.indexOf("/",sliceIndex3+1);
			mysection5 = mysectionX.slice(sliceIndex3+1,mysectionX.indexOf("/",sliceIndex4));
			if((mysection5 == '')||(mysection4 == '')) mysection5 = "";
			//alert(mysection5 + " = 9<br />");
			
			var hoofd_sectie = mysection2;
			var hoofd_sectieId = mysection3;
			
			var sub_sectie = mysection4;
			var sub_sectieId = mysection5;
		}
		
		
		
		
		
		
		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);
		PageTopScroller();
		
		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", load_artikelen_kolom_1);
			  else ajaxObj.call("T=loadAccount&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
			ajaxObj.call("T=categorie_loadKolom2&section=" + hoofd_sectieId + "&pagina=" + sub_sectieId, load_kolom_2); // zie onder yahoo gedeelte
			$('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 + "&zoek="+sub_sectie, 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 == 'zoeken') {
			ajaxObj.call("T=zoeken&zoeknaar=" + hoofd_sectieId + "&pagina=" +sub_sectie, load_artikelen_kolom_1);
		}
		if(hoofd_sectie == 'vindArtikel') {
			allTogglesOnPage(hoofd_sectieId);
			ajaxObj.call("T=vindArtikel&zoekwoord="+sub_sectie, 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();
    }
}
