function BehandelingSelector(divId, nieuwsberichten)
{
	var aInvoer1 = new Array();
	var aInvoer2 = new Array();
	var aUitvoerTekst = new Array();
	var aUitvoerLink = new Array();
	var aAfspraakLink = new Array();

	this.pagina = window.location+"#";

	this.containerDiv = document.getElementById(divId);
	this.aHoofdcategorie = new Array();
	this.aHoofdcategorie[0] = "Gezicht";
	this.aHoofdcategorie[1] = "Lichaam";
	this.aHoofdcategorie[2] = "Handen";
	this.aHoofdcategorie[3] = "Voeten";
	this.nietGekozenHTML	= nieuwsberichten;
	this.afspraakPlanLinkTekst = "Klik hier om uw gekozen behandeling  en uw voorkeur voor een datum en tijd aan ons door te geven. U ontvangt binnen 24 uur een reactie.";

	this.geefBehandeling = function(hoofdcategorie, invoer1, invoer2){

		// arrays resetten
		aInvoer1 = [];
		aInvoer2 = [];

		switch (hoofdcategorie)
		{
			// "Gezicht":
			case this.aHoofdcategorie[0]:
				aInvoer1[0] = "Gemengde huid";
				aInvoer1[1] = "Droge huid";
				aInvoer1[2] = "Normale huid";
				aInvoer1[3] = "Gevoelige huid";
				aInvoer1[4] = "Verouderde huid";
				aInvoer1[5] = "Acne huid";
				aInvoer1[6] = "Vermoeide huid";
				aInvoer1[7] = "Geen idee?";

				// Gezicht, gemengd, droog, normaal
				if (invoer1 == aInvoer1[0] || invoer1 == aInvoer1[1] || invoer1 == aInvoer1[2] || invoer1 == aInvoer1[7])
				{
					aInvoer2[0] = "Reinigend (30 min)";
					aInvoer2[1] = "Reinigend en verzorgend (45 min)";
					aInvoer2[2] = "Reinigend en ontspannend (45 min)";
					aInvoer2[3] = "Reinigend, verzorgend en ontspannend (60 min)";
				}
				// Gezicht, verouderd
				else if (invoer1 == aInvoer1[4])
				{
					aInvoer2[0] = "Reinigend en verzorgend (60 min)";
					aInvoer2[1] = "Reinigend, verzorgend en ontspannend (75 min)";
				}
				// Gezicht, vermoeid
				else if (invoer1 == aInvoer1[6])
				{
					aInvoer2[0] = "Reinigend en verzorgend (45 min)";
					aInvoer2[1] = "Reinigend, verzorgend en ontspannend (60 min)";
				}
				// Gezicht, acne
				else if (invoer1 == aInvoer1[5])
				{
					aInvoer2[0] = "Reinigend (30 min)";
					aInvoer2[1] = "Reinigend en verzorgend (45 min)";
				}
				// Gezicht, gevoelig
				else if (invoer1 == aInvoer1[3])
				{
					aInvoer2[0] = "Reinigend en verzorgend (45 min)";
					aInvoer2[1] = "Reinigend, verzorgend en ontspannend (60 min)";
				}

			  //if (invoer1 == "Gemengde huid" || invoer1 == "Droge huid" || invoer1 == "Normale huid" || invoer1 == "Geen idee?") {
				if (invoer1 == aInvoer1[0] || invoer1 == aInvoer1[1] || invoer1 == aInvoer1[2] || invoer1 == aInvoer1[7]) {
					switch (invoer2)
					{
					  //case "Reinigend":
						case aInvoer2[0]:
							aUitvoerTekst[0] = "Short Facial";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=short_facial";
						break;

					  //case "Reinigend en verzorgend":
						case aInvoer2[1]:
							aUitvoerTekst[0] = "Sport & Care Facial";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=sport_care_facial";
						break;

					  //case "Reinigend en ontspannend":
						case aInvoer2[2]:
							aUitvoerTekst[0] = "Sport & Relax Facial";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=sport_relax_facial";
						break;

					  //case "Reinigend, verzorgend en ontspannend":
						case aInvoer2[3]:
							aUitvoerTekst[0] = "Exclusive Facial";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=exclusive_facial";
						break;
					}
				}
				else if (invoer1 == aInvoer1[4]) //"Verouderde huid"
				{
					switch (invoer2)
					{
					  //case "Reinigend en verzorgend":
						case aInvoer2[0]:
							aUitvoerTekst[0] = "Cellmen Cellulaire Revatilize Anti-age";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/cellmen_skincare_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=cellmen_revatilize_anti_age";
						break;
					  //case "Reinigend en verzorgend en ontspannend":
						case aInvoer2[1]:
							aUitvoerTekst[0] = "Cellmen Cellulaire Revatilize Anti-age & Massage";
							aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/cellmen_skincare_gezichtsbehandelingen.html";
							aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=cellmen_revatilize_anti_age_massage";
						break;
					}
				}
				else if (invoer1 == aInvoer1[6]) //"Vermoeide huid"
				{
					if (invoer2 == aInvoer2[1])
					{
						aUitvoerTekst[0] = "Detoxifying & Relax Treatment";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/cellmen_skincare_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=detoxifiyng_massage_treament";
					}
					else {
						aUitvoerTekst[0] = "Detoxifiyng Treatment";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/cellmen_skincare_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=detoxifying_treament";						
					}
				}
				else if (invoer1 == aInvoer1[5]) //"Acne huid"
				{
					if (invoer2 == aInvoer2[0])
					{
						aUitvoerTekst[0] = "Anti-Bac & Short Facial";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=anti_bac_short_facial";
					}
					else {
						aUitvoerTekst[0] = "Anti-Bac Facial";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=anti_bac_care_facial";
					}
				}
				else if (invoer1 == aInvoer1[3]) //"Gevoelige huid"
				{
		 			if (invoer2 == aInvoer2[0])
					{
						aUitvoerTekst[0] = "Sensitive Facial";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=sensitive_facial";
					}
					else {
						aUitvoerTekst[0] = "Sensitive & Relax Facial";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/gezichtbehandeling/dermalogica_facials_gezichtsbehandelingen.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=gezichtsbehandeling&behandeling=sensitive_relax_facial";
					}
				}
			break;

			//"Lichaam":
			case this.aHoofdcategorie[1]:

				aInvoer1[0] = "Lichaamsbehandeling";
				aInvoer1[1] = "Ontharing";

				// Lichaamsbehandeling
				if (invoer1 == aInvoer1[0])
				{
					aInvoer2[0] = "Reinigend, hele lichaam";
					aInvoer2[1] = "Reinigend, rug en/of borst";
					aInvoer2[2] = "Verzorgend, bovenarmen en schouders";

					if (invoer2 == aInvoer2[0])
					{
						aUitvoerTekst[0] = "Body Nourishing Sea Mud Wrap";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/lichaamsbehandeling.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=lichaamsbehandeling&behandeling=body_nourishing_sea_mud_wrap";
					}
					else if (invoer2 == aInvoer2[1]){
						aUitvoerTekst[0] = "Back or Chest Purifying Treatment";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/lichaamsbehandeling.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=lichaamsbehandeling&behandeling=back_or_chest_purifying_treatment";
					}
					else {
						aUitvoerTekst[0] = "Nourishing Shoulder & Upperarm Therapy";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/lichaamsbehandeling.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=lichaamsbehandeling&behandeling=shoulder_upperarm_therapy";
					}
				}
				// Ontharing
				else if (invoer1 == aInvoer1[1])
				{
					aInvoer2[0] = "Harsen";

						aUitvoerTekst[0] = "Harsen";
						aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/ontharing.html";
						aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=ontharing&behandeling=harsen";
				}
				
			break;
			
			//"Handen":
			case this.aHoofdcategorie[2]:
				aUitvoerTekst[0] = "Manicure";
				aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/voeten_en_handen.html";
				aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=voeten_handen&behandeling=manicure";
			break;

			//"Voeten":
			case this.aHoofdcategorie[3]:
				aUitvoerTekst[0] = "Luxe voetverzorging";
				aUitvoerLink[0] = "http://www.manmanbeautycare.nl/treatments/voeten_en_handen.html";
				aAfspraakLink[0] = "http://www.manmanbeautycare.nl/contact/afspraak_maken.html?type=voeten_handen&behandeling=luxe_voetverzorging";
			break;	
		}

		this.updateBehandeling(hoofdcategorie, invoer1, invoer2, aInvoer1, aInvoer2, aUitvoerTekst, aUitvoerLink, aAfspraakLink);

	}

	this.updateBehandeling = function(hoofdcategorie, invoer1, invoer2, aInvoer1, aInvoer2, aUitvoerTekst, aUitvoerLink, aAfspraakLink) {

		this.verwijderAlleChildNodes();

		var hoofdgroepenDiv = document.createElement('div');
			hoofdgroepenDiv.style.width="500px";
			hoofdgroepenDiv.style.height="35px";
			hoofdgroepenDiv.style.textAlign="center";

			for(var i = 0; i<this.aHoofdcategorie.length; i++)
			{
				var hoofdgroepSpan = document.createElement('span');
					hoofdgroepSpan.style.paddingLeft="28px";
					hoofdgroepSpan.style.paddingRight="29px";
					hoofdgroepSpan.style.paddingBottom="9px";
					hoofdgroepSpan.style.paddingTop="7px";
					hoofdgroepSpan.style.marginRight="1px";
					hoofdgroepSpan.style.display="block";
					hoofdgroepSpan.style.styleFloat="left";
					hoofdgroepSpan.style.cssFloat="left";
					hoofdgroepSpan.style.width="13%";
					hoofdgroepSpan.style.border="1px solid #312b20";
					hoofdgroepSpan.style.backgroundImage = "url('template/afbeeldingen/gradient_passief.gif')";
					hoofdgroepSpan.innerHTML="<a href=\""+this.pagina+"\" onclick=\"BehandelingSelector.geefBehandeling('"+this.aHoofdcategorie[i]+"', null, null);\" style=\"color: white;\">"+this.aHoofdcategorie[i]+"</a>";
				
					if(hoofdcategorie === this.aHoofdcategorie[i]) {
						hoofdgroepSpan.style.backgroundImage = "url('template/afbeeldingen/gradient_actief.gif')";
					}
					hoofdgroepenDiv.appendChild(hoofdgroepSpan);
			}

			this.containerDiv.appendChild(hoofdgroepenDiv);

			var uitvoer = false;

			if (hoofdcategorie != this.aHoofdcategorie[2] && hoofdcategorie != this.aHoofdcategorie[3]) {
				if(aUitvoerTekst == null || hoofdcategorie == null || invoer1 == null || invoer2 == null) {
					this.containerDiv.appendChild(this.geefInvoerDiv(hoofdcategorie, invoer1, invoer2, aInvoer1, aInvoer2));
				}
				else
					var uitvoer = true;
			}
			else {
				var uitvoer = true;
			}

			if (uitvoer == true) {
				this.containerDiv.appendChild(this.geefGeschiktebehandelingDiv(aUitvoerTekst, aUitvoerLink, aAfspraakLink));
			}


	}

	this.geefGeschiktebehandelingDiv = function(aUitvoerTekst, aUitvoerLink, aAfspraakLink)
	{
		var uitvoerDiv = document.createElement('div');
			uitvoerDiv.style.width="470px";
			uitvoerDiv.style.height="180px";
			uitvoerDiv.style.backgroundColor="#8e877a";
			uitvoerDiv.style.textAlign="left";
			uitvoerDiv.style.padding="15px";
			uitvoerDiv.style.marginBottom="20px";

		if(aUitvoerTekst.length == 1) {
			var tekstregel = "De oplossing is: ";
		}
		else if (aUitvoerTekst.length > 1)
		{
			var tekstregel = "Oplossingen zijn: ";
		}
		else
		{
			var tekstregel = "Er is een fout opgetreden, onze excuses voor het ongemak.";
		}

		uitvoerDiv.innerHTML=tekstregel;

		for(var i = 0; i<aUitvoerTekst.length; i++){
			var br = document.createElement('br');
			uitvoerDiv.appendChild(br);

			var link = document.createElement('a');
				link.style.color="white";
				link.href=aUitvoerLink[i];
				link.innerHTML=aUitvoerTekst[i];

			uitvoerDiv.appendChild(link);

			uitvoerDiv.appendChild(br);

			var afspraakDiv = document.createElement('div');
				afspraakDiv.style.margin="40px";
				afspraakDiv.style.textAlign="center";

			var afspraakLink = document.createElement('a');
				afspraakLink.style.color="white";
				afspraakLink.href=aAfspraakLink[i];
				afspraakLink.innerHTML=this.afspraakPlanLinkTekst;
			
			afspraakDiv.appendChild(afspraakLink);
			uitvoerDiv.appendChild(afspraakDiv);

		}

		return uitvoerDiv;
	}

	this.geefInvoerDiv = function(hoofdcategorie, invoer1, invoer2, aInvoer1, aInvoer2)
	{
		var invoerDiv = document.createElement('div');
			invoerDiv.style.width="470px";
			invoerDiv.style.height="180px";
			invoerDiv.style.backgroundColor="#8e877a";
			invoerDiv.style.textAlign="left";
			invoerDiv.style.padding="15px";

		if(hoofdcategorie == null){
			invoerDiv.style.background="none";
			invoerDiv.style.textAlign="left";
			invoerDiv.style.paddingTop="25px";
			invoerDiv.style.height="170px";
			invoerDiv.style.color="#312b20";
			invoerDiv.style.textTransform="";
			invoerDiv.style.fontSize="";
			invoerDiv.innerHTML=this.nietGekozenHTML;
		}
		else {
			var invoerDivLinks = document.createElement('div');
				invoerDivLinks.style.width="150px";
				invoerDivLinks.style.textAlign="left";
				invoerDivLinks.style.styleFloat="left";
				invoerDivLinks.style.cssFloat="left";

				// huidtype
				if(hoofdcategorie == "Gezicht") {
					invoerDivLinks.innerHTML="Huidtype:"
				}

			var invoerDivRechts = document.createElement('div');
				invoerDivRechts.style.width="320px";
				invoerDivRechts.style.textAlign="left";
				invoerDivRechts.style.styleFloat="left";
				invoerDivRechts.style.cssFloat="left";

				// type behandeling
					if(hoofdcategorie == "Gezicht" && invoer1 != null) {
						invoerDivRechts.innerHTML="Type behandeling:"
					}

			for(var i = 0; i<aInvoer1.length; i++)
			{
				if(invoer1 === aInvoer1[i]) {
					var kleurLink = "white";
				}
				else {
					var kleurLink = "#c0bdb5";
				}

				var invoer1Span = document.createElement('span');
					invoer1Span.style.paddingBottom="3px";
					invoer1Span.style.display="block";
					invoer1Span.style.width="150px";
					invoer1Span.innerHTML="<a href=\""+this.pagina+"\" onclick=\"BehandelingSelector.geefBehandeling('"+hoofdcategorie+"', '"+aInvoer1[i]+"', null);\" style=\"color: "+kleurLink+";\">"+aInvoer1[i]+"</a>";
				
					if(invoer1 === invoer1Span[i]) {
						invoer1Span.style.borderBottom="2px dotted gray";
					}
					invoerDivLinks.appendChild(invoer1Span);
			}

			if(invoer1 != null)
			{
				for(var i = 0; i<aInvoer2.length; i++)
				{
					if(invoer2 === aInvoer2[i]) {
						var kleurLink = "white";
					}
					else {
						var kleurLink = "#c0bdb5";
					}

					var invoer2Span = document.createElement('span');
						invoer2Span.style.paddingBottom="3px";
						invoer2Span.style.display="block";
						invoer2Span.style.width="320px";
						invoer2Span.innerHTML="<a href=\""+this.pagina+"\" onclick=\"BehandelingSelector.geefBehandeling('"+hoofdcategorie+"', '"+invoer1+"', '"+aInvoer2[i]+"');\" style=\"color: "+kleurLink+";\">"+aInvoer2[i]+"</a>";
					
						if(invoer2 === invoer2Span[i]) {
							invoer2Span.style.borderBottom="2px dotted gray";
						}
						invoerDivRechts.appendChild(invoer2Span);
				}
			}

			invoerDiv.appendChild(invoerDivLinks);
			invoerDiv.appendChild(invoerDivRechts);

		}

		return invoerDiv;
	}

	this.verwijderAlleChildNodes = function()
	{
		if(this.containerDiv.hasChildNodes() )
		{
		    while(this.containerDiv.childNodes.length >= 1 )
		    {
		        this.containerDiv.removeChild(this.containerDiv.firstChild );       
		    } 
		}
	}
}
