/*Feel free to use this in any way you like. You can reach
me at pesotum74@yahoo.com. Just unzip the file and link 
to psychictest.html*/

guess=0;
correct = 0;
incorrect = 0;
function FormatNumber(num, decimalNum, bolLeadingZero, bolParens)
/* IN - num:            the number to be formatted
decimalNum:     the number of decimals after the digit
bolLeadingZero: true / false to use leading zero
bolParens:      true / false to use parenthesis for - num

RETVAL - formatted number
*/
{
	var tmpNum = num;
	
	// Return the right number of decimal places
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.floor(tmpNum);
	tmpNum /= Math.pow(10,decimalNum);
	
	var tmpStr = new String(tmpNum);
	
	// See if we need to hack off a leading zero or not
	if (!bolLeadingZero && num < 1 && num > -1 && num !=0)
		if (num > 0) {
		tmpStr = tmpStr.substring(1,tmpStr.length);}
		else {
		// Take out the minus sign out (start at 2)
		tmpStr = "-" + tmpStr.substring(2,tmpStr.length);
	}
	
	// See if we need to put parenthesis around the number
	if (bolParens && num < 0) {
		tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")";
	}
	
	return tmpStr;
}

function generateRandomNumber(name) {
	answer=Math.floor(Math.random()*5) +1
		if(answer == name) {
			correct++;
		guess++;
		shape = new Array('Krog','Kriz','Kvadrat','Zvezda','Valovi')
			now = "Pravilno. Odgovor je " + shape[answer - 1];
		
		document.fname.report.value =guess;
		document.fname.report2.value = now;
		document.fname.report4.value = correct;
		document.fname.report6.value =Math.floor(correct/guess * 100) +"%";
		} else {
		incorrect++;
		guess++;
		shape = new Array('Krog','Kriz','Kvadrat','Zvezda','Valovi')
			now = "Narobe. Odgovor je "+ shape[answer - 1];
		document.fname.report.value =guess;
		document.fname.report2.value = now;
		document.fname.report4.value = correct;
		document.fname.report6.value =Math.floor(correct/guess * 100) +"%";
		//document.fname.report.value =
	}
}
function psychic() {
	a = .16 * guess;
	b = Math.sqrt(a);
	c = guess * .2 ;
	d = correct - c ;
	e =(d/b) ;
	f = Math.abs(e);
	g = FormatNumber(f,2,true,false)
		if( f <= 1.96) {
			document.fname.tell.value = "Vas rezultat " +g+ " ne da slutiti, da bi imeli intuitivne sposobnosti.";
		} if( f > 1.96 && f <= 2.58) {
		document.fname.tell.value = "Vas rezultat " +g+ " da slutiti le majhne intuitivne sposobnosti." ;
	}
	if( f > 2.58 && f <= 3.00) {
		document.fname.tell.value = "Vas rezultat " +g+ " je dober! Ocitno imate intuitivne sposobnosti. " ;
		if( f > 3.00) {
			document.fname.tell.value = "Vas rezultat " +g+ " je odlicen! Ocitno imate zelo razvite intuitivne sposobnosti" ;
		}
	}
}
function openit(){
	winda =
		window.open("","newone","scrollbars,toolbar=no,location=no,directories=no,status=no,menubar=yes,resizable=yes,width=400,height=200");
	winda.focus();
	winda.document.open();
	winda.document.write("This test is based on the Zenner card test.  Since the shape is not selected until after you have made your choice, this is a test of your ability to predict future events.  The accuracy of the result increases with the number of guesses that you make.  The significance level is determined by a formula that was used with the Zenner tests.  Less then 1.96 indicates no psychic ability.  1.96 to 2.58 indicates some psychic ability.  2.58 to 3.00 indicates significant psychic ability. Greater then 3.00 indicates very signficant psychic ability.");
	
	
	winda.document.close();
}
