
// --------------------------------------- Data Structures

// Data For The 3 Questions

var tzone = new Array (3);
var dryness = new Array (2);
var symptoms = new Array (5);

// Constants For Reference

var TZONE_VERY_OILY = 0;
var TZONE_SLIGHTLY_OILY = 1;
var TZONE_NOT_OILY = 2;

var DRY_YES = 0;
var DRY_NO = 1;

var DRY = 0;
var BLEMISH = 1;
var SUN = 2;
var DULL = 3;
var PUFFY = 4;

// --------------------------------------- Show & Hide

function show (id)
{
	try
	{
		document.getElementById (id).style.display = "inline";
		document.getElementById (id).style.visibility = "inherit";
	}
	catch (err)
	{
		alert ("object " + id + " not found.")
	}
}

function hide (id)
{
	try
	{
		document.getElementById (id).style.display = "none";
		document.getElementById (id).style.visibility = "hidden";
	}
	catch (err)
	{
		alert ("object " + id + " not found.")
	}
}

// --------------------------------------- Slides

var currentslide = null;

function showslide (newslide)
{
	if (currentslide)
		hide (currentslide);

	show (newslide);

	currentslide = newslide;
}

// --------------------------------------- Questions

function selectanswer (formid, variable, nextslide, requirecheckeditem)
{
	var form = document.getElementById (formid);
	var anyitemchecked = false;

	for (var i = 0; i < form.elements.length; i ++)
	{
		if ((form.elements [i].type == "radio") || (form.elements [i].type == "checkbox"))
		{
			variable [i] = form.elements [i].checked;

			if (form.elements [i].checked)
				anyitemchecked = true;
		}
	}

	if (requirecheckeditem && ! anyitemchecked)
	{
		alert ("Please make a selection in order to proceed.");
		return false;
	}

	if (nextslide == "answer")
	{
		clearproducts ();
		showproducts ();
	}

	showslide (nextslide);
}

// --------------------------------------- Answers

function clearproducts ()
{
	hide ("basicproductsdry");
	hide ("basicproductsnormal");
	hide ("basicproductsoily");
	hide ("basicproductscomb1");
	hide ("basicproductscomb2");
}

function showproducts ()
{
	if ((tzone [TZONE_VERY_OILY] == true) && (dryness [DRY_YES] == true))
		show ("basicproductscomb1");

	else if ((tzone [TZONE_VERY_OILY] == true) && (dryness [DRY_NO] == true))
		show ("basicproductsoily");

	else if ((tzone [TZONE_SLIGHTLY_OILY] == true) && (dryness [DRY_YES] == true))
		show ("basicproductscomb2");

	else if ((tzone [TZONE_SLIGHTLY_OILY] == true) && (dryness [DRY_NO] == true))
		show ("basicproductsoily");

	else if ((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
		show ("basicproductsdry");

	else if ((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_NO] == true))
		show ("basicproductsnormal");

	clearboosterproducts ();
	showboosterproducts ();


}

function clearboosterproducts ()
{
	hide ("boosterintro");
	hide ("boosterproductsdry");
	hide ("boosterproductsblemish");
	hide ("boosterproductssun");
	hide ("boosterproductsdull");
	hide ("boosterproductspuffy");
	hide ("boosterproductsall");
	
	hide ("boosterproducts41");
	hide ("boosterproducts42");
	hide ("boosterproducts43");
	hide ("boosterproducts44");
	hide ("boosterproducts45");

	hide ("boosterproducts31");
	hide ("boosterproducts32");
	hide ("boosterproducts33");
	hide ("boosterproducts34");
	hide ("boosterproducts35");
	hide ("boosterproducts36");
	hide ("boosterproducts37");
	hide ("boosterproducts38");
	hide ("boosterproducts39");
	hide ("boosterproducts310");

	hide ("boosterproducts21");
	hide ("boosterproducts22");
	hide ("boosterproducts23");
	hide ("boosterproducts24");
	hide ("boosterproducts25");
	hide ("boosterproducts26");
	hide ("boosterproducts27");
	hide ("boosterproducts28");
	hide ("boosterproducts29");
	hide ("boosterproducts210");

	hide ("toshow1");
	hide ("toshow2");
	hide ("toshow3");
	hide ("toshow4");
	hide ("toshow5");
	hide ("toshow6");
	hide ("toshow7");
	hide ("toshow8");
	hide ("toshow9");
	hide ("toshow10");


}

function showboosterproducts ()
{
	if (anysymptomschecked ())
		show ("boosterintro");

	if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [SUN]  && symptoms [DULL] && symptoms [PUFFY] )
		show ("boosterproductsall");
	
	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [SUN]  && symptoms [DULL] )
		show ("boosterproducts41");
	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [SUN]  && symptoms [PUFFY] )
	{
		if((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
			show ("toshow10");
	
		show ("boosterproducts42");
	}
	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [DULL]  && symptoms [PUFFY] )
		show ("boosterproducts43")
	else if (symptoms [DRY] && symptoms [SUN]  && symptoms [DULL]  && symptoms [PUFFY] )
		show ("boosterproducts44");
	else if (symptoms [BLEMISH] && symptoms [SUN]  && symptoms [DULL]  && symptoms [PUFFY] )
		show ("boosterproducts45");

	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [SUN])
		show ("boosterproducts31");
	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [DULL])
	{
		if((dryness [DRY_YES] == true))
			show ("toshow6");
	
		show ("boosterproducts32");
	}
	else if (symptoms [DRY] && symptoms [BLEMISH]  && symptoms [PUFFY])
		show ("boosterproducts33");
	else if (symptoms [DRY] && symptoms [SUN]  && symptoms [DULL])
	{
		if((dryness [DRY_YES] == true))
			show ("toshow7");
	
		show ("boosterproducts34");
	}
	else if (symptoms [DRY] && symptoms [DULL]  && symptoms [PUFFY])
	{
		if((dryness [DRY_YES] == true))
			show ("toshow8");
	
		show ("boosterproducts35");
	}
	else if (symptoms [DRY] && symptoms [SUN]  && symptoms [PUFFY])
	{
		if((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
			show ("toshow9");
	
		show ("boosterproducts36");
	}
	else if (symptoms [BLEMISH] && symptoms [SUN]  && symptoms [DULL])
		show ("boosterproducts37");
	else if (symptoms [BLEMISH] && symptoms [DULL]  && symptoms [PUFFY])
		show ("boosterproducts38");
	else if (symptoms [BLEMISH] && symptoms [SUN]  && symptoms [PUFFY])
		show ("boosterproducts39");
	else if (symptoms [SUN] && symptoms [DULL]  && symptoms [PUFFY])
		show ("boosterproducts310");

	else if (symptoms [DRY] && symptoms [BLEMISH])
		show ("boosterproducts21");
	else if (symptoms [DRY] && symptoms [SUN])
	{
		 if ((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
		{
			show ("toshow1");	
			hide ("tohide1");
		}
		show ("boosterproducts22");
	}

	else if (symptoms [DRY] && symptoms [DULL])
	{
		 if ((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
			show ("toshow2");	
		
		show ("boosterproducts23");
	}
	else if (symptoms [DRY] && symptoms [PUFFY])
	{
		 if ((tzone [TZONE_NOT_OILY] == true) && (dryness [DRY_YES] == true))
		{
			hide ("tohide2");
			show ("toshow3");	
		}
		 show ("boosterproducts24");
	}
	else if (symptoms [BLEMISH] && symptoms [SUN])
	{
		if((tzone [TZONE_VERY_OILY] == true) && (dryness [DRY_NO] == true))
			show ("toshow4");

		show ("boosterproducts25");
	}
	else if (symptoms [BLEMISH] && symptoms [DULL])
	{
		if((tzone [TZONE_VERY_OILY] == true) && (dryness [DRY_NO] == true))
			show ("toshow5");
	
		show ("boosterproducts26");
	}
	else if (symptoms [BLEMISH] && symptoms [PUFFY])
		show ("boosterproducts27");
	else if (symptoms [SUN]  && symptoms [PUFFY])
		show ("boosterproducts28");
	else if (symptoms [SUN] && symptoms [DULL])
		show ("boosterproducts29");
	else if (symptoms [DULL] && symptoms [PUFFY])
		show ("boosterproducts210");

	else if (symptoms [DRY])
		show ("boosterproductsdry");
	else if (symptoms [BLEMISH])
		show ("boosterproductsblemish");
	else if (symptoms [SUN])
		show ("boosterproductssun");
	else if (symptoms [DULL])
		show ("boosterproductsdull");
	else if (symptoms [PUFFY])
		show ("boosterproductspuffy");
}

function anysymptomschecked ()
{
	for (var i = 0; i < symptoms.length; i ++)
	{
		if (symptoms [i] == true)
			return true;
	}

	return false;
}

// --------------------------------------- End


