function errorCheck(){

for(i=0;i<document.frmQuiz.elements.length;i++){
   	if(document.frmQuiz.elements[i].type == "select-one"){
		if(document.frmQuiz.elements[i].options[document.frmQuiz.elements[i].selectedIndex].value =="none"){
			return false;
		}
	}
		
}
return true;
}


function calcQuiz(){
	var count1 = 0;
	var type1="none";
	var letter1 = "none";
	var count2 = 0;
	var type2 ="none";
	var letter2 = "none";
	var count3 = 0;
	var type3="none";
	var letter3 = "none";
	var count4 = 0;
	var type4="none";
	var letter4 = "none";
	var combo="none";
	var desc = "none";

	if(document.frmQuiz.sec1_1.options[document.frmQuiz.sec1_1.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_2.options[document.frmQuiz.sec1_2.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_3.options[document.frmQuiz.sec1_3.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_4.options[document.frmQuiz.sec1_4.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_5.options[document.frmQuiz.sec1_5.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_6.options[document.frmQuiz.sec1_6.selectedIndex].value=="A"){
		count1++;
	}
	if(document.frmQuiz.sec1_7.options[document.frmQuiz.sec1_7.selectedIndex].value=="A"){
		count1++;
	}
	
	switch(count1){
		case 0: 
			type1="100% Energy from within";
			break;
		case 1: 
			type1="86%  Energy from within";
			break;
		case 2: 
			type1="71%  Energy from within";
			break;
		case 3: 
			type1="57%  Energy from within";
			break;
		case 4: 	
			type1="57%  Energy from the outside world ";
			break;
		case 5: 	
			type1="71%  Energy from the outside world ";
			break;
		case 6: 	
			type1="86%  Energy from the outside world ";
			break;
		case 7: 	
			type1="100% Energy from the outside world ";
			break;
	}

	if(count1>3){
		letter1 = "E";
	}
	else{
		letter1 = "I";
	}
	

	if(document.frmQuiz.sec2_1.options[document.frmQuiz.sec2_1.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_2.options[document.frmQuiz.sec2_2.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_3.options[document.frmQuiz.sec2_3.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_4.options[document.frmQuiz.sec2_4.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_5.options[document.frmQuiz.sec2_5.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_6.options[document.frmQuiz.sec2_6.selectedIndex].value=="A"){
		count2++;
	}
	if(document.frmQuiz.sec2_7.options[document.frmQuiz.sec2_7.selectedIndex].value=="A"){
		count2++;
	}
	switch(count2){
		case 0: 
			type2="100% Big-picture focused";
			break;
		case 1: 
			type2="86%  Big-picture focused";
			break;
		case 2: 
			type2="71%  Big-picture focused";
			break;
		case 3: 
			type2="57%  Big-picture focused";
			break;
		case 4: 	
			type2="57%  Present-moment focused";
			break;
		case 5: 	
			type2="71%  Present-moment focused";
			break;
		case 6: 	
			type2="86%  Present-moment focused";
			break;
		case 7: 	
			type2="100% Present-moment focused";
			break;
	}
	if(count2>3){
		letter2 = "S";
	}
	else{
		letter2 = "N";
	}



	if(document.frmQuiz.sec3_1.options[document.frmQuiz.sec3_1.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_2.options[document.frmQuiz.sec3_2.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_3.options[document.frmQuiz.sec3_3.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_4.options[document.frmQuiz.sec3_4.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_5.options[document.frmQuiz.sec3_5.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_6.options[document.frmQuiz.sec3_6.selectedIndex].value=="A"){
		count3++;
	}
	if(document.frmQuiz.sec3_7.options[document.frmQuiz.sec3_7.selectedIndex].value=="A"){
		count3++;
	}
	
	switch(count3){
		case 0: 
			type3="100% Decisions based on people ";
			break;
		case 1: 
			type3="86%  Decisions based on people ";
			break;
		case 2: 
			type3="71%  Decisions based on people ";
			break;
		case 3: 
			type3="57%  Decisions based on people ";
			break;
		case 4: 	
			type3="57%  Decisions based on facts ";
			break;
		case 5: 	
			type3="71%  Decisions based on facts ";
			break;
		case 6: 	
			type3="86%  Decisions based on facts ";
			break;
		case 7: 	
			type3="100% Decisions based on facts ";
			break;
	}
	if(count3>3){
		letter3 = "T";
	}
	else{
		letter3 = "F";
	}


	if(document.frmQuiz.sec4_1.options[document.frmQuiz.sec4_1.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_2.options[document.frmQuiz.sec4_2.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_3.options[document.frmQuiz.sec4_3.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_4.options[document.frmQuiz.sec4_4.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_5.options[document.frmQuiz.sec4_5.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_6.options[document.frmQuiz.sec4_6.selectedIndex].value=="A"){
		count4++;
	}
	if(document.frmQuiz.sec4_7.options[document.frmQuiz.sec4_7.selectedIndex].value=="A"){
		count4++;
	}
	
	switch(count4){
		case 0: 
			type4="100% Decisive planner ";
			break;
		case 1: 
			type4="86%  Decisive planner ";
			break;
		case 2: 
			type4="71%  Decisive planner ";
			break;
		case 3: 
			type4="57%  Decisive planner ";
			break;
		case 4: 	
			type4="57%  Open-ended planner  ";
			break;
		case 5: 	
			type4="71%  Open-ended planner  ";
			break;
		case 6: 	
			type4="86%  Open-ended planner  ";
			break;
		case 7: 	
			type4="100% Open-ended planner  ";
			break;
	}
	if(count4>3){
		letter4 = "P";
	}
	else{
		letter4 = "J";
	}

	combo = letter1+letter2+letter3+letter4;

	switch(combo){
		case "ESTJ":
			desc = "'The Logical Manager'.\n\nYou are a strong leader who prefers to deal with logical events and here-and-now connections. Traditions and ceremonies are important for you and you are concerned with maintaining a good society. At work, you don't stop until the job is done and are efficient, practical and logical . Socially, you are gregarious, outgoing, tend to make jokes and enjoy being an energetic participant in group activities.";  
		break;
		case "INFJ":
			desc = "'The Ethical Advisor'.\n\nYou are an empathetic friend and focused on future possibilities. You are value-focused, have strong ethical feelings about what is right, and may be involved in social causes/issues important to you. Socially, you are often quiet, though you do have a silly/goofy social side and are talkative with friends. You are considerate and very open to conversation with others. A natural listener, others are drawn to your warmth and quiet confidence.";
		break; 
		case "ENFP":
			desc = "'The Enthusiastic Motivator'.\n\nYou are a concerned champion of potential possibilities for people. You are interested in expanding your horizons and experiencing new things. Socially, you are upbeat, fun, sometimes outgoing and sometimes quiet.";
		break;
		case "ISTP":
			desc = "'The Independent Problem-Solver'. You are an adventurous crafter of here-and-now goals and projects using logic and the five senses. You are 'up for anything' and like new experiences, autonomy and living life by your own rules. Socially, you know how to have fun, like to do your own thing, and also really appreciate your close circle of friends.";
		break;
		case "ENTJ":
			desc = "'The Efficient Leader'. You are a visionary leader who uses logical patterns to lead people towards the most efficient solution. Independent, confident and decisive, you naturally lead people. You enjoy logical discussions and theory. Socially, you enjoy conversing with others and making friends, though you sometimes prefer debate to small talk. Others are drawn to your natural confidence, and making friends comes naturally to you.";
		break;
		case "ISFJ":
			desc = "'The Loyal Supporter'. You are a patient, caring helper of people in the here-and-now based on the conventions of society, family traditions and work expectations. Considerate, polite and socially-focused, you enjoy spending time with friends and family. Though you enjoy big social events, you cherish your close relationships and would do just about anything for the people you care about, making you a prized friend. ";
		break; 
		case "ESFP":
			desc = "'The Entertaining Diplomat'. You are a take-charge, people-focused, enthusiastic life of the party type. You enjoy the here-and-now, are energized by challenges and take immediate action to deal with present-moment problems in a practical way. With others, you are empathetic and enjoy helping people. Socially adept, outgoing and always ready with a charming joke, you tend to be invited to many parties.";
		break;
		case "INTP":
			desc = "'The Analytical Philosopher'. At heart, you are an abstract philosopher who uses logical patterns of events to build systems of theory-based information in an open-ended way. You are a natural critic and can point out important problems before a project starts. Socially, you are laid back, spontaneous, independent and are open to socializing with fun people. You tend to prefer a small group of close friends who know you well.";
		break;
		case "ENTP":
			desc = "'The Conceptualizer'. You are an inventive creator of logical systems of possibilities that you use to create processes, products or strategies. Socially, you are sometimes quiet and often the life of the party, especially when you get caught up in a debate or entertaining topic of conversation.";
		break;
		case "ISFP":
			desc = "'The Enjoyer of Life'. You enthusiastically enjoy experiencing the five senses, creative pursuits and social harmony in the here-and-now. You are independent, socially upbeat, and enjoy creating a positive and happy atmosphere. Despite your outgoing persona, you are a private person and few people truly know you well.";
		break;
		case "INTJ":
			desc = "'The Planner'. You are an analyst of logical connections between big-picture future possibilities and a creator of contingency plans. Socially, you're confident, independent and bring good humor, wit and fun to events.";
		break;
		case "ESFJ":
			desc = "'The Socialite'. You are a communicator of feelings, social connector of people and concerned with emotional exchanges between people and sensory pleasures in the here-and-now. Socially, you put people at ease, easily communicate, project confidence and are often a great host or hostess.";
		break;       
		case "ENFJ":
			desc = "'The Socially-Focused Idealist'. You are a self-expressive communicator of ethically-important information, driven to improve humanity. You enjoy socializing with others, mentoring others at work and getting friends together. A stickler for details, you enjoy big-picture theory and often are involved with important social issues. Others see you as outgoing, passionate, friendly and warm.";
		break;
		case "INFP":
			desc = "'The Reflective Seeker of Truth'. You are a passionate searcher of big-picture meaning and strive to help others with your empathetic listening skills. Socially, you are usually quiet, but can be a social butterfly when you feel like it. You have a very silly and goofy side, enjoy people and need time to quietly reflect.";
		break;
		case "ISTJ":
			desc = "'The logical Assessor'. You are a realistic, steady, stable person and a supporter of society-strengthening laws, rules, systems and protocols in the here-and-now. Socially, you may come across as quiet and confident, but your friends know that you can be the life of the party when you feel like it, and you have a fun silly side as well! Others really enjoy your company.";
		break;
		case "ESTP":
			desc = "'The Strong-Willed Go-Getter'. You are a bold sculptor of the here-and-now in order to achieve immediate results following a logical system for making decisions. You add a fun, upbeat vibe to social events.";
		break;
	}


	document.frmQuiz.txtResults.value = type1 + "\n" + type2 + "\n" + type3 + "\n" + type4 + "\n\n" + "This means your personality type is " + desc;
	//document.frmQuiz.txtType.value = combo;
}

function getResults(){
	
	if(!errorCheck()){
		alert("Please answer all questions");
	}
	else{
		calcQuiz();
	}

}
function sendEmail(){
	
	document.frmQuiz.action+= "?subject=Personality Quiz Results from " + document.frmQuiz.fullname.value +  "&body=fullname:" + document.frmQuiz.fullname.value + "****" + "email:" +  document.frmQuiz.email.value + "****" + "profilename:" + document.frmQuiz.profilename.value + "****" + document.frmQuiz.txtResults.value;// + "********" + document.frmQuiz.txtType.value + "*******";

	document.frmQuiz.submit();

}
