
var imgSrc = "http://www.mcgrawhill.ca/college/olcsupport/mcshane6e/selfassess/";
// ---------------------------------------

var ansWin = null;
var qCount = 12;
// ---------------------------------------
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) {

var totals = 0;

for (var i = 0; i < qCount; i++) {

	var cntlname = "pd"+ (i+1);
	var 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;
	}
	totals = totals + (cont/1);
}
var rsp = "";
rsp += BeginPage();

var llabel = "" + "12";
var rlabel = "" + "72";
var scoreLow = 12;
var scoreHigh = 72;

var header = "Level of Need for Personal Structure";

var divLabel = new Array("Low<br>12 to 26","Below average<br>27 to 37","Average<br>38 to 46","Above average<br>47 to 57","High<br>58 to 72");
var divLow = new Array(12,27,38,47,58);
var divHigh = new Array(26,37,46,57,72);


rsp += MakeTable(scoreLow,scoreHigh,totals,llabel,rlabel,divLabel,divLow,divHigh,header);


rsp += GetFeedback();

rsp += EndPage();
WriteResponse(rsp);
return false;

}
// ---------------------------------------
function MakeTable(datamin,datamax,dscore,ll,lr,divLabel,divLow,divHigh,scalehead) {

var colorBars = new Array("blackspacer.gif","grayspacer.gif");

var spread = datamax - datamin;
var maxwidth = 550;
var gwidth = maxwidth - (maxwidth%spread);
var dfactor = gwidth/spread;
var halffactor = (dfactor - (dfactor%2))/2;

var gscore = (dscore - datamin) * dfactor;

var ptricon = "redpointer.gif";
var ptrwidth = 15;
var ptrloc = gscore - 7 + halffactor;
	// 7 is determined by halfwidth of graphic rounded

if ( ptrloc < 0 ) {
	ptricon = "redpointerleft.gif"
	ptrloc = gscore;
	ptrwidth = 8;
} else {
	if ( (ptrloc + ptrwidth) > gwidth ) {
		ptricon = "redpointerright.gif";
		ptrwidth = 8;
		ptrloc = gscore - 8;
	}
}

var winCode = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">";

if (scalehead != "") {
	winCode += "<tr valign=\"top\"><td colspan=\"5\" align=\"center\" style=\"padding-bottom: 3px;\"><b>" + scalehead + "</b></td></tr>";
}

winCode += "<tr valign=\"bottom\"><td></td><td></td><td width=\"" + gwidth + "\" align=\"center\">";

winCode += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\"><tr valign=\"bottom\" align=\"center\">";

var pctally = 0;
var barTotalWidth = 0;
var bars = new Array();

for (var i=0; i<divLabel.length; i++) {
	var divWidth = divHigh[i] - divLow[i] + 1;
	var divPercent = (divWidth/gwidth)*100;
	divPercent = divPercent - (divPercent%1);
	if (i == (divLabel.length-1)) {
		bars[i] = gwidth - barTotalWidth;
		divPercent = 100 - pctally;
	} else {
		bars[i] = divWidth*dfactor;
		barTotalWidth = barTotalWidth + (bars[i]/1);
		pctally = pctally +  (divPercent/1);
	}
	winCode += "<td style=\"padding-bottom: 3px;\" class=\"smlabel\" width=\"" + bars[i] + "\">" + divLabel[i] + "</td>";
}

winCode += "</tr></table></td><td></td><td></td></tr>";

winCode += "<tr valign=\"top\"><td rowspan=\"2\" align=\"right\" valign=\"middle\" class=\"smlabel\">" + ll + "</td>";
winCode += "<td align=\"right\" rowspan=\"2\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"25\"></td>";
winCode += "<td nowrap align=\"center\">";

for (var i=0; i<divLabel.length; i++) {
	var divWidth = divHigh[i] - divLow[i];
	var divPercent = (divWidth/gwidth)*100;
	divPercent = divPercent - (divPercent%1);
	if (i == (divLabel.length-1)) {
		divPercent = 100 - pctally;
	} else {
		pctally += divPercent;
	}
	winCode += "<img src=\"" + imgSrc + colorBars[(i+1)%2] + "\" width=\"" + bars[i] + "\" height=\"10\">";
}

winCode += "</td>";
winCode += "<td rowspan=\"2\"><img src=\"" + imgSrc + "blackspacer.gif\" width=\"1\" height=\"25\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"4\" height=\"1\"></td>";
winCode += "<td rowspan=\"2\" valign=\"top\" class=\"smlabel\">" + lr + "</td></tr>";

winCode += "<tr valign=\"top\"><td nowrap valign=\"bottom\"><img src=\"" + imgSrc + "whitespacer.gif\" width=\"" + ptrloc + "\" height=\"1\"><img height=\"12\" src=\"" + imgSrc + ptricon + "\" width=\"" + ptrwidth + "\"></td></tr>";

winCode += "</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 GetFeedback() {
var winCode = "<h3 class=\"explanation\">Understanding Your Score on the Personal Need for Structure Scale</h3><p>Some people need to \"make sense\" of things around them more quickly or completely than do other people. This personal need for perceptual structure relates to selective attention as well as perceptual organization and interpretation. For instance, people with a strong personal need for closure might form first impressions, fill in missing pieces, and rely on stereotyping more quickly than people who don't mind incomplete perceptual situations.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The Personal Need for Structure (PNS) Scale estimates the extent to which people are motivated to structure their world in a simple and unambiguous way. Scores range from 12 to 72 with higher scores indicating a high personal need for structure, that is, a higher need to quickly and unambiguously make sense of the world.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PNS norms vary from one group to the next. For instance, a study of Finnish nurses reported a mean PNS score of 34 whereas a study of 236 male and 303 female undergraduate psychology students in the United States had a mean score of 42. This graph shows your score on the PNS scale compared with results from the U.S. sample of undergraduate psychology students.</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";

}
// ---------------------------------------
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; 2006 McGraw-Hill Ryerson Limited<br>&nbsp;</p></td></tr></table></body></html>";
return winCode
}



