var allSliders = new Array();
var mouseDocX = 0;

function $ (id) {
	return document.getElementById(id);
}


function updatePsychopathScore (form) {
	var scoreElement = $('psychopathyScore');
	scoreElement.innerHTML = getDiagnosis(form);
}


function getDiagnosis (form) {
	var el;
	var score = 0;
	
	for (var i=0; i < form.elements.length; i++) {
		el = form.elements[i];
		if (el.checked) {
			score+= parseInt(el.value);
		}
	}
	
	if (score < 2) {
		return "Selfless goodie-two-shoes";
	}
	else if (score <= 8) {
		return "Relatively normal";
	}
	else if (score <= 23) {
		return "Non-psychopath with criminal leanings";
	}
	else if (score <= 28) {
		return "Moderately psychopathic";
	}
	else if (score <= 39) {
		return "Psychopath";
	}
	else if (score == 40) {
		return "Pure psychopath";
	}

}


function showTextOnly () {
	var text = '<pre>';
	var psychopathyTest = $('psychopathyTest');
	var textOnly = $('textOnlyValues');

	text+= "Glibness/superficial charm = " + getResponse('1') + "\n";
	text+= "Egocentric, exaggerated self-image = " + getResponse('2') + "\n";
	text+= "Need for stimulation/bored easily = " + getResponse('3') + "\n";
	text+= "Pathological lying = " + getResponse('4') + "\n";
	text+= "Conning and manipulativeness = " + getResponse('5') + "\n";
	text+= "Lack of remorse or guilt = " + getResponse('6') + "\n";
	text+= "Shallow emotions = " + getResponse('7') + "\n";
	text+= "Callousness and lack of empathy = " + getResponse('8') + "\n";
	text+= "Parasitic lifestyle = " + getResponse('9') + "\n";
	text+= "Poor behavioral controls = " + getResponse('10') + "\n";
	text+= "Sexual promiscuity = " + getResponse('11') + "\n";
	text+= "Childhood behavior problems = " + getResponse('12') + "\n";
	text+= "Lack of realistic long-term goals = " + getResponse('13') + "\n";
	text+= "Impulsivity = " + getResponse('14') + "\n";
	text+= "Irresponsibility = " + getResponse('15') + "\n";
	text+= "Failure to accept responsibility for actions = " + getResponse('16') + "\n";
	text+= "Many short-term relationships = " + getResponse('17') + "\n";
	text+= "Varied criminal behavior = " + getResponse('18') + "\n";
	text+= "Posts 'first' messages = " + getResponse('19') + "\n\n";
	
	text+= "Probable diagnosis = " + getDiagnosis(document.responses) + "\n</pre>";

	textOnly.innerHTML = text;
	psychopathyTest.style.display = 'none';
	textOnly.parentNode.style.display = 'block';
}


function getResponse (questionNumber) {
	var radio = document.responses.elements['radio_q' + questionNumber];
	
	if (radio) {
		if (radio[0].checked) {
			return "YES";
		}
		if (radio[1].checked) {
			return "SOMEWHAT";
		}
		if (radio[2].checked) {
			return "NO";
		}
		
	}
}


function showTest () {
	var psychopathyTest = $('psychopathyTest');
	var textOnly = $('textOnlyValues');
	
	psychopathyTest.style.display = 'block';
	textOnly.parentNode.style.display = 'none';	
}



