function HideRoute(divid) {
	
	if($('store_'+divid)) {
		if ($('store_'+divid).className  == 'bgstoreinfo') {
			//$('.linkroute').style.display = "block";
			//$('.formroute').style.display = "none";
			
			 if(document.getElementsByClassName){
				
				var e = document.getElementsByClassName('formroute');
				for (i = 0; i < e.length; i++) {
					e[i].style.display = 'none';
				}
			
				var e = document.getElementsByClassName('linkroute');
				for (i = 0; i < e.length; i++) {
					e[i].style.display = 'block';
				}
			
			}
	
		}
	}

}

function ShowRoute(divid) {
	
	if ($('linkroute_'+divid)) { $('linkroute_'+divid).style.display = "none"; }
	if ($('formroute_'+divid)) {$('formroute_'+divid).style.display = "block"; }
	if ($('vertrekpunt_'+divid)) {$('vertrekpunt_'+divid).value = "vertrekpunt"; }

}

function setlinkNonActive(link_id) {
	$(link_id).className = 'more';
}
function setlinkActive(link_id) {
	$(link_id).className = 'active';
}

/********** Multi-step form ******************************************/

	// A function which automatically transforms a given form with multiple
	// fieldsets, into a multi-step form with 'Next' and 'Previous' buttons
	function fSetPagingForm(oForm) {
		// Store all the nested fieldsets for quick reference
		var oFieldsets = oForm.getElements('fieldset');

		var sFormID = oForm.get('id');

		// On initiation, display the first fieldset and hide the form's submit button
		oFieldsets[0].setStyle('display', 'block');
		$$('#' + sFormID + ' input[type=submit]').setStyle('display', 'none');

		// Set the total number of form steps
		var sTotalSteps = ($$('#' + sFormID + ' span.counter')[0].get('text')).replace(/###TOTAL###/, oFieldsets.length);
		$$('#' + sFormID + ' span.counter').set('text', sTotalSteps);

		// Set the current form step
		fStepCounter(1);

		// Create a next button to allow the user to advance to the next fieldset
		fCreateBut(sFormID, 1, 'next');
	}


	// A function which displays a button on the screen which moves the user to
	// the next fieldset of the given form
	//
	// Arguments:
	// @sFormID - a string referencing the form to inject the button into
	// @iNext - an integer which contains the index of the next fieldset
	function fCreateBut(sFormID, iNext, sDir) {
		var htmlPrevBut = '', htmlNextBut = '';

		switch(sDir) {
			case "prev":
				htmlPrevBut = '<a href="#" id="prevBut" class="button" onclick="fRewindForm(\'' + sFormID + '\', ' + iNext + '); return false;" title="GA NAAR STAP ' + iNext + '">GA NAAR STAP ' + iNext + '</a>';
				break;

			case "next":
				htmlNextBut = '<a href="#" id="nextBut" class="button" onclick="fAdvanceForm(\'' + sFormID + '\', ' + iNext + '); return false;" title="GA NAAR STAP ' + (iNext + 1) + '">GA NAAR STAP ' + (iNext + 1) + '</a>';
				break;
		}

		if ($('nextBut')) {
			// If the next button is already on the page and a previous button has been generated above
			if (htmlPrevBut != "") {
				htmlNextBut = '<a href="#" id="nextBut" class="button" onclick="' + $('nextBut').getAttributeNode('onclick').nodeValue + '" title="' + $('nextBut').get('title') + '">' + $('nextBut').get('text') + '</a>';
				$$('#' + sFormID + ' div.buttonRow').set('html', htmlPrevBut + htmlNextBut);
			}
			
			// If the next button is already on the page and a next button has been generated above
			if (htmlNextBut != "") {
				// Use the existing Previous button to re-generate itself, but only if there is a Previous button present
				if ($('prevBut')) {
					htmlPrevBut = '<a href="#" id="prevBut" class="button" onclick="' + $('prevBut').getAttributeNode('onclick').nodeValue + '" title="' + $('prevBut').get('title') + '">' + $('prevBut').get('text') + '</a>';
				}
				
				$$('#' + sFormID + ' div.buttonRow').set('html', htmlPrevBut + htmlNextBut);
			}
		} else if ($('prevBut')) {
			// If the previous button is already on the page and a previous button has been generated above
			if (htmlPrevBut != "") {
				// Use the existing Next button to re-generate itself, but if there is no Next button present,
				// manipulate the Previous button parameters to generate one
				if ($('nextBut')) {
					htmlNextBut = '<a href="#" id="nextBut" class="button" onclick="' + $('nextBut').getAttributeNode('onclick').nodeValue + '" title="' + $('nextBut').get('title') + '">' + $('nextBut').get('text') + '</a>';
				} else {
					htmlNextBut = '<a href="#" id="nextBut" class="button" onclick="fAdvanceForm(\'' + sFormID + '\', ' + (iNext + 1) + '); return false;" title="GA NAAR STAP ' + (iNext + 2) + '">GA NAAR STAP ' + (iNext + 2) + '</a>';
				}

				$$('#' + sFormID + ' div.buttonRow').set('html', htmlPrevBut + htmlNextBut);
			}
			
			// If the previous button is already on the page and a next button has been generated above
			if (htmlNextBut != "") {
				htmlPrevBut = '<a href="#" id="prevBut" class="button" onclick="' + $('prevBut').getAttributeNode('onclick').nodeValue + '" title="' + $('prevBut').get('title') + '">' + $('prevBut').get('text') + '</a>';
				$$('#' + sFormID + ' div.buttonRow').set('html', htmlPrevBut + htmlNextBut);
			}
		} else {
			// Mark-up the HTML for the next button and inject it inside the DIV buttonRow
			$$('#' + sFormID + ' div.buttonRow').set('html', htmlPrevBut + htmlNextBut);
		}
	}


	function fAdvanceForm(sFormID, iFieldset) {
		// Validate the current fieldset before allowing to advance
		if (inputCheck(iFieldset)) {
			// Move the user back to the top of the page
			window.scrollTo(0, 180);

			// If the current set of input fields validated, hide the current fieldset
			$$('#' + sFormID + ' fieldset')[iFieldset - 1].setStyle('display', 'none');
			
			// If there is a next index in the array of fieldsets, display it
			if ($$('#' + sFormID + ' fieldset')[iFieldset]) {
				$$('#' + sFormID + ' fieldset')[iFieldset].setStyle('display', 'block');
			}

			// Set the current form step
			fStepCounter(iFieldset + 1);

			// If this is step 2 or further, a previous button must be included as well
			if (iFieldset > 0) {
				fCreateBut(sFormID, iFieldset, 'prev');
			} else {
				// This is the first step, the previous button should be destroyed
				$('prevBut').dispose();
			}

			// Re-create the next button with the new values, but only if there is actually another step
			if (iFieldset < ($$('#' + sFormID + ' fieldset').length - 1)) {
				fCreateBut(sFormID, iFieldset + 1, 'next');
			} else {
				// This is the last step, the next button should be destroyed and the
				// submit button should be displayed
				$('nextBut').dispose();
				$$('#' + sFormID + ' input[type=submit]').setStyle('display', 'block');
			}
		}
	}


	function fRewindForm(sFormID, iFieldset) {
		// Move the user back to the top of the page
			window.scrollTo(0, 180);

		// Hide the current fieldset and the submit button
		$$('#' + sFormID + ' fieldset')[iFieldset].setStyle('display', 'none');
		if ($$('#' + sFormID + ' input[type=submit]').getStyle('display') != 'none') {
			$$('#' + sFormID + ' input[type=submit]').setStyle('display', 'none');
		}
		
		// Display the previous fieldset if it exists
		if ($$('#' + sFormID + ' fieldset')[iFieldset - 1]) {
			$$('#' + sFormID + ' fieldset')[iFieldset - 1].setStyle('display', 'block');
		}

		// Set the current form step
		fStepCounter(iFieldset);

		// If this is step 2 or further, a previous button must be included as well
		if (iFieldset > 1) {
			fCreateBut(sFormID, iFieldset - 1, 'prev');
		} else {
			// This is the first step, the previous button should be destroyed
			$('prevBut').dispose();
		}

		// Re-create the next button with the new values, but only if there is actually another step
		if (iFieldset < ($$('#' + sFormID + ' fieldset').length - 1)) {
			fCreateBut(sFormID, iFieldset, 'next');
		}
	}


	// A function which sets the text in the upper-right hand corner of the form to
	// reflect the current fieldset the user is at
	function fStepCounter(iStepNr) {
		var sStepInfo = ($('stepcounter_' + iStepNr).get('text')).replace(/###STEP_NR###/, iStepNr);
		$('stepcounter_'  + iStepNr).set('text', sStepInfo);
	}

/*********************************************************************/
