top.name = "mainwin";var isNav, isIE;if (parseInt(navigator.appVersion) >= 4) {	if (navigator.appName == "Netscape") {		isNav = true;	} else {		isIE = true;	}}/*if (isNav) {	top.window.captureEvents (Event.RESIZE);	top.window.onresize = new Function ("top.location.reload();");}*/// WRITE_SUPP// This function writes the title and text in the supplemental frame// The caller can also specify any number of links to include at the bottom of the supp frame, along//   with javascript functions (defined in the caller's document) to associate with the functions.	function Write_Supp (title, text) {		parent.supp.document.open("text/html", "replace");		parent.supp.document.write ('<HEAD><STYLE TYPE="text/css"><!-- BODY, TD, LI {font-size: 14px; font-family: Verdana, Arial, sans-serif} A {font-weight:bold} A:link {color: #FFCC33; text-decoration:none} A:active {color: #FF6600; text-decoration:none} A:visited {color: #FFCC33; text-decoration:none} A:hover {color: #FF6600; text-decoration:underline} --><\/STYLE><\/HEAD>');		parent.supp.document.write ('<BODY BGCOLOR="#333333" TEXT="#FFFFFF" ALINK="#FFCC33" VLINK="#FFCC33" LINK="#FFCC33" margin="0px">');		// draw the title		if (title != '') {			parent.supp.document.write ('<B STYLE="font-family:Verdana, Arial, sans-serif">', title, '<\/B><P>');		}		// draw the main text		parent.supp.document.writeln (text);				// draw any links that go at the bottom of the supp frame		if (arguments.length > 2) {						parent.supp.document.write ('<UL>');			for (var i = 2; i < arguments.length; i += 2) {				if (arguments[i] == "intro")					parent.supp.document.write ('<LI><A href="Javascript:parent.main.Show_Intro()" onmouseover="return true;">Return to the activity introduction<\/A><\/LI>');				else					parent.supp.document.write ('<LI><A href="Javascript:parent.main.' + arguments[i+1] + '" onmouseover="return true;">' + arguments[i] + '<\/A><\/LI>');			}			parent.supp.document.write ('<\/UL>');		}					parent.supp.document.write ('<\/BODY>');		parent.supp.document.close ();	}// INSTRUCTIONS STUFFvar instString = ' Click on the ? icon at the top of the screen for more instructions.';// This function is called when the help button is clicked by the user.var iw;function Instructions_Window (bringToFront) {	if (typeof iw == "undefined" || iw.closed)		iw = window.open ('', "auxWindow", "width=600,height=500,scrollbars,resizable", true);	iw.document.open("text/html", "replace");		iw.document.write ('<html><HEAD><title>Instructions</title><STYLE TYPE="text/css"><!-- BODY {font-size: 14px; font-family: Verdana, sans-serif; margin:10px; background-color:#ffd940} TD {font-size: 14px; font-family: Verdana, sans-serif} A {font-weight:bold; text-decoration:none; color:#660000} A:hover {color: #000066; text-decoration:underline} --></STYLE><TITLE>Instructions</TITLE></HEAD>');	iw.document.write ('<BODY><div style="width:500px; padding:10px; background-color:#ffffff">');	iw.document.write ('<B>' + Title() + ': Instructions</B><P>');	iw.document.write (Instructions());	iw.document.write ('<P><A HREF="../common/tips.htm" onMouseOver="return true;">Click here for general tips about using this website.</A>');	iw.document.writeln ('</div></BODY></html>');	iw.document.close();	if (bringToFront)		iw.focus();}// Call this function if you want to update the instructions window, if it's open.  If the window// isn't open, nothing happens.  You can't update after banner.htm has been reloaded, because// the iw reference is lost at that point.function Update_Instructions () {	if (typeof iw == "undefined" || iw.closed)		return;	else		Instructions_Window (false);}function Close_Instructions () {	if (typeof iw == "undefined" || iw.closed)		return;	else		iw.close();}window.onunload = Close_Instructions;// HISTORY STUFFvar historyP = new Array();		// can't use "history" because it's already defined as a property of the windowvar histsize = 0;			// size of historyP array (may not be same as historyP.length)var histind = -1;			// current place in historyP array; will get bumped up to 0 the first time Add_To_History is calledvar ok_to_add_hist = true;	// set to false when back or forward pressed so page won't get added againvar isBack = false;			// determines whether back button changes color on rollovervar isForward = false;		// determines whether forward button changes color on rolloverfunction Add_To_History (h) {	if (!ok_to_add_hist) {				// if ok_to_add_hist is false, Add_To_History was called		ok_to_add_hist = true;			// just after the forward or back button was pressed,		return;							// so don't do anything	}		++histind;							// increment histind	historyP[histind] = h;				// store the function (h) in the historyP array	histsize = histind + 1;				// histsize always gets reset when a new page is added	if (histind > 0)		Enable_Back();					// enable the back button	Disable_Forward ();					// disable the forward button}function Go_Back () {	if (isBack) {		ok_to_add_hist = false;					// set ok_to_add_hist to false (see Add_To_History)		--histind;								// decrement histind		if (histind == 0)						// if we're about to call the first function			Disable_Back ()						// in the historyP array, disable the back button		Enable_Forward ();						// enable the forward button		eval ("top.main." + historyP[histind]);	// call the function in the historyP array	}}function Go_Forward () {	if (isForward) {		ok_to_add_hist = false;					// set ok_to_add_hist to false (see Add_To_History)		++histind;								// increment histind		if (histind == histsize - 1)			// if we're about to call the last function			Disable_Forward ();					// in the historyP array, disable the forward button		Enable_Back ();							// enable the back button		eval ("top.main." + historyP[histind]);	// call the function in the history array	}}function Enable_Back () {	if (bannerLoaded)		top.banner.document.getElementById('back').src = backEn.src;		// top.banner.document.back.src = backEn.src;	isBack = true;}function Disable_Back () {	if (bannerLoaded)		top.banner.document.getElementById('back').src = backDim.src;	isBack = false;}function Enable_Forward () {	if (bannerLoaded)		top.banner.document.getElementById('forward').src = forwardEn.src;	isForward = true;}function Disable_Forward () {	if (bannerLoaded)		top.banner.document.getElementById('forward').src = forwardDim.src;	isForward = false;}function Reset_History () {	histsize = 0;	histind = -1;	ok_to_add_hist = true;	Disable_Back ();	Disable_Forward ();}// Modified from quirksmode: find out if we're not using Safari or IEvar detect = navigator.userAgent.toLowerCase();function CheckBrowserString(string) {	var place = detect.indexOf(string) + 1;	return place;}var warningIssued = false;function IssueWarningIfNeeded() {	// Only issue warning once	if (warningIssued) {		return;	}		// no problem with safari	if (CheckBrowserString('safari')) {		return;	}		// no problem with IE	if (CheckBrowserString('msie')) {		return;	}		// no problem with firefox 1.5	var place;	if (place = CheckBrowserString('firefox')) {		var v = detect.substr(place + 7, 3) * 1;		if (v >= 1.5) {			return;		}	}		alert('A known bug in some browsers, including Firefox version 1.0, causes the back and forward page buttons, both in the Sensation and Perception window (the double-arrow buttons) and in the browser, to malfunction in some cases. The bug has been fixed in Firefox version 1.5, which is now available from getfirefox.com. Firefox users should navigate the site using the single-arrow buttons and the drop-down menu at the top of the window.');	warningIssued = true;}function Go_Back_Page() {	IssueWarningIfNeeded();	top.history.back();}function Go_Forward_Page() {	IssueWarningIfNeeded();	top.history.forward();}// BANNER AND PULL-DOWN MENU STUFFvar bannerLoaded = false;var backEn = new Image(); backEn.src = "../common/butBack.gif"; var backDim = new Image(); backDim.src = "../common/butBackDim.gif"; var forwardEn = new Image(); forwardEn.src = "../common/butForward.gif"; var forwardDim = new Image(); forwardDim.src = "../common/butForwardDim.gif"; var studyNames = new Array (//	"Chapter Organization",	"Chapter Summary",	"Key Terms",	"Study Questions");var studyURLs = new Array (//	"chaporganization",	"chapsummary",//	"namesdates",	"terms",	"questions");function MenuName(s) {	if (s.length <= 25) {		return s;	} else {		var newToTry = "";		var newS = "";		var words = s.split(" ");		for (var i = 0; i < words.length; ++i) {			if (newToTry != "") {				newToTry += " ";			}			newToTry += words[i];			if (newToTry.length > 25) {				break;			}			newS = newToTry;		}		return newS + "...";	}}// Note that the "menu.js" file for the given chapter must be included before this function is called.function Write_Banner () {	top.banner.document.open("text/html", "replace");	top.banner.document.write ('<HEAD></HEAD><BODY BGCOLOR="#111111" style="margin:0px">');	top.banner.document.write ('<FORM NAME="exerciseForm" style="margin:0"><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" style="width:100%; padding-left:12px"><TR><TD>');	top.banner.document.write ('<A HREF="../home/startF.htm" TARGET="_top"><IMG SRC="../common/perception.gif" WIDTH="220" HEIGHT="33" ALIGN="top" BORDER="0" id="home" title="Return to Perception Home"></A>');	top.banner.document.write ('</TD>');		top.banner.document.write('<td width="40%" style="text-align:center; padding-left:5px; padding-right:5px">');	top.banner.document.write('<select name="chapterSelect" onchange="top.main.JumpToChapter()">');	top.banner.document.write('<option value="-1" selected>Jump to chapter</option>');	top.banner.document.write('<option value="-1">--------------</option>');	top.banner.document.write ("<OPTION value='0'>S & P Home</OPTION>");	top.banner.document.write('<option value="1">1. Introduction</option>');	top.banner.document.write('<option value="2">2. Early Vision</option>');	top.banner.document.write('<option value="3">3. Spatial Vision</option>');	top.banner.document.write('<option value="4">4. Objects</option>');	top.banner.document.write('<option value="5">5. Color</option>');	top.banner.document.write('<option value="6">6. Space</option>');	top.banner.document.write('<option value="7">7. Motion</option>');	top.banner.document.write('<option value="8">8. Attention/Scene</option>');	top.banner.document.write('<option value="9">9. Hearing</option>');	top.banner.document.write('<option value="10">10. Hearing II</option>');	top.banner.document.write('<option value="11">11. Music/Speech</option>');	top.banner.document.write('<option value="12">12. Touch</option>');	top.banner.document.write('<option value="13">13. Olfaction</option>');	top.banner.document.write('<option value="14">14. Taste</option>');	top.banner.document.write('<option value="15">15. Vestibular System</option>');	top.banner.document.write('</select>');	top.banner.document.write('</td>');		if (typeof chapNum != "undefined") {		top.banner.document.write ('<TD width="40%" style="text-align:center; padding-left:0px; padding-right:5px">');		top.banner.document.write ('<SELECT NAME="exerciseSelect" onchange="top.main.Goto_Exercise();">');		top.banner.document.write ("<OPTION SELECTED>Chapter " + chapNum + " Contents</OPTION>");		top.banner.document.write ('<option value="-1">-------------------</option>');		top.banner.document.write ("<OPTION>Chapter Overview</OPTION>");		top.banner.document.write ("<OPTION>-- ACTIVITIES</OPTION>");		for (var i = 0; i < exerNames.length; ++i)			top.banner.document.write ("<OPTION>" + chapNum + "." + (i+1) + " " + MenuName(exerNames[i]) + "</OPTION>");		top.banner.document.write ("<OPTION>-- ESSAYS</OPTION>");		for (var i = 0; i < surfNames.length; ++i)		{						if (surfURLs[i] == "" )			{				top.banner.document.write ("<OPTION>" + MenuName(surfNames[i]) + "</OPTION>");			}			else			{				top.banner.document.write ("<OPTION>" + chapNum + "." + (i+1) + " " + MenuName(surfNames[i]) + "</OPTION>");			}		}		top.banner.document.write ("<OPTION>-- STUDY AIDS</OPTION>");		for (var i = 0; i < studyNames.length; ++i)			top.banner.document.write ("<OPTION>" + studyNames[i] + "</OPTION>");		top.banner.document.write ('</SELECT></TD>');	}	top.banner.document.write('<td align="right" style="padding-right:10px"><nobr>');	top.banner.document.write ('<A href="Javascript:top.main.Go_Back_Page()" TARGET="_top"><IMG SRC="../common/butBackpage.gif" WIDTH="36" HEIGHT="33" align=top BORDER=0 id="backpage" title="Back"></A>');	top.banner.document.write ('<A href="Javascript:top.main.Go_Back()" TARGET="_top"><IMG SRC="../common/butBackDim.gif" WIDTH="32" HEIGHT="33" align=top BORDER=0 id="back" title="Go back to the previous page of gray text"></A>');	top.banner.document.write ('<A href="Javascript:top.main.Go_Forward()" TARGET="_top"><IMG SRC="../common/butForwardDim.gif" WIDTH="32" HEIGHT="33" align=top BORDER=0 id="forward" title="Go forward to the next page of gray text"></A>');	top.banner.document.write ('<A href="Javascript:top.history.forward()" TARGET="_top"><IMG SRC="../common/butForwardpage.gif" WIDTH="36" HEIGHT="33" align=top BORDER=0 id="forwardpage" title="Forward"></A>');	top.banner.document.write ('<A href="Javascript:top.main.Instructions_Window(true)"><IMG SRC="../common/butHelp.gif" WIDTH="34" HEIGHT="33" align=top BORDER=0 id="help" title="Show the instructions for this page"></A>');	top.banner.document.write('</nobr></td>');		top.banner.document.write ('</TR></TABLE></FORM>');	top.banner.document.write ('</BODY>');	top.banner.document.close ();	bannerLoaded = true;}var demoVersion;if (location.hostname.indexOf('sinauer') != -1) {	demoVersion = true;} else {	demoVersion = false;}demoVersion = false;function JumpToChapter(c) {	if (c == null) {		// then we're coming from the form above; otherwise c is passed		var c = top.banner.document.exerciseForm.chapterSelect.selectedIndex;		c = c - 2;	}		top.banner.document.exerciseForm.chapterSelect.options[0].selected = true;	if (demoVersion == true && c > 10) {		alert('The content for Chapter ' + c + ' is not yet available. Chapters 1-10 are available at this time. The remaining chapters will be available by January 15, 2006.');	} else if (c == 0) {		top.location = "../home/startF.htm";	} else {		top.location = "../chap" + c + "/startF.htm";	}}function Goto_Exercise () {	var selected = top.banner.document.exerciseForm.exerciseSelect.selectedIndex;	top.banner.document.exerciseForm.exerciseSelect.options[0].selected = true;	if (selected == 2) {		top.location = "../chap" + chapNum + "/startF.htm";		return;	}		selected = selected - 4;	if (selected >= 0 && selected < exerURLs.length) {		if (exerURLs[selected] == "")			top.location = "../common/underconstF.htm";		else			top.location = "../chap" + chapNum + "/" + exerURLs[selected] + "F.htm";		return;	}		selected = selected - exerURLs.length - 1;	if (selected >= 0 && selected < surfURLs.length) {		if (surfURLs[selected] == "")			//top.location = "../common/underconstF.htm"; dsfad			return;		else			top.location = "../chap" + chapNum + "/" + surfURLs[selected] + "F.htm";		return;	}	selected = selected - surfURLs.length - 1;	if (selected >= 0 && selected < studyURLs.length) {		if (!studyComplete)			top.location = "../common/underconstF.htm";		else			top.location = "../chap" + chapNum + "/" + studyURLs[selected] + "F.htm";		return;	}		selected = selected - studyURLs.length - 1;	if (selected == 0) {		top.location = "../home/startF.htm";		return;	}	return;}function Expand() {	window.open (location.href.replace(/.htm/, "BigF.htm"), "Expanded Page", "top=5,left=5,scrollbars,resizable,menubar", true);}// UTILITY FUNCTIONS// Return random integer >= 0 and < uplimfunction Rand_Int (uplim) {	return Math.floor (Math.random() * uplim);}// Note that in the following functions, you just specify the name of the div.// This is unlike in the eBook API, where we have to pass in the actual element.// Set display of layer l (d should be "block" or "none"; if "toggle" we toggle)function Layer_Display (l, d) {	var els = document.getElementById(l);	if (els == null) {		//alert("Couldn't get div " + l);		return null;	}		els = els.style;	if (d == "toggle" || d == null) {		if (els.display == "block") {			d = "none";		} else {			d = "block";		}	}	els.display = d; 	return d;}// Set visibility of layer l (v should be "hidden" or "visible")function Layer_Vis (l, v) { 	var els = document.getElementById(l);	if (els == null) {		//alert("Couldn't get div " + l);		return null;	}		els = els.style;	if (v == "toggle" || v == null) {		if (els.visibility == "visible") {			v = "hidden";		} else {			v = "visible";		}	}	els.visibility = v; 	return v;}// Return the current position (style.left/top) of layer lfunction Layer_Position(l, dim) {	if (dim == "x")		return parseInt(document.getElementById(l).style.left);	else		return parseInt(document.getElementById(l).style.top);}// Move layer l to position x, y.  If y is not specified, only move horizontallyfunction Layer_Move_To (l, x, y) {	document.getElementById(l).style.left = x + "px";	if (arguments.length > 2)		document.getElementById(l).style.top = y + "px";}// Move layer l by dx/dy pixels (can be negative or positive values). If y not specified, move horizontally onlyfunction Layer_Move (l, dx, dy) {	var layer = document.getElementById(l);	layer.style.left = (parseInt(layer.style.left) + dx) + "px";	if (arguments.length > 2)		layer.style.top = (parseInt(layer.style.top) + dy) + "px";}// Return the number value of something like "50px"function RemovePx(s) {	var pxPos = s.indexOf("px");	if (pxPos != -1) {		s = s.substring(0, pxPos);	}	return s * 1;}// Stop the event e from bubbling up to higher layers of the DOM// see http://www.quirksmode.org/index.html?/js/events_compinfo.htmlfunction Stop_Event(e) {	e.cancelBubble = true;		// IE	if (e.stopPropagation) 		// everyone else		e.stopPropagation();		// In NS, we (also?) have to return false to cancel the default action from occurring.	// Stop_Event returns false so that the caller can say "return Stop_Event(e);"	// to cover all eventualities.	return false;}var soundPlayerFrame = top.main;var soundLoaded = new Object();		// Not used right now (see below)function PlaySound(layerId, soundSrc, loop) {/*	In theory, we should be able to use the following code to only load the sound once,	then just use the Stop() command in StopSound.	But, it doesn't seem to work in Firefox -- the sound loads and plays, but won't stop.	Also, doing it without keeping it in the document ensures that the sound starts over	every time it's played.		if (soundLoaded[soundSrc] == true) {		soundPlayerFrame.document[layerId + "embed"].Play();		return;	}	soundLoaded[soundSrc] = true;*/	if (loop == null || loop == "false" || loop == false) {		loop = "false";	} else {		loop = "true";	}		soundPlayerFrame.document.getElementById(layerId).innerHTML = "<OBJECT id='" + layerId + "embed' CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='320' height='260' CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='" + soundSrc + "'><param name='controller' value='true'><param name='autoplay' value='true'><param name='loop' value='" + loop + "'><param name='cache' value='true'><EMBED name='" + layerId + "embed' EnableJavaScript='true' cache='true' src='" + soundSrc + "' WIDTH=320 HEIGHT=260 AUTOPLAY=true CONTROLLER=true loop=" + loop + " PLUGINSPAGE='http://www.apple.com/quicktime/download/'></EMBED></OBJECT>";}function StopSound(layerId) {	if (soundPlayerFrame.document[layerId + "embed"] != null) {		//soundPlayerFrame.document[layerId + "embed"].Stop();		soundPlayerFrame.document.getElementById(layerId).innerHTML = "";	}}function PreloadSounds() {		var f = top.soundFrame.document;	f.open();	f.writeln("<body>");	for (var i = 0; i < arguments.length; ++i) {	// write code for each argument here, using f.writeln, perhaps:	f.writeln("<OBJECT CLASSID='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='320' height='260' CODEBASE='http://www.apple.com/qtactivex/qtplugin.cab'><param name='src' value='" + arguments[i] + "'><param name='controller' value='false'><param name='autoplay' value='false'><EMBED src='" + arguments[i] + "'WIDTH=320 HEIGHT=260 AUTOPLAY=false CONTROLLER=false PLUGINSPAGE='http://www.apple.com/quicktime/download/'></EMBED></OBJECT>");	}	f.writeln("</body>");}
