<!-- Hide from older browsers
var Droog_score=0;
var Normaal_score=0;
var Gevoelig_score=0;
var Vet_score=0;
var Combinatie_score=0;
var group_string = "document.test_form.";

function convert_to_int(num_toconvert){
//This function converts a floating point number into an integer after proper rounding 
//for formatting
var num1=0;
var rem1=0;
var num2=0;
var num3=0;
num1=parseInt(num_toconvert);
num2=num_toconvert*100;
num3=parseInt(num2);
rem1=num3-(num1*100);
if(rem1>49)num1=num1+1;
return num1;
}

function check_score(group_name)

{
// This function checks a group for selection and updates the score based on the value selected
	if(group_name[0].checked == true)
		{Droog_score +=5;}
	if(group_name[1].checked == true)
		{Normaal_score +=5;}
	if(group_name[2].checked == true)
		{Gevoelig_score +=5;}
	if(group_name[3].checked == true)
		{Vet_score +=5;}
	if(group_name[4].checked == true)
		{Combinatie_score +=5;}

}

function Calculate_skin_type()
{
var total, max, i, nextmax, j, ans_str, str_var;
//This function calculates the skin type based on input from the user
Droog_score=0;
Normaal_score=0;
Gevoelig_score=0;
Vet_score=0;
Combinatie_score=0;

//check individual answers

	check_score(document.test_form.N1);

	check_score(document.test_form.N2);

	check_score(document.test_form.N3);

	check_score(document.test_form.N4);

	check_score(document.test_form.N5);

	check_score(document.test_form.N6);

	
//save value
//alert("Your Raw scores:\nYour Droog Skin Type Score Is: "+ Droog_score +"\nYour Normaal Skin Type score is:" + Normaal_score +"\nYour Gevoelig Skin Type score is: " + Gevoelig_score +"\nYour Vet Skin Type score is: " + Vet_score +"\nYour Combinatie Skin Type score is: " + Combinatie_score +"\n");
//Normaalize the score
total=Droog_score+Normaal_score+Gevoelig_score+Vet_score+Combinatie_score;
if(total>0)
	{
	Droog_score=convert_to_int((Droog_score*100)/total);
	Normaal_score=convert_to_int((Normaal_score*100)/total);
	Gevoelig_score=convert_to_int((Gevoelig_score*100)/total);
	Vet_score=convert_to_int((Vet_score*100)/total);
	Combinatie_score=convert_to_int((Combinatie_score*100)/total);

	//alert("Your Normaalized scores:\nYour Droog Skin Type Score Is: "+ Droog_score +"\nYour Normaal Skin Type score is:" + Normaal_score +"\nYour Gevoelig Skin Type score is: " + Gevoelig_score +"\nYour Vet Skin Type score is: " + Vet_score +"\nYour Combinatie Skin Type score is: " + Combinatie_score +"\n");
	}
	
if(total>0)

	{
	//Find out the predominant skin type
	max=Droog_score;
	i=1;
	if(Normaal_score>max)
		{max=Normaal_score;
		nextmax=Droog_score;
		j=1;
		i=2;}
	else
		{nextmax=Normaal_score;
		j=2;}
	if(Gevoelig_score>max)
		{
		nextmax=max;
		max=Gevoelig_score;
		j=i;
		i=3;}
	else
		{
		if(Gevoelig_score>nextmax)
			{nextmax=Gevoelig_score;
			j=3;
			}
		}
	
	if(Vet_score>max)
		{
		nextmax=max;
		max=Vet_score;
		j=i;
		i=4;}
	else
		{
		if(Vet_score>nextmax)
			{nextmax=Vet_score;
			j=4;
			}
		}

	if(Combinatie_score>max)
		{
		nextmax=max;
		max=Combinatie_score;
		j=i;
		i=5;}

	else
		{
		if(Combinatie_score>nextmax)
			{nextmax=Combinatie_score;
			j=5;
			}
		}
}
if(i==5) {
			alert("Je huidtype: Combinatie");
			}
else {
			
		if(total<1){
			alert("Beantwoord de vragen om je huidtype te bepalen.")
			}
		else {	
			
			prepare_report(i,j,max,nextmax);
			}
		}
}

function prepare_report(i,j,max,nextmax)
{
var ans_str;
//check if dual-type

	
	if((max-nextmax)<25){
				ans_str="Je huidtype: ";
				if(i==1) {ans_str=ans_str+"Droog";}
				if(i==2) {ans_str=ans_str+"Normaal";}
				if(i==3) {ans_str=ans_str+"Gevoelig";}
				if(i==4) {ans_str=ans_str+"Vet";}
		

				if (j==1) {ans_str=ans_str+" en Droog";}
				if (j==2) {ans_str=ans_str+" en Normaal";}
				if (j==3) {ans_str=ans_str+" en Gevoelig";}
				if (j==4) {ans_str=ans_str+" en Vet";}
		
				alert(ans_str);
	
				}
		else

				{
				if(i==1){
					ans_str="Je huidtype: Droog";}
				if(i==2){
					ans_str="Je huidtype: Normaal";}
				if(i==3){
					ans_str="Jew huidtype: Gevoelig";}
				if(i==4){
					ans_str="Je huidtype: Vet";}
				if(i==5){
					ans_str="Je huidtype: Combinatie";}
				alert(ans_str);

				}
	
}
// end hiding -->
