var imgSrc = "http://www.mcgrawhill.ca/college/olcsupport/mcshane6e/selfassess/";
// ---------------------------------------
var ansWin = null;
var qCount = 20;
// ---------------------------------------
function WriteResponse(content) {
if (ansWin && !ansWin.closed) {
	ansWin.close()
}
ansWin = window.open("","","toolbar=NO,location=NO,resizable,scrollbars,width=650,height=450");
ansWin.document.write(content);
ansWin.document.close();
}
// -----------------------------
function GetSelection(radios) {
for (var i=0; i<radios.length; i++) {
	if (radios[i].checked) {
		return i;
	}
}
return 99;
}
// ---------------------------------------
function GradeAssess(theForm) {
var cntlname; var cntlname2; var cont; var cont2;
// currently supports 4 categories
var totals = new Array(5);
totals[0] = 0; totals[1] = 0; totals[2] = 0; totals[3] = 0; totals[4] = 0;
var tmp;
for (var i = 0; i < qCount; i++) {
	cntlname2 = "Q" + (i+1) + "Cat";
	cont2 = theForm[cntlname2].value;
	cntlname = "QX"+ (i+1);
	tmp = GetSelection(theForm[cntlname]);
	if (tmp == 99) {
		alert("One or more questions are unanswered. Please complete the form and try again.");
		return false;
	}
	cont = theForm[cntlname][tmp].value;
	totals[cont2] += (cont/1);
}
var rsp = "";
rsp += BeginPage();
rsp += GetFeedback0();
var llabel = "" + "1.0";
var rlabel = "" + "5.0";
var top1 = "Low<br>positive energy<br>1.0 to 2.3";
var top2 = "Moderate<br>positive energy<br>2.4 to 3.7";
var top3 = "High<br>positive energy<br>3.8 to 5.0";
var labelnum = ""; var calcnum = 0;
// when averaging averaging: 4 5 6 5 are divisors for 4 categories
var aver = "" + (totals[1]/4);
var dotspot = aver.indexOf(".")
if (dotspot >= 0) {
	// labelnum = "" + aver.substr(0,dotspot) + "." + aver.substr(dotspot+1,1)
	labelnum = "" + aver.substr(0,dotspot + 2)
} else {
	labelnum = "" + aver.substr(0) + ".0"
}
// all calculation in building the graph are mutliplying 0.0 values by 10; the proportions are right but easier to construct the graph
calcnum = (parseFloat(labelnum)*10)
rsp += MakeTable3(10,50,calcnum,llabel,rlabel,labelnum,top1,top2,top3,14,14,12);
rsp += GetFeedback1();
top1 = "Low<br>relaxation<br>1.0 to 2.3";
top2 = "Moderate<br>relaxation<br>2.4 to 3.7";
top3 = "High<br>relaxation<br>3.8 to 5.0";
aver = "" + (totals[2]/5);
dotspot = aver.indexOf(".")
if (dotspot >= 0) {
	labelnum = "" + aver.substr(0,dotspot + 2)
} else {
	labelnum = "" + aver.substr(0) + ".0"
}
calcnum = (parseFloat(labelnum)*10)
rsp += MakeTable3(10,50,calcnum,llabel,rlabel,labelnum,top1,top2,top3,14,14,12);
rsp += GetFeedback2();
top1 = "Low<br>negative arousal<br>1.0 to 2.3";
top2 = "Moderate<br>negative arousal<br>2.4 to 3.7";
top3 = "High<br>negative arousal<br>3.8 to 5.0";
aver = "" + (totals[3]/6);
dotspot = aver.indexOf(".")
if (dotspot >= 0) {
	labelnum = "" + aver.substr(0,dotspot + 2)
} else {
	labelnum = "" + aver.substr(0) + ".0"
}
calcnum = (parseFloat(labelnum)*10)
rsp += MakeTable3(10,50,calcnum,llabel,rlabel,labelnum,top1,top2,top3,14,14,12);
rsp += GetFeedback3();
top1 = "Low<br>tiredness<br>1.0 to 2.3";
top2 = "Moderate<br>tiredness<br>2.4 to 3.7";
top3 = "High<br>tiredness<br>3.8 to 5.0";
aver = "" + (totals[4]/5);
dotspot = aver.indexOf(".")
if (dotspot >= 0) {
	labelnum = "" + aver.substr(0,dotspot + 2)
} else {
	labelnum = "" + aver.substr(0) + ".0"
}
calcnum = (parseFloat(labelnum)*10)
rsp += MakeTable3(10,50,calcnum,llabel,rlabel,labelnum,top1,top2,top3,14,14,12);
rsp += GetFeedback4();
rsp += EndPage();
WriteResponse(rsp);
return false;
}
// ---------------------------------------
function MakeTable3(datamin,datamax,dscore,ll,lr,strlabel,lt1,lt2,lt3,bl1,bl2,bl3) {
// bl1 + bl2 + bl3 should equal spread
// differing from others, strlabel added as part of decimal method
var spread = datamax - datamin;
var maxwidth = 550;
var dfactor = (maxwidth - (maxwidth%spread))/spread;
var gwidth = spread * dfactor;
var gscore = (dscore - datamin) * dfactor;
var ptrloc = gscore - 7;
var ptricon;
if ( (ptrloc) < 0 ) {
	ptricon = "redpointerleft.gif\" width=\"8\"";
	ptrloc = gscore
} else {
	if ( (ptrloc + 15) > gwidth ) {
		ptricon = "redpointerright.gif\" width=\"8\"";
		ptrloc = gscore - 8
	} else {
		ptricon = "redpointer.gif\" width=\"15\""
	}
}
// var padder = 0;
var bar1 = bl1*dfactor;
var bar2 = bl2*dfactor;
var bar3 = gwidth - (bar1 + bar2);
var winCode = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\"><tr valign=\"bottom\"><td></td><td></td><td width=\"" + gwidth + "\" align=\"center\"><table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr valign=\"bottom\" align=\"center\"><td class=\"smlabel\" width=\"33%\">" + lt1 + "</td><td class=\"smlabel\" width=\"34%\">" + lt2 + "</td><td class=\"smlabel\" width=\"33%\">" + lt3 + "</td></tr></table></td><td></td><td></td></tr><tr valign=\"bottom\"><td rowspan=\"2\" align=\"right\" valign=\"middle\" class=\"smlabel\">" + ll + "</td><td align=\"right\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"25\"></td><td nowrap align=\"center\"><img src=\"" + imgSrc + "grayspacer.gif\" width=\"" + bar1 + "\" height=\"10\"><img src=\"" + imgSrc + "blackspacer.gif\" width=\"" + bar2 + "\" height=\"10\"><img src=\"" + imgSrc + "grayspacer.gif\" width=\"" + bar3 + "\" height=\"10\"></td><td><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"25\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"></td><td rowspan=\"2\" valign=\"middle\" class=\"smlabel\">" + lr + "</td></tr><tr valign=\"top\"><td align=\"right\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"20\"></td><td nowrap valign=\"bottom\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"" + ptrloc + "\" height=\"1\"><img height=\"12\" src=\"" + imgSrc + ptricon + "></td><td><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"20\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"></td></tr></tr></table>";
winCode += "<p align=\"center\"><font color=\"#cc0000\"><b>Your averaged score was " + strlabel + ".</b></font></p>";
return winCode
}
// ---------------------------------------
function GetFeedback0() {
var winCode = "<h3 class=\"explanation\">Understanding Your Scores on the Dispositional Mood Scale</h3><p>This self-assessment is designed to help you estimate your dispositional mood, that is, your general emotional tendency based on your personality. The four dispositional mood categories created in this scale are positive energy, relaxation, negative arousal, and tiredness. These four categories are distinguished in two ways: (1) positive affectivity versus negative affectivity and (2) high activation and low activation. Thus, the four subscales are consistent with the affect circumplex model shown in the textbook. The only difference is that this scale measures your emotional personality rather than emotions in a specific setting.</p><hr noshade size=\"1\">\n";
return winCode
}
// ---------------------------------------
function GetFeedback1() {
var winCode = "<p><b>Positive energy</b><br>People who score high on positive energy have positive affectivity and high activation. Positive affectivity is the tendency to experience positive emotional states. It is very similar to extroversion, a personality trait depicting people who are outgoing, talkative, sociable, and assertive. Positive energy also includes high activation, meaning that people who score high on this scale experience more energizing or motivating positive emotions. Scores on this scale range from 1 to 5. From a sample of hospital employees, the average score was 3.0.</p><hr noshade size=\"1\">\n";
return winCode
}
// ---------------------------------------
function GetFeedback2() {
var winCode = "<p><b>Relaxation</b><br>People who score high on relaxation have positive affectivity and low activation. Positive affectivity is the tendency to experience positive emotional states. It is very similar to extroversion, a personality trait depicting people who are outgoing, talkative, sociable, and assertive. Relaxation also includes low activation, meaning that people who score high on this scale experience more passive (less energizing) positive emotions. Scores on this scale range from 1 to 5. From a sample of hospital employees, the average score was 2.6.</p><hr noshade size=\"1\">\n";
return winCode
}
// ---------------------------------------
function GetFeedback3() {
var winCode = "<p><b>Negative arousal</b><br>People who score high on negative arousal have a tendency toward negative affectivity and high activation. Negative affectivity is the tendency to negative emotions. Negative arousal also includes high activation, meaning that people who score high on this scale experience negative emotions that demand our attention (e.g., anger, upset). People with negative arousal tend to be more distressed and unhappy because they focus on the negative aspects of life. Scores on this scale range from 1 to 5. From a sample of hospital employees, the average score was 2.1.</p><hr noshade size=\"1\">\n";
return winCode
}
// ---------------------------------------
function GetFeedback4() {
var winCode = "<p><b>Tiredness</b><br>People who score high on tiredness have a tendency toward negative affectivity and low activation. Negative affectivity is the tendency to negative emotions. Tiredness also includes low activation, meaning that people who score high on this scale experience more passive (less demanding) negative emotions. Scores on this scale range from 1 to 5. From a sample of hospital employees, the average score was 2.3.</p>\n";
return winCode
}
// ---------------------------------------
function BeginPage() {
var winCode = "<html><head><title>Organizational Behaviour Self-Assessment Exercises</title>\n\n";
winCode += "<script language=\"JavaScript\">\n<!--\n// ---------------------------\n";
winCode += "function printScreen(){\nif (window.print) {\n window.print();\n} else {\n alert(\"Your browser does not support printer links embedded within a web page. PC users, however, can right-click within the window and a popup menu will appear from which you can print. Macintosh users can access a similar menu by holding down the mouse for several seconds.\");\n}\n}\n";
winCode += "//-" + "->\n</script>\n" + GetStyles() + "</head>\n";
winCode += "<body bgcolor=\"#ffffff\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n<tr><td bgcolor=\"#000000\"><font size=\"4\">&nbsp;</font></td></tr>\n</table>\n<table border=\"0\" width=\"100%\" cellpadding=\"20\" cellspacing=\"0\">\n<tr valign=\"top\"><td>\n\n";
return winCode
}
//----------------------------------------
function GetStyles() {
return "\n<link href=\"http://www.mcgrawhill.ca/college/olcsupport/mcshane6e/selfassess/selfassess.css\" type=\"text/css\" rel=\"stylesheet\"></link>\n";
var winCode = "\n<style>\n<!-- For some reason Netscape seems to go for case sensitivity. Here's uppercase tags. -->\nA\n{\ntext-decoration: none;\n}\nA:HOVER\n{\ntext-decoration: underline;\n}\nA.hint \n{\ncolor: #999999;\ntext-decoration: none;\nfont-weight: bold;\n}\nA.nav \n{\nfont-size: 10px;\ncolor:#999999;\ntext-decoration: none;\nfont-weight:bold;\n}\nA.navCur \n{\nfont-size: 10px;\ncolor:#FFFFFF;\ntext-decoration: none;\nfont-weight:bold;\n}\nBODY \n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\nTABLE\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nTR\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nTD\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nTD.smlabel\n{\nfont-family: verdana, sans-serif; \nfont-size: 10px;\ncolor: #999999;\n}\nP\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px\n}\np\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nUL\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nOL\n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\nLI\n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\nH3 \n{\nfont-family: verdana, sans-serif;\nfont-size: 16px;\nfont-weight: bold;\ncolor: #000000;\nmargin: 0px;\npadding: 0px;\npadding-bottom: 3px;\npadding-top: 2px;\n}\n<!-- For some reason Netscape seems to go for case sensitivity. Here's lowercase tags. -->\na\n{\ntext-decoration: none;\n}\na:hover\n{\ntext-decoration: underline;\n}\na.hint \n{\ncolor: #999999;\ntext-decoration: none;\nfont-weight: bold;\n}\na.nav \n{\nfont-size: 10px;\ncolor:#999999;\ntext-decoration: none;\nfont-weight:bold;\n}\na.navCur \n{\nfont-size: 10px;\ncolor:#FFFFFF;\ntext-decoration: none;\nfont-weight:bold;\n}\nbody \n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\ntable\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\ntr\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\ntd\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\ntd.smlabel\n{\nfont-family: verdana, sans-serif; \nfont-size: 10px;\ncolor: #999999;\n}\nul\n{\nfont-family: verdana, sans-serif; \nfont-size: 12px;\n}\nol\n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\nli\n{\nfont-family: verdana, sans-serif;\nfont-size: 12px;\n}\nh3 \n{\nfont-family: verdana, sans-serif;\nfont-size: 16px;\nfont-weight: bold;\ncolor: #000000;\nmargin: 0px;\npadding: 0px;\npadding-bottom: 3px;\npadding-top: 2px;\n}\n.explanation\n{\ncolor: #0000ff;\n}\n.footer\n{\nfont-size: 10px;\n}\n</style>\n\n";
return winCode;
}
// ---------------------------------------
function EndPage() {
var winCode = "\n\n<p class=\"footer\"><hr noshade size=\"1\" />\n<font face=\"Symbol\" color=\"ff0000\">&#168;</font> <a href=\"javascript:printScreen()\"><b>Print Screen</b></a>\n</p>\n<p class=\"footer\"><a href=\"mailto:highered_web@mcgrawhill.ca\">Comments or questions?</a><br>Copyright &copy; 2004 McGraw-Hill Ryerson Limited<br>&nbsp;</p></td></tr></table></body></html>";
return winCode
}
