<!-- Beginning of JavaScript -

// Zung Depression Survey

// This code is the exclusive property of AfraidToAsk.com
// Code reuse is strictly prohibited
// Copyright 2000 AfraidToAsk.com

function AnsweredAll()
{
	// make sure all the questions in the quiz have been answered
	for (var i=0; i <= document.quiz.elements.length-1; i=i+4) 
	{ 
		if ( !document.quiz.elements[i].checked &&
			 !document.quiz.elements[i+1].checked &&
			 !document.quiz.elements[i+2].checked &&
			 !document.quiz.elements[i+3].checked )
		{
			return false;
		}
	}
	return true;
}

function GetResults() 
{
	var bRes;
	var nScore = 0;
	var nTotal = 0;

	bRes = AnsweredAll();
	if ( bRes == false )
	{
		alert("NOTE: Answer Every Question!" )
		return;
	}

	radio = document.quiz.elements;
	for ( var i=0; i <= radio.length-1; i++ ) 
	{
		if( radio[i].checked ) 
		{
			var strQNum = radio[i].name;
			nScore +=  eval( radio[i].value );
			
			nTotal++;
		}
	}
//	alert( "score: " + nScore + "  total: " + nTotal );
	ScoreWin( nScore );
} 

function ScoreWin( nScore ) 
{
	var strResults;

	if ( nScore >= 50 )
		strResults = 'Scores greater than 50 are an indication of depression. Your score suggests that you may indeed be suffering from clinical depression. You should discuss this possibility with your physician.';
	else
		strResults = 'Scores greater than 50 are an indication of depression. Your score is within the normal range.  If you do not feel well or your mood is not right, however, you should still contact your physician for further evaluation as this questionnaire does not evaluate other possible physical or mood problems, such as anxiety.';
		

	resultWin = open("", "resultWin","toolbar=no,width=600,height=600,directories=no,status=yes,scrollbars=yes,resize=yes,menubar=no");               
    
   with(window.resultWin) 
	{    
		document.write("<head><title>Zung Questionnaire Results</title></Head><body bgcolor='ffffff'><basefont size=5>");   

		document.write("<p>");
		document.write("<p>Score:\t\t " + nScore +  "<BR>");
		document.write("<p>");
		document.write("<p>Results:\t\t " + strResults +  "<BR>");
		document.write("</font><BR></body>"); 
		document.close();
	}
}

// - End of JavaScript - -->


