
var testqs=[
    "",
    "Do you believe hypnosis can help you?",
    "Have you ever daydreamed?",
    "Are you able to follow simple instructions?",
    "Do you have a vivid imagination?",
    "Can you imagine the sound of the wind blowing?",
    "Does your mouth begin to water when you think of biting into a plump, juicy, sour lemon?",
    "Have you ever been so caught up in a book that you couldn't put it down?",
    "Can you sometimes arise from sleep to get a drink of water and then immediately go back to sleep?",
    "Are you willing to accept new ideas for change that will improve your life?",
    "Have you ever driven a car and lost track of time and missed your turn?",
    "Have you ever been so involved in a television program that you didn't notice someone in the room was talking to you?",
    "While listening to a favorite song, can you remember what you were doing, where you were at, and who you were with when you first heard it?",
    "Have you ever cried or been frightened while watching a movie?",
    "Do you shudder at the thought of someone scratching his or her fingernails down the front of the chalkboard?",
    "Did you ever lose track of time while doing something really enjoyable?",
    "Have you ever impulsively purchased a cup of coffee, a bag of popcorn, or a hot, freshly baked cinnamon roll because of the aroma filtering through the air?",
    "Are you able to recall a positive memory so clearly that you can remember what you felt, heard, saw, smelt, and/or tasted?",
    "Do you sometimes have vivid dreams?"
];

var answers = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var xxhtml="";
function take_test(attrs) {
    attrs = attrs || {};
    var opacity = attrs.opacity || 0.50;
    var bgcolor = attrs.background || "#000";
    var fade = attrs.fade || 1;
    var elt = document.getElementById('hiddentest');
    if(elt) {
	if(xxhtml == "") xxhtml = elt.innerHTML;   
	_show_dialog('testdialog', xxhtml,
                     function(x){ return x },
                     null,
                     {
			 background: bgcolor,
			 opacity: opacity,
			 fade: 0,
			 popup:0,
			 onopen:function(){_qno=1;showq(1);},
			 onclose:function(){}
                     }
                    );
	elt.innerHTML="";   
    }
}

function showq(k) {
    var m = "q" + k;
    var txt = testqs[k];
    var el=document.getElementById("qbox");
    if(el) { el.innerHTML="<table cellpadding=4><tr><td valign='top'>"+k+".</td><td>" +txt + "</td></tr></table>";}
    el=document.getElementById("abox");
    if(el) {el.style.display="block";}
}

function grade() {
    el=document.getElementById("abox");
    if(el) {el.style.display="none";}
    total=0;
    for(var i=0; i<testqs.length; i++) {total += answers[i];}
    var el=document.getElementById("qbox");
    var clw = "<div class=\"closex\">" +
	"<a href=\"javascript:void(0)\" onclick=\"_close_all_dialogs()\">" +
	"<img src=\"images/closex.gif\" width=\"100\" height=\"41\" border=0></a>" +
	"</div>";
    if(total >= 15) {
	el.innerHTML="<div class=\"hypnoableYES\"><div class=\"grades\">" + 
	    "<img src=\"images/check-sqrt.gif\" width=16 height=16 border=0 align=left>&nbsp;" +
	    " You answered YES to "+
	    total + " questions posted above...</div>" +
	    "<div class=\"note\">Congratulations!<br><br>" +
	    "You are definitely HYPNOTIZABLE!</div></div>" +
	    clw; 
    } else {
	el.innerHTML="<div class=\"hypnoableNO\"><div class=\"grades\">" +
	    "<img src=\"images/check-x.gif\" width=16 height=16 border=0 align=left>&nbsp;" +
	    "You answered YES to " +
	    total + " of the questions posted above ...</div>" +
	    "<div class=\"notea\">Hypnosis may not be right for you ...<br>" +
	    "While most people are in fact hypnotizable, there must be an "+
	    "openness to the process. Find out for yourself how positive "+
	    "the experience can be. Call for a free "+
	    "telephone consultation.</div></div>" +
	     clw ;
    }
}
function ayes() {
    answers[_qno]=1;
    _qno++;
    if(_qno == testqs.length ) {
	grade();
    } else {
	showq(_qno);
    }
}
function ano(i) { 
    answers[_qno]=0;
    _qno++;
    if(_qno == testqs.length) {
	grade();
    } else {
	showq(_qno);
    }
}