/********** 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);
	}

	function ShowHideFAQ(divid, sPrefix) {
		if ($(divid).style.display == "none") {
			for (var iCnt = 0; iCnt < $('aantal_faq').value; iCnt++) {
				$("faq_" + iCnt).style.display = "none";
				$("icon_faq_" + iCnt + "").src = sPrefix + 'media/img/plus.jpg';
				$("link_faq_" + iCnt + "").className = '';
			}
			$(divid).style.display = "block";

			$("icon_" + divid + "").src = sPrefix + 'media/img/minus.jpg';
			$("link_" + divid + "").className = 'active';
		} else {
			$(divid).style.display = "none";
			$("icon_" + divid  +"").src = sPrefix + 'media/img/plus.jpg';
			$("link_" + divid + "").className = '';
		}
	}

/*********************************************************************/

//banners

function setHTMLExample(iBanner) {
	var sHTML, sImgUrl
	switch(iBanner) {
		case "partner":
			sHTML = '<a href="http://www.usupport.nl/" title="partner van U-Support Secretaressedag">\n<img width="150" height="75" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_banner_150x75px.gif"/>\n</a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_banner_150x75px.gif';
			break;

		case "rectangle":
			sHTML = '<a href="http://www.usupport.nl/" title="partner van U-Support Secretaressedag"><img width="336" height="280" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_Bazen_Rectangle_336x280.gif" /></a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_Bazen_Rectangle_336x280.gif';
			break;

		case "skyscraper":
			sHTML = '<a href="http://www.usupport.nl/" title="U-Support Secretaressedag"><img width="120" height="600" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_Gestrikt_skyscraper_120x600.gif" /></a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_Gestrikt_skyscraper_120x600.gif'
			break;

		case "fullbanner":
			sHTML = '<a href="http://www.usupport.nl/" title="U-Support Secretaressedag"><img width="468" height="60" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_Gestrikt_Fullbanner_468x60.gif" /></a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_Gestrikt_Fullbanner_468x60.gif';
			break;

		case "leaderbord":
			sHTML = '<a href="http://www.usupport.nl/" title="U-Support Secretaressedag"><img width="728" height="90" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_Gestrikt_Leaderbord_728x90.gif" /></a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_Gestrikt_Leaderbord_728x90.gif';
			break;

		case "getriktrectangle":
			sHTML = '<a href="http://www.usupport.nl/" title="U-Support Secretaressedag"><img width="336" height="280" alt="U-Support Secretaressedag" src="http://www.usupport.nl/media/userfiles/file/partnermateriaal/U-Support_Gestrikt_Rectangle_336x280.gif" /></a>';
			sImgUrl = 'http://www.usupport.nl/media/userfiles/media/partnermateriaal/U-Support_Gestrikt_Rectangle_336x280.gif'
			break;

	}


	$('copypaste_field').value = sHTML;
	$('copypaste_preview').src = sImgUrl;

}


