// JavaScript Document
function get_cookie (cookiename)
{
  var results = document.cookie.match ( '(^|;) ?' + cookiename + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else{
    return null;
	}
}

function popUp(URL) {

window.open(URL, '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=500, height=712');
}

function grade_it(){
	wand=0;
	cup=0;
	pentacles=0;
	sword=0;
	type="";
	
	len1 = document.survey.q1.length;
	for (i = 0; i <len1; i++) {
	if (document.survey.q1[i].checked) {
		chosen1 = document.survey.q1[i].value;
		if (chosen1== "a"){wand= 5+wand;}
		else if(chosen1=="b"){cup = cup+5;}
		else if(chosen1=="c"){pentacles= pentacles+5;}
		else{sword= sword+5;}
		}
	}
	
	//--------------------------------------------------------------
	len2 = document.survey.q2.length;
	for (i = 0; i <len2; i++) {
	if (document.survey.q2[i].checked) {
		chosen2 = document.survey.q2[i].value;
		if (chosen2== "a"){wand= 3+wand;}
		else if(chosen2=="b"){cup = cup+2;}
		else if(chosen2=="c"){pentacles= pentacles+2; cup=cup+1;}
		else{sword= sword+3; pentacles= pentacles+1;}
		}
	}
	
	//---------------------------------------------------------------
	len3 = document.survey.q3.length;
	for (i = 0; i <len3; i++) {
	if (document.survey.q3[i].checked) {
		chosen3 = document.survey.q3[i].value;
		if (chosen3== "a"){wand= 3+wand;}
		else if(chosen3=="b"){cup = cup+3;}
		else if(chosen3=="c"){pentacles= pentacles+3;}
		else{sword= sword+3;}
		}
	}
	
	//--------------------------------------------------------------
	len4 = document.survey.q4.length;
	for (i = 0; i <len4; i++) {
	if (document.survey.q4[i].checked) {
		chosen4 = document.survey.q4[i].value;
		if (chosen4== "a"){wand= 2+wand;}
		else if(chosen4=="b"){cup = cup+2;}
		else if(chosen4=="c"){pentacles= pentacles+2;}
		else{sword= sword+2;}
		}
	}
	
	//---------------------------------------------------------------
	len5 = document.survey.q5.length;
	for (i = 0; i <len5; i++) {
	if (document.survey.q5[i].checked) {
		chosen5 = document.survey.q5[i].value;
		if (chosen5== "a"){wand= 3+wand; pentacles = pentacles+1;}
		else if(chosen5=="b"){cup = cup+4;}
		else if(chosen5=="c"){pentacles= pentacles+3; wand=wand+1;}
		else{sword= sword+4;}
		}
	}
	//---------------------------------------------------------------
	len6 = document.survey.q6.length;
	for (i = 0; i <len6; i++) {
	if (document.survey.q6[i].checked) {
		chosen6 = document.survey.q6[i].value;
		if (chosen6== "a"){wand= 4+wand;}
		else if(chosen6=="b"){cup = cup+4;}
		else if(chosen6=="c"){pentacles= pentacles+4;}
		else{sword= sword+4;}
		}
	}
	//---------------------------------------------------------------
	len7 = document.survey.q7.length;
	for (i = 0; i <len7; i++) {
	if (document.survey.q7[i].checked) {
		chosen7 = document.survey.q7[i].value;
		if (chosen7== "a"){wand= 4+wand;}
		else if(chosen7=="b"){cup = cup+4;}
		else if(chosen7=="c"){pentacles= pentacles+4;}
		else{sword= sword+4;}
		}
	}
	//---------------------------------------------------------------
	len8 = document.survey.q8.length;
	for (i = 0; i <len8; i++) {
	if (document.survey.q8[i].checked) {
		chosen8 = document.survey.q8[i].value;
		if (chosen8== "a"){wand= 4+wand;}
		else if(chosen8=="b"){cup = cup+4;}
		else if(chosen8=="c"){pentacles= pentacles+4;}
		else{sword= sword+4;}
		}
	}
	//---------------------------------------------------------------
	len9 = document.survey.q9.length;
	for (i = 0; i <len9; i++) {
	if (document.survey.q9[i].checked) {
		chosen9 = document.survey.q9[i].value;
		if (chosen9== "a"){wand= 2+wand;}
		else if(chosen9=="b"){cup = cup+2;}
		else if(chosen9=="c"){pentacles= pentacles+2;}
		else{sword= sword+2;}
		}
	}
	if(pentacles >= wand && pentacles >=cup  && pentacles >= sword){type="pentacles";}
	else if(wand >= cup && wand >= pentacles && wand >= sword){type="wand";}
	else if(cup >= wand && cup >= pentacles && cup >=sword){type="cup";}
	
	else if(sword > cup && sword > wand && sword > pentacles){ type="sword";}
	//alert(type);
	//var score = eval(parseInt(chosen1)+ parseInt(chosen2)+parseInt(chosen3)+parseInt(chosen4)+parseInt(chosen5));
	document.cookie = "type=" + type;
}
function readgrade(){
	var type = get_cookie ("type");
	
	if(type =="wand"){
		document.write("<p align='center'><img src='images/queen-swords_03.jpg'></p>");
		document.write("<p class='copy'>You are a natural intellect and a go-getter. You take charge when other people falter and you stand tall in the face of adversary. You stand out in a crowd. You have a wonderful knowledge base – you are well read and have diversified interests- many of which you are successful at. You project your ideas clearly, but have little patience for people you find stupid. You can appear cold at times and even your friends may find you a bit aloof. You are an analytical person who has little time to offer sympathy and compassion to people with continued problems. </p>");
		document.write("<p class='copy'><span style='color:#695077'>Lucky Colors:</span> White <br/> <span style='color:#695077'>Lucky Day:</span> Tuesday");
		document.write("<p align='center'><img src='images/queen-swords_06.jpg'></p>");
		}
	else if(type =="cup"){
		document.write("<p align='center'><img src='images/quiz-cups_03.jpg'></p>");
		document.write("<p class='copy'>People are drawn to your compassionate nature. You are sensitive and imaginative- maybe even psychic! You value self-expression whether it is through the art, music or cooking. You thrive in a relationship, but beware that you don’t wear your heart on your sleeve. You are a very empathic person- friends, family, even strangers feel that they can open up to you and that you understand them. At times you can let your feelings be too easily hurt or you can become discouraged too easily. Try to step out of the situation and utilize your own good advice.  </p>");
		document.write("<p class='copy'><span style='color:#695077'>Lucky Colors:</span> Blue and Purple <br/> <span style='color:#695077'>Lucky Day:</span> Thursday");
		document.write("<p align='center'><img src='images/quiz-cups_03-02.jpg'></p>");
		}
	else if(type =="pentacles"){
		document.write("<p align='center'><img src='images/quiz-pentacles_03.jpg'></p>");
		document.write("<p class='copy'>You are a very practical, sensual woman. You love to have the best in life & you are not afraid to work hard for it. You are an ambitious person and your enthusiasm for life is infectious. You have impeccable taste and high standards. Your success at making good decisions can make you a little narrow-minded about other people’s ideas. People can be intimidated by your high standards. In relationships, encourage your partner to be him/herself.  Being open to new things will only broaden your interests and cultivate your taste. </p>");
		document.write("<p class='copy'><span style='color:#695077'>Lucky Colors:</span> Green and Brown <br/> <span style='color:#695077'>Lucky Day:</span> Friday");
		document.write("<p align='center'><img src='images/quiz-pentacles_03-02.jpg'></p>");
		}
	else{
		document.write("<p align='center'><img src='images/quiz-wands_03.jpg'></p>");
		document.write("<p class='copy'>You are versatile, creative and talented. You love being the center of attention and people are easily attracted to you. You have a knack at making friends – maybe because your sense of humor makes you open and relatable.  You seem to have an endless supply of energy, which fuels your ability to juggle a multitude of tasks at once. Although you tend to put yourself first, you make a great co-worker and friend. Use your charm and dynamic personality to create new opportunities and share the spotlight with friends or workers who may feel second best to you. </p>");
		document.write("<p class='copy'><span style='color:#695077'>Lucky Colors:</span> Red and Orange <br/> <span style='color:#695077'>Lucky Day:</span> Sunday");
		document.write("<p align='center'><img src='images/quiz-wands_03-02.jpg'></p>");
		}
	//document.write("Your Medication Management Survey Score is "+type+".")
	}
	


function checkSubmit(theForm) {
    var p = 'Please supply the following:\n';
    var val = true;
    var fld = null;

    if ((theForm.name.value) == '') {
        p = p + '\nName';
        val = false;
        fld = theForm.name;
    }
	else if ((theForm.dob.value) == '') {
		p = p + '\nDate of Birth';
		val = false;
		if (fld == null) fld = theForm.dob;
	} 
    
    else if ((theForm.phone.value) == '') {
		p = p + '\nphone';
		val = false;
		if (fld == null) fld = theForm.phone;
	} 
	else if ((theForm.email.value) == '') {
		p = p + '\nE-mail Address';
		val = false;
		if (fld == null) fld = theForm.email;
	} 
	else if ((theForm.address.value) == '') {
		p = p + '\nAddress';
		val = false;
		if (fld == null) fld = theForm.address;
	} 
	else if ((theForm.city.value) == '') {
		p = p + '\nCity';
		val = false;
		if (fld == null) fld = theForm.city;
	} 
	else if ((theForm.country.value) == '') {
		p = p + '\nCountry';
		val = false;
		if (fld == null) fld = theForm.country;
	} 
	else if ((theForm.state.value) == '') {
		p = p + '\nState';
		val = false;
		if (fld == null) fld = theForm.state;
	} 
	else if ((theForm.zip.value) == '') {
		p = p + '\nZip';
		val = false;
		if (fld == null) fld = theForm.zip;
	} 
	

    if (!val) {
        alert(p);
        if (fld != null) fld.focus();
    }
    return val;
}
