function showHide(element)
{
	if (document.getElementById(element).style.display == 'block')
	{
		document.getElementById(element).style.display = 'none';
	}
	else
	{
		document.getElementById(element).style.display = 'block';
	}
}
// Hides all div elements with a given class name
function hideElementsByClassName(className) {
	if(document.getElementById) {
		var divTags = document.body.getElementsByTagName('div');
		for (i = 0; i < divTags.length; i++) {
			if(divTags[i].className == className) {
				divTags[i].style.display = 'none';
			}
		}
	}
}
// Shows just one of the div elements with a given class name
function showElement(className, elementToShow) {
	if(document.getElementById) {
		hideElementsByClassName(className);
		document.getElementById(elementToShow).style.display = 'block';
	}
}

// This assumes that a summary p element is followed by one or more detail p elements.
// The detail p elements must have class="detail".
// The hideDetails function must be called when the page loads.
function showHideDetails(summary) {
var detail = summary.nextSibling;
while (detail != null) {
	// Check that this is an element node
	if (detail.nodeType == 1) {
		// hide or show
		if (detail.style.display == '' || detail.style.display == 'block') {
			detail.style.display = 'none';
			summary.firstChild.firstChild.data = '+';
			}
		else {
			detail.style.display = 'block';
			summary.firstChild.firstChild.data = '-';
			}
		}
	detail = detail.nextSibling;
	}
}

function hideDetails() {
    var liTags = document.getElementsByTagName('li');
    for (var index = 0; index < liTags.length; index ++) {
        if (liTags[index].className == 'collapsibleList') {
	        var pTags = liTags[index].getElementsByTagName('p');
	        for (var i = 0; i < pTags.length; i ++) {
		        if (pTags[i].className != 'detail') {
		            var signSpan = document.createElement('span');
		            var sign = document.createTextNode('+');
		            signSpan.onclick = function() {showHideDetails(this.parentNode)};
		            signSpan.appendChild(sign);
		            pTags[i].insertBefore(signSpan, pTags[i].firstChild);
		            signSpan.style.fontFamily = 'courier', 'monospace';
		            signSpan.style.paddingRight = '0.5em';
		            pTags[i].style.cursor = 'pointer';
		            showHideDetails(pTags[i]);
		        }
	        }
        }
    }
}

function processMultiWayFeedback(formID,action)
// This function takes the ID of a form.
// It reads the values of any radio buttons set within this form, and strings these values together separated by - into a text string.
// Any element within the form with an ID starting with the formID + "-FB" are considered feedback elements.
// A feedback element with ID matching the strung together list of button settings will be shown.
// All other feedback elements will be hidden.

// The above all holds true unless the function is called with action=='reset'
// In that case, all buttons are turned off, and all feedback is hidden.

{

if (document.getElementsByTagName) 
{
	var selectedRadios = ""; // record of selected radio buttons in the form

	// step through form for first time, looking for all inputs, either resetting them or recording which selected
	for (elementToProcess = 0; elementToProcess < eval("document.forms."+formID+".length"); elementToProcess++)
	// look through all elements in the form
	{
		if (eval("document.forms."+formID+".elements[elementToProcess].type") == "radio") 
		// if it is an radio button, we act on it
		{
 			if (action=='reset') eval("document.forms."+formID+".elements[elementToProcess].checked = 0") // just turn the button off, if in reset mode // eval used to execute here, not intd in return value
			else 
			{
				if (eval("document.forms."+formID+".elements[elementToProcess].checked")) 
				// add to list of selectedRadios, dash-separated, if selected
				{
					selectedRadios += "-" + eval("document.forms."+formID+".elements[elementToProcess].value")
				}
			}
	    }
	}


	var feedbackStub = formID + "-FB";

	// step through for second time, this time through the whole document, looking for all feedback items, either resetting them, or showing only one which corresponds to the combination of buttons selected
	// alert(document.getElementsByTagName('DIV').length);
	for (elementToProcess = 0; elementToProcess < document.getElementsByTagName('DIV').length; elementToProcess++)
	// look through all DIVs in the document
	{
		element = document.getElementsByTagName('DIV')[elementToProcess];
		// alert(element.id);
		if (element.id.substr(0,feedbackStub.length) == feedbackStub)
		// if its ID starts with the feedbackStub, ie it is a DIV of our feedback type, act on it
		{
			element.style.display = 'none';
			// now, only if it is a match to the buttons selected, and we are not in reset mode, show it
			if ((element.id == feedbackStub + selectedRadios) && (action!='reset'))
			{
				element.style.display = 'block';
			}
		}
		

	}
}
 
}

function writeLinkToTransactionPages(transactionType) {
	switch (transactionType)  {
	case "orderCourse" :
		document.write('<a href="javascript:__utmLinker(\'https://www.ebsglobal.net/pppages/userdetailsentryform.aspx?page=course\');">Order Course</a>');
		break;
	case "requestProspectus" :
		document.write('<a href="javascript:__utmLinker(\'https://www.ebsglobal.net/pppages/userdetailsentryform.aspx\');">Request prospectus</a>');
		break;
	}
}

function initiatePage() {
	if(document.getElementById) {
		hideElementsByClassName('hidden');
		hideDetails();
	}
}