var imgSrc = "http://www.mcgrawhill.ca/college/olcsupport/mcshane6e/selfassess/";
// ---------------------------------------
var ansWin = null;
var qCount = 14;
// ---------------------------------------
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 GradeAssess(theForm) {
// add all the values
var cntlname; var cont; var atotal = 0
for (var i = 0; i < qCount; i++) {
	cntlname = "pd"+ (i+1);
	cont = theForm[cntlname].options[theForm[cntlname].selectedIndex].value;
	if (cont == 99) {
		alert("One or more questions are unanswered. Please complete the form and try again.");
		return false;
	}
	atotal += (cont/1);
}
var llabel = "" + "0";
var rlabel = "" + "56";
var top1 = "Low<br>perceived stress<br>0-19"
var top2 = "Moderate<br>perceived stress<br>20-39"
var top3 = "High<br>perceived stress<br>40-56"
var rsp = "";
rsp += BeginPage();
rsp += MakeTable(0,56,atotal,llabel,rlabel,top1,top2,top3,20,20,16);
rsp += GetFeedback1();
rsp += EndPage();
WriteResponse(rsp);
return false;
}
// ---------------------------------------
function GetFeedback1() {
var winCode = "<hr noshade size=\"1\"><h3 class=\"explanation\">Understanding Your Score on the Perceived Stress Scale</h3><p>The perceived stress scale estimates the extent to which recent events in your life are appraised as stressful. It taps into the degree to which you believe events in your life are currently unpredictable, uncontrollable, and overloading. The scale is not restricted to specific situations, so is appropriate for people in a variety of situations (e.g., students, executives, children).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Scores on the perceived stress scale range from 0 to 56. Higher scores indicate that you perceive your current life situation as stressful. Based on samples of over 1,000 people (mostly college students in the United States), the average score is around 24 for men and 25 for women.</p>\n";
return winCode
}
// ---------------------------------------
function MakeTable(datamin,datamax,dscore,ll,lr,lt1,lt2,lt3,bl1,bl2,bl3) {
// bl1 + bl2 + bl3 should equal spread
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 score was " + dscore + ".</b></font> The range of possible scores is from " + datamin + " to " + datamax + ".</p>";
return winCode
}
// ---------------------------------------
function BeginPage() {
var winCode = "<html><head><title>Organizational Behaviour Self-Assessment Exercises</title>\n<link type=\"text/css\" href=\"" + imgSrc + "css.css\" rel=\"stylesheet\">\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</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 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
}
