function scoreForm()
{
//sets the messages for each score category
	var lo_score = "Your child is at LOW RISK for drug and/or alcohol problems";
	var med_score = "Your child is at MEDIUM RISK for a drug and/or alcohol problems";
	var hi_score = "You are a parent who is dealing with a child with drug and/or alcohol problems.";
	var controlIndex;
	var element;
	var numberOfQuestions= document.the_form.length;
	var the_total = 0;
	var theMessage = "";
//cycles through form, counts responses
	for (controlIndex = 0; controlIndex < numberOfQuestions; controlIndex++)
		{
			var element = document.the_form[controlIndex].checked;
			if (element == true) 
			{
			  the_total++;
			}
		}
	
//assigns a message to total	
if (the_total <= 4)
	{
	theMessage = lo_score;
	}
	else if (the_total > 4 && the_total <=6)
	{
	theMessage = med_score;
	}
	else if (the_total >= 7 )
	{
	theMessage = hi_score;
	}
//spawns a new window, populates it with text, score and message
var newWin = window.open ("","theWin","width=475, height=450 scrollbars=yes, resizable=yes");
newWin.document.open();
newWin.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html><head><title>SOS Drugs Drug Addiction Self-Assessment Quiz</title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><link href='sosdrugs.css' rel='stylesheet' type='text/css'></head><body><table width='450' border='0' cellspacing='0' cellpadding='0'>  <tr>    <td><p>You checked ");
	newWin.document.write(the_total);
	newWin.document.write(" items. ");
	newWin.document.write(theMessage);
	newWin.document.write(". <p>You may be interested in the following 3-step        guide to help parents get direction for themselves and their children:</p>      <blockquote>        <p>1. View our <a href='faq.html' target='main'>Frequently Asked Questions</a> by parents          who have been there and the answers.</p>        <p>2. Tell us about yourself and your child and <a href='contact.html' target='main'>ask            us a question</a> that our experts will answer within 48 hours.</p>        <p>3. Ask our experts <a href='contact.html' target='main'>follow-up questions</a> and          receive answers that can guide you.</p>      </blockquote>      <p> Please note: This website and all its information in no way intends        to be an all-inclusive professional diagnostic test or evaluation. It        in no way infers nor implies that it's resources or the information received        from it is to take the place of professional and/or medical advice or        therapy. Anyone with such concerns should seek professional advice before        participating. The questionaire is designed to identify areas of focus    of personal and family education and improvement.</p></td>  </tr></table><p>&nbsp;</p><p>&nbsp; </p></body></html>");
	newWin.document.close();
}

function clearForm()
{
	var controlIndex;
	var element;
	var numberOfQuestions= document.the_form.length;
	var the_total = 0;
	for (controlIndex = 0; controlIndex < numberOfQuestions; controlIndex++)
		{
			var element = document.the_form[controlIndex].checked;
			if (element == true) 
			{
			  window.document.the_form[controlIndex].checked = false;
			}
		}
	
}

function bcolor(bcol,d_name)
{
if (document.all)
{
 var thestyle= eval ('document.all.'+d_name+'.style');
 thestyle.backgroundColor=bcol;
 }
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
