
// Function to return the name of the folder that the current page is stored in.
function getFolder() {
	var thisPathname;     // relative path to this file of the form "/hike-at-lamurta/index.htm" - see p468
	var x;                // will contain an array of values between '/', e.g. hike-at-lamurta, index.htm
	var thisFolder;       // the folder name extracted (but not necessarily returned
	thisPathname = window.location.pathname;
	x = thisPathname.split("/");
	if (x[x.length-2]=='') {return 'root';} else {return x[x.length-2];}  // subtract 2 to get the name between the /  / one from the end.
} // function getFolder()

function getNewsletterGroup() {
	// we want to return one of walk, cycle, relax, root, es, nl
	var x;
	x = getFolder();
	 	switch (x) {
			// walking
			case 'walk' :  return 'walk';	break;
			case 'walking' :  return 'walk';	break;
			case 'walking-in-spain' : return 'walk';	break;
			case 'walking-holiday-spain' : return 'walk';	break;
			case 'hike-at-lamurta' : return 'walk';	break;
			case 'walk-in-spain' : return 'walk';	break;
			// cycling
			case 'cycle' :  return 'cycle';	break;
			case 'ride' :  return 'cycle';	break;
			case 'cycling' : return 'cycle';	break;
			case 'cycling-holiday-spain' : return 'cycle';	break;
			case 'cycling' : return 'cycle';	break;
			// others
			case 'relax' : return 'relax';	break;
			case 'motorbike' : return 'motorbike';	break;
			case 'es' :  return 'es';	break;
			case 'nl' :  return 'nl';	break;
			case 'de' :  return 'de';	break;
			case 'en' :  return 'en';	break;
			case 'test' :  return 'test';	break;
			case 'root' :  return 'root';	break;
			case 'mountain' : return 'walk';	break;
		} // end switch
		
		return 'root'; // if none of those we have to return something sensible
		
} // end function getNewsletterGroup

function setNewsletterID() {
	// writes the form ID to enable the correct group to be set in the 1and1 Newsletter subscriber database 
	var x;
	var ID;
	x = getNewsletterGroup();
	 	switch (x) {
			case 'walk' :  ID='78616';	break;
			case 'cycle' :  ID='78619';	break;
			case 'relax' : ID='78620';	break;
			case 'root' : ID='78621';	break;
			case 'motorbike' : ID='80439';	break;
			case 'es' : ID='78629';	break;
			case 'nl' : ID='78630';	break;
			case 'de' : ID='78631';	break;
			default: ID='78621'; //root
		} // end switch
		
		// set the value of the value attribute of the hidden <input> which sets the newsletter ID and therefore grouping (cycle, walk, etc)
		document.getElementById('RegistrationFormID').value=ID;
		
} // end function setNewsletterID

