/*(c) 2001-2007 Kinetic Books Company */
if(document.cookie!=""){
	myCookie = "";
	myCookie = document.cookie;
	the_info = new Array();
	// load the cookie into a variable and unescape it
	var the_cookie = document.cookie;
	var the_cookie = unescape(the_cookie);

	var separated_values = (the_cookie.indexOf(';')!=-1)?the_cookie.split("; "):new Array(the_cookie);
	// loop through the list of name:values and load
	// up the associate array
	var property_value = "";
	for (var loop = 0; loop < separated_values.length; loop++){
		if(separated_values[loop]!=""){
			property_value = separated_values[loop];
			var broken_info = new Array(property_value.substring(0,property_value.indexOf("=")),property_value.substr(property_value.indexOf("=")+1));
			var the_property = broken_info[0];
			if(typeof(broken_info[1])=='undefined') continue;
			var the_value = broken_info[1];
			the_info[the_property] = the_value;
			}
		}
	fs = (the_info['fs']&& !isNaN(parseFloat(the_info['fs'])))?parseFloat(the_info['fs']):3;
	nr = (the_info['nr'])?parseFloat(the_info['nr']):0;
	}
else{
	nr = 0;
	fs = 3;
	}
var kbprefs = new Array();
ipclk = -1;
hlrange = new Array();
hlrange2 = new Array();
agt=navigator.userAgent.toLowerCase();
SF = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
SFV = (SF)?parseFloat(agt.substring(agt.indexOf("applewebkit/")+12,agt.indexOf("applewebkit/")+15)):0;
FF = (agt.indexOf('gecko')!=-1 && !SF);

hostName = location.hostname;
localHostTest = (location.hostname=="localhost"||location.hostname=="127.0.0.1");
document.write("<scr"+"ipt language=\"javascript\" src=\"../../scripts/highlight.js\"></sc"+"ript><sc"+"ript language=\"javascript\" src=\"../../scripts/notes.js\"></s"+"crip"+"t>");
if(localHostTest){
rander = Math.random();
document.write("<scr"+"ipt language=\"javascript\" src=\"../../cgi-bin/prefs.js?rand="+rander+"\"></scr"+"ipt><scr"+"ipt language=\"javascript\" src=\"../../cgi-bin/highlight.js?rand="+rander+"\"></sc"+"ript><sc"+"ript language=\"javascript\" src=\"../../cgi-bin/notes.js?rand="+rander+"\"></s"+"crip"+"t>");
}
txt = new Array(18,16,14,12,10,9);

var textsize = txt[fs];
document.write("<style type=\"text/css\">li, .SectionBody,.TableBody,.SectionList, .Vars,.InteractiveListItem,.Title,.EquationText,P{font-size:"+(textsize)+"px;}.Math,.MathTable,.eqMath{font-size:"+(textsize+3)+"px;}</style>");

function uninit(){
	closeIPs();
	if(typeof(notewin)!='undefined'&&!notewin.closed) notewin.close();
	xmlhttp = "";
	}
function init(){
	startX = null;
	startY = null;
	chk = 0;

 	uselessvar = 0;
	window.focus();
	loadbuttons();
	if(typeof(qlength)!='undefined'){
		Init();
		}
	}

function safaricrap2(hla,i){
	if(hlload >= (i-1)){
		try{
		hlite[i] = hla.split(",");
		var pStart = document.getElementById("p"+hlite[i][0]);
		var pEnd = document.getElementById("p"+hlite[i][3]);
		var nStart = pStart.childNodes[hlite[i][1]];
		var nEnd = pEnd.childNodes[hlite[i][4]];
		highlightFF(pStart,nStart,parseFloat(hlite[i][2]),pEnd,nEnd,parseFloat(hlite[i][5]),i,50);
		clearInterval(hli[i]);
		}catch(e){
			clearInterval(hli[i]);
			}
		}
	}

function getSectionNavString(str){
	var nsa = '<object data="../../media/navbutton.swf" type="application/x-shockwave-flash" ';
	nsa += 'flashvars="'+str+'" width="25" height="25" bgcolor="#000000"><param name="allowScriptAccess" value="sameDomain"/>';
	nsa += '<param name="movie" value="../../media/navbutton.swf"/><param name="quality" value="high"/>';
	nsa += '<param name="FlashVars" value="'+str+'"/><param name="bgcolor" value="#000000"/></object>';
	return nsa;
}


function switcheroo(){
	firsttime = false;

	tds = document.getElementsByTagName("TD");
	for(var nm = 0; nm < tds.length; nm++){
		if(tds[nm].className=="SectionTableCol1"||tds[nm].className=="ExampleTableCol1"||tds[nm].className=="DerivationCol"){
			elm = tds[nm].firstChild;
			cango = true;
			for(var m = 0; m < tds[nm].childNodes.length; m++){
				elm = tds[nm].childNodes[m];
				if(elm.nodeType == 1){
					if(elm.nodeName.toLowerCase()=='script'||elm.nodeName.toLowerCase()=='object'){
						elm = elm.nextSibling;
						continue;
						}
					if(elm.nodeName.toLowerCase()=='table'){
						if(elm.className=='DerivationTable') var tp = elm.getElementsByTagName('td');
						else var tp = elm.getElementsByTagName('p');
						for(var td = 0; td < tp.length; td++){

							var nbdo = document.createElement("bdo");
							nbdo.dir = "rtl";
							tp[td].dir="rtl";
							nbdo.innerHTML = tp[td].innerHTML;
							tp[td].innerHTML = ""
							tp[td].appendChild(nbdo);
							}
						elm = elm.nextSibling;
						continue;
						}
					if(elm.nodeName.toLowerCase() != "p"){

						while(!elm.tagName||(elm.tagName.toLowerCase()!='li')){
							if(elm.nodeType==3) elm = elm.nextSibling;
							else elm = elm.firstChild;
							}
						while(elm){
							if(elm.nodeType==3){
								elm = elm.nextSibling;
								continue;}
							var nbdo = document.createElement("bdo");
							nbdo.dir = "rtl";
							elm.dir="rtl";
							nbdo.innerHTML = elm.innerHTML;
							elm.innerHTML = ""
							elm.appendChild(nbdo);
							elm = elm.nextSibling;

							}
						continue;
						}
					var nbdo = document.createElement("bdo");
					nbdo.dir = "rtl";
					elm.dir="rtl";
					nbdo.innerHTML = elm.innerHTML;
					elm.innerHTML = ""
					elm.appendChild(nbdo);
					}
				}
			}
		}
	}
function removebdo(){
	elm = document.getElementsByTagName("bdo")[0];
	while(elm){
		for(var i = 0; i < elm.childNodes.length ; i++){
			var copynode = elm.childNodes[i].cloneNode(true)
			elm.parentNode.appendChild(copynode);
			}
		elm.parentNode.dir = "ltr";
		elm.parentNode.removeChild(elm);
		elm = document.getElementsByTagName("bdo")[0];
		}
	}
function fontsize(e){
	if(typeof(fs)=='undefined')fs = 3;
	uselessvar ++ ;
	if(!e) e = window.event;
	var tg = (e.target) ? e.target : e.srcElement
	num = (tg.id.indexOf("fup")!=-1)?-1:1;
	if((fs + num)>txt.length-1 && uselessvar > 15){
	//	switcheroo();
		}

	if((fs + num) > txt.length-1  || (fs + num)<0){
		return;
		}
	var docheight = document.body.scrollHeight;
	fs += num;
	textsize = txt[fs];
	tds = document.getElementsByTagName("TD");
	for(var nm = 0; nm < tds.length; nm++){
		if(tds[nm].className=="SectionTableCol1"||tds[nm].className=="ExampleTableCol1"||tds[nm].className=="DerivationCol"){
			for(var ch = 0; ch<tds[nm].getElementsByTagName("P").length;ch++){
				elm = tds[nm].getElementsByTagName("P")[ch];
				elm.style.fontSize = textsize+"px";
				if(elm.className=="DefinitionBody") elm.style.fontSize = (textsize*2)+"px";
				}
			for(var ch = 0; ch<tds[nm].getElementsByTagName("SPAN").length;ch++){
				elm = tds[nm].getElementsByTagName("SPAN")[ch];
				if(elm.className.toLowerCase().indexOf("math")!=-1){
					elm.style.fontSize = (textsize+3)+"px";
					}
				if(elm.className=="DefinitionTag") elm.style.fontSize = (textsize*2)+"px";
				}
			for(var ch = 0; ch<tds[nm].getElementsByTagName("DIV").length;ch++){
				elm = tds[nm].getElementsByTagName("DIV")[ch];
				elm.style.fontSize = textsize+"px";
				}
			for(var ch = 0; ch<tds[nm].getElementsByTagName("LI").length;ch++){
				elm = tds[nm].getElementsByTagName("LI")[ch];
				elm.style.fontSize = textsize+"px";
				}
			var newdocheight = document.body.scrollHeight;
			if(newdocheight > docheight){
				window.scrollBy(0,(newdocheight-docheight));
				}
			}
		}
	if(document.getElementById("notes")) document.getElementById("notes").style.fontSize =textsize+"px";
	uselessvar = 0;
	setcookie();
	}
function loadbuttons(){

	hlbtn_on = new Array();
	hlbtn_on[1] = new Image();
	hlbtn_on[1].src = "../../media/prefs/footer_hilite1.gif";
	hlbtn_on[2] = new Image();
	hlbtn_on[2].src = "../../media/prefs/footer_hilite1b.gif";
	hlbtn_on[3] = new Image();
	hlbtn_on[3].src = "../../media/prefs/footer_hilite1c.gif";

	hlbtn_off = new Array();
	hlbtn_off[1] = new Image();
	hlbtn_off[1].src = "../../media/prefs/footer_hilite2.gif";
	hlbtn_off[2] = new Image();
	hlbtn_off[2].src = "../../media/prefs/footer_hilite2b.gif";
	hlbtn_off[3] = new Image();
	hlbtn_off[3].src = "../../media/prefs/footer_hilite2c.gif";

	hlbtn_clear = new Array();
	hlbtn_clear[1] = new Image();
	hlbtn_clear[1].src = "../../media/prefs/footer_clear1.gif";
	hlbtn_clear[2] = new Image();
	hlbtn_clear[2].src = "../../media/prefs/footer_clear2.gif";
	hlbtn_clear[3] = new Image();
	hlbtn_clear[3].src = "../../media/prefs/footer_clear3.gif";

	txtsz_sm = new Array()
	txtsz_sm[1] = new Image();
	txtsz_sm[1].src = "../../media/prefs/footer_small.gif";
	txtsz_sm[2] = new Image();
	txtsz_sm[2].src = "../../media/prefs/footer_small2.gif";
	txtsz_sm[3] = new Image();
	txtsz_sm[3].src = "../../media/prefs/footer_small3.gif";

	txtsz_lg = new Array()
	txtsz_lg[1] = new Image();
	txtsz_lg[1].src = "../../media/prefs/footer_large.gif";
	txtsz_lg[2] = new Image();
	txtsz_lg[2].src = "../../media/prefs/footer_large2.gif";
	txtsz_lg[3] = new Image();
	txtsz_lg[3].src = "../../media/prefs/footer_large3.gif";

	add_note = new Array();
	add_note[1] = new Image();
	add_note[1].src = "../../media/prefs/footer_note1.gif";
	add_note[2] = new Image();
	add_note[2].src = "../../media/prefs/footer_note2.gif";
	add_note[3] = new Image();
	add_note[3].src = "../../media/prefs/footer_note3.gif";

	issuesbtn = new Array();
	issuesbtn[1] = new Image();
	issuesbtn[1].src = "../../media/prefs/footer_issues1.gif";
	issuesbtn[2] = new Image();
	issuesbtn[2].src = "../../media/prefs/footer_issues2.gif";

	prefbtn = new Array();
	prefbtn[1] = new Image();
	prefbtn[1].src = "../../media/prefs/footer_pref1.gif";
	prefbtn[2] = new Image();
	prefbtn[2].src = "../../media/prefs/footer_pref2.gif";


	document.getElementById("fup").onclick = fontsize;
	document.getElementById("fup").onmouseover = function(){document.getElementById("fup").src=txtsz_lg[2].src;}
	document.getElementById("fup").onmouseout = function(){document.getElementById("fup").src=txtsz_lg[1].src;}
	document.getElementById("fdown").onclick = fontsize;
	document.getElementById("fdown").onmouseover = function(){document.getElementById("fdown").src=txtsz_sm[2].src;}
	document.getElementById("fdown").onmouseout = function(){document.getElementById("fdown").src=txtsz_sm[1].src;}


		document.getElementById("hon").previousSibling.src = "../../media/prefs/footer_highlight3.gif";
		document.getElementById("hon").src = hlbtn_off[3].src;
		document.getElementById("hoff").src = hlbtn_clear[3].src;
		document.getElementById("hon").previousSibling.onclick = disabled;
		document.getElementById("hoff").onclick = disabled;
		document.getElementById("hon").onclick = disabled;
		document.getElementById("note").src=add_note[3].src;
		document.getElementById("note").onclick = disabledn;

//	document.getElementById("prefsbtn").onmouseover= function(){document.getElementById("prefsbtn").src=prefbtn[2].src;};
//	document.getElementById("prefsbtn").onmouseout= function(){document.getElementById("prefsbtn").src=prefbtn[1].src;};
	document.getElementById("prefsbtn").onclick = disabledn;
	document.getElementById("prefsbtn").className = "Footer Hand";


	document.getElementById("issues").onmouseover = function(){document.getElementById("issues").src=issuesbtn[2].src;};
	document.getElementById("issues").onmouseout = function(){document.getElementById("issues").src=issuesbtn[1].src;};
	}

www = (document.location.toString().indexOf("http")==0&&!localHostTest)?true:false;
Mac = navigator.platform.indexOf("Mac") != -1;
IE = navigator.appName.indexOf("Microsoft") != -1;

card = 1;
if(typeof(starter)=='undefined'){starter = 0;}
theCard = new Array();
cardImage = new Array();
breaker = 0;

show = true;
imgs = /whiteboards\/equations\/image(\d+)w.gif/g;
temp3 = new Array();
temp4 = new Array();
addNum = ["concept","equation","example"];
addNum["concept"] = 1;
addNum["equation"] = 1;
addNum["example"] = 1;


if(Mac){ document.write("<LINK type=\"text/css\" href=\"../../css/chapter-mac.css\"/>");}

function replaceHeadlines(int1, int2){
	matcher = 0;
	var breaker = false;
	temp1 = headline[int1].split("</div>");
	temp2 = headline[int2].split("</div>");
	tempheadline = headline[int1];
	for(i = temp1.length - 2;i>=0;i--){
		//go from the longer of the two headlines backwards
		if(temp1.length > temp2.length){
			//if the lower card really has more lines, check the lines for matches
			if(temp2[i]!=null && temp1[i].indexOf("wbmainequation")==-1){
				temp3[i] = temp1[i].replace(imgs,"xx");
				temp4[i] = temp2[i].replace(imgs,"xx");
				//replace the image sources into dummy strings

				if(temp4[i].length!=0&&temp3[i] == temp4[i]){
					matcher++;
					tempheadline = tempheadline.replace(temp1[i]+"</div>","");
					//replaces matched line in the temporary headline
					}
				else if(temp4[i].length<=1){
					//the split creates a few empty spaces in the array at the end, so do nothing in this case.
					}
				else{
					//lines don't match, error out.
					breaker = true;
					break;
					}
				}
			}
		}

	if(!breaker && matcher == temp2.length - 1) headline[int1] = tempheadline

	}
function NewWhiteboard(type){
	aNewWhiteboard(type)
	}
function checkres(ht){
	scrht = self.screen.availHeight;
	return (scrht <= ht && (FF||SF));
	}
function popRes(){
	wide = 760;
	var vert = (screen.height - 300) / 2;
	var horiz = (screen.width - 760) / 2;
	var extras = 'height=300,width='+wide+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no';
	var wblocation = (FF)?'../../scripts/resolution.html':'../../scripts/resolutionmac.html';
	var name = 'reswindow';
	rwin = window.open(wblocation, name, extras)
	if (parseInt(navigator.appVersion) >= 4) { rwin.focus(); }
	}
function aNewWhiteboard(type){
if(typeof(nr)=='undefined') nr = false;
	if(checkres(600)){
		popRes();
		return;
		}
	wide = (!nr)?560:780;
	var vert = (screen.height - 550) / 2;
	var horiz = (screen.width - 780) / 2;
	var extras = 'height=550,width='+wide+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no'+(IE&&navigator.appMinorVersion==';SP2;'&&screen.availHeight<600?',fullscreen=yes':'');

	var wblocation = 'whiteboards/index.htm';
	 if(type != 1){
			wblocation = wblocation +'?' + type;
			}
	var name = 'whiteboard';
  if (window.open) {
  	wbwin = window.open(wblocation, name, extras)
		if (parseInt(navigator.appVersion) >= 4) wbwin.focus();
		}
	}

function openpa(flv){
	wide = 700;
	tall = 540;
	var vert = (screen.height - tall) / 2;
	var horiz = (screen.width - wide) / 2;
	var extras = 'height='+tall+',width='+wide+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes';

	var paloc = "../../media/uw/widget.html"+((!flv)?"":"?"+flv);
	var name = "PhysicsFactbook";

	win = window.open(paloc, name, extras)
	if (parseInt(navigator.appVersion) >= 4) { win.focus(); }
	}

function nWin(pg,wid,hit){

	var vert = (screen.height - hit) / 2;
	var horiz = (screen.width - wid) / 2;
	var extras = 'height='+hit+',width='+wid+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no';
	 win = window.open(pg, 'newwin', extras);
	 if (parseInt(navigator.appVersion) >= 4) { win.focus(); }
	}
function buildSwfFile(){

	//creates the slide classes and colors arrays once per document.
	if(cardSlide != ""){
		for (i = 0; i <= cardSlide.length; i++){
		cardSlide.sort(function(a,b){return a-b;})
			if((cardSlide[i-1]!= null && cardSlide[i] == cardSlide[i-1])){
				cardSlide[i] = "9999";
				}
			if(typeof(skipCard) != 'undefined' && cardSlide[i] == skipCard[0]){
				headline[cardSlide[i] -1] = headline[cardSlide[i] -2];
				cardSlide[i] = "9999";
				}
			}
		cardSlide.sort(function(a,b){return a-b;});
		for (i = 0; i <= cardSlide.length; i++){
			if(cardSlide[i]=="9999"){
				cardSlide.pop();
				}
			}
		classSlide = new Array();
		color = new Array()

		liteColor = new Array();
		color["concept"]="#669933";
		liteColor["concept"] = "#CCFF99"
		color["equation"] = "#FF6600";
		liteColor["equation"] = "#FFFF99"
		color["example"] = "#006699";
		liteColor["example"] = "#CCFFFF"
		for (j = 0; j<=subtitle.length; j++){
			for (h = 0; h<question.length;h++){
				for (i = 0; i < cardSlide.length; i++){
					if (cardSlide[i] >= conceptSlideArray[j] && conceptSlide != 0){
							classSlide[i] = "concept";
							}
						if (cardSlide[i] >= equationSlideArray[j] && equationSlide != 0){
							classSlide[i] = "equation";
							}
						if (cardSlide[i] >= exampleSlideArray[j] && exampleSlide != 0 || questionslide[h] == cardSlide[i] && exampleSlide != 0){
							classSlide[i] = "example";
						}
					}
				}
			}
		swfFile = new Array();
		for(i=0;i<cardSlide.length;i++){
			swfnm = "crd_0"+(i+1)+".swf";
			swfFile[i] = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" id=\"crd"+(i+1)+"\" width=\"290\" height=\"160\">";
			swfFile[i]+=" <param name=\"quality\" value=\"high\">";
			swfFile[i]+="<param name=\"movie\" value=\"media/";
			swfFile[i]+= swfnm;
			swfFile[i]+="\">";
			swfFile[i]+="<embed src=\"media/"
			swfFile[i]+= swfnm;
			swfFile[i]+="\" quality=\"high\" width=\"290\" height=\"160\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" name=\"crd"+(i+1)+"\">";
			swfFile[i]+="</embed>";
			swfFile[i]+="</object>";
			if(typeof(cardSwf)!='undefined'){
				if(cardSwf[i] == false)	swfFile[i] = "";
				}
			}
		}
	}

var stubsearchstr = "Please enter a search term";
function sFunc(){

 var frm = document.forms[document.forms.length-1];
 var sBox = frm.elements[0];
 if(sBox.value!="" && sBox.value != stubsearchstr ){
  frm.method = "get";
   frm.action= "../../search/search.html";
  }
 else{
  sBox.value= stubsearchstr;
  frm.action = "javascript:nothing();";
  }
 }

function clearstr(obj){
	if(obj.value==stubsearchstr) obj.value="";
	}

function wrapLink(str,wbInt,clsStr){

	//return "<a href='javascript:aNewWhiteboard("+wbInt+")' class='"+clsStr+"'>"+str+"</a>";
	if(typeof(subtitleslide)!='undefined'&&wbInt == 1 && subtitleslide[0]==1 && clsStr=='cardHeader'){str=subtitle[0]}
	var clk = /click=wb(\d{0,})/g;
	var tds = /<td/g;
	if(clk.test(str)){str = str.replace(clk,'click=wb'+wbInt);}
	if(tds.test(str)){str = str.replace(tds,'<td class="subhead"');}
	return "<span class='"+clsStr+"'>"+str+"</span>";
	}

function writeImageCol(){
	image = "";
	if(typeof(topCardName)!='undefined'&&topCardType==7){
		if(typeof(topCardHeight) == 'undefined') topCardHeight=370;
		image+="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" id=\"crd0\" width=\"290\" height=\"370\">";
		image+=" <param name=\"quality\" value=\"high\">";
		image+="<param name=\"movie\" value=\"media/";
		image+=topCardName;
		image+="\">";
		image+="<embed src=\"media/"
		image+=topCardName;
		image+="\" quality=\"high\" width=\"290\" height=\""+topCardHeight+"\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" name=\"crd0\">";
		image+="</embed>";
		image+="</object>";
		image+="<p></p>";
		}
	buildSwfFile();
	if(starter == 1 && addNum[classSlide[0]]==1) 	addNum[classSlide[0]] ++;
	for(i=starter; i<cardSlide.length; i++){
		if(typeof(cardBreakAfter) != 'undefined'&& cardBreakAfter[0] != 0 && typeof(cardBreakAfter[0]) != 'undefined'){
			if(typeof(cardBreakAfter[breaker]) !='undefined' && cardSlide[i] > cardBreakAfter[breaker]){
				breaker ++;
				starter = i;
				break;
				}
			else if(typeof(cardBreakAfter[breaker]) == 'undefined' || cardBreakAfter[breaker] >= cardSlide[cardSlide.length-1]){
				starter = 99999;
				}

			}
		else if(typeof(cardBreakAfter) != 'undefined'&& typeof(cardBreakAfter[0]) == 'undefined'){
			starter = 99999;
			}
		// hi should equal the next card slide value - 1, then adjust to 0 based so -1 again.
		// Or lastSlide -1 for 0 based.
			var hi = (i==cardSlide.length-1)?lastSlide-1:cardSlide[i+1]-1-1;

		crdTitle="";
		if(i==0) crdTitle = (wbtitle)?wbtitle:"";
		if(cardSlide[i] != "9999" ){
			if(subtitleslide){
				for(j=0;j<subtitleslide.length;j++){
					if(cardSlide[i]==subtitleslide[j]){
						crdTitle = subtitle[j];
						}
					}
				}
			if(questionslide){
				for(k=0;k<questionslide.length;k++){
					if(cardSlide[i] == questionslide[k]){
						crdTitle = question[k];
						}
					}
				}

			var hline;
			if (typeof(headline)!='undefined') {
				hline = (headline[hi])?headline[hi]:"";
				}
			else hline = "temp text until wb's are exported again.";
			if (crdTitle != "" || !(hline =="" || hline == "&nbsp;")){
				image +='<table border="0" cellspacing="0" cellpadding="0" width="290" onClick="window.location=\'javascript:aNewWhiteboard('+cardSlide[i]+')\'">\n';
				image +='<tr>\n';
				image +='<td colspan="3"><img src="../../media/chapters/'+classSlide[i].substring(0,2);
				if(classSlide[i+1] && classSlide[i] == classSlide[i+1]){
					image+=""+addNum[classSlide[i]];
					}
				else if (classSlide[i-1] != classSlide[i]){image+=""+addNum[classSlide[i]]}
				else if(classSlide[i-1] && classSlide[i] == classSlide[i-1]){
					image+=""+addNum[classSlide[i]];
					}
				addNum[classSlide[i]]++
				image +='.gif" alt="'+classSlide[i]+'" width="290" height="23" vspace="0" hspace="0" border="0" class="hand"></td>\n';
				image +='</tr>\n';
				image +='<tr>\n';
				image +='  <td colspan="3">'
				image += swfFile[i];
				image +='</tr>\n';
				image +='<tr bgcolor="'+color[classSlide[i]]+'">\n';
				image +='<td width="10"><img src="../../media/chapters/clear.gif" width="10" height="10" vspace="0" hspace="0" border="0" class="hand"></td>\n';
				image +="		<td width=270 valign=top class=\"ImageTableCell hand\">\n";
				image += (crdTitle==""||crdTitle=="&nbsp;"||crdTitle == wbtitle && i > 1)?"":"		"+wrapLink(crdTitle,cardSlide[i],"cardHeader")+"<br>\n";
				image += "		"+wrapLink(hline,cardSlide[i],"cardBody");
				image +="	</td>\n";
				image +='<td width="10"><img src="../../media/chapters/clear.gif" width="10" height="10" vspace="0" hspace="0" border="0" class="hand"></td>\n';
				image +='</tr>\n';
				image +='<tr>\n';
				image +='<td colspan="3"><img src="../../media/chapters/'+classSlide[i].substring(0,2)+'.gif" alt="click here" width="290" height="27" vspace="0" hspace="0" border="0" class="hand"></td>\n';
				image +='</tr>\n';
				image +='</table>\n';
				image +='<p></p>\n';
				}
			}
		}
		document.write(image);
		//if(SF) writeNotesDiv(notestr);
	}

function NewIP(fname,wid,hgt,dcrtitle){
	if(parseFloat(ipclk) < 0){ipclk = setTimeout('ipclk=-1',500); }
	else{ return; }

	if(checkres(600)){
		popRes();
		return;
		}
	var vert = (screen.height - hgt) / 2;
	var horiz = (screen.width - wid) / 2;

	if (screen.width> 800){ //jd
	  var extras = 'height='+hgt+',width='+wid+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no';
	} else { // jd added fullscreen
 	  var extras = 'height='+hgt+',width='+wid+',top='+vert+',left='+horiz+',scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=yes,resizable=no';
	}

	var wblocation = 'media/' + fname;
	titleOP = (dcrtitle == 'undefined')?"Interactive Problem":dcrtitle;
	var name = fname.substring(0,(fname.length-4));

	if(typeof(win)!='undefined' && !win.closed){win.close()}
	win = window.open('../../scripts/interactives.html?titleOP='+titleOP+'&wid='+wid+'&hgt='+hgt+'&fname='+fname,'interactive'+fname.substring(0,fname.length),extras);
	if (parseInt(navigator.appVersion) >= 4) { win.focus(); }

	}

function closeIPs(){
	if(typeof(win)!='undefined' && !win.closed){win.close()}
	}


function writeDiagram(nam,wid,hit,rtn){
if (wid == 'null') wid = 470;
if (hit == 'null') hit = 300;
	obj="";
	if(rtn){
		obj+="</p><p class=\"SectionBody\">";
		}
	obj +='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ID="whiteboard" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+wid+'" height="'+hit+'">';
	obj +='<PARAM NAME="movie" Value="media/'+nam+'.swf">';
	obj +='<PARAM NAME="quality" VALUE="high">';
	obj +='<param name="PLAY" value="false">';
	obj +='<PARAM NAME="bgcolor" VALUE="#FFFFFF">';
	obj +='<EMBED swliveconnect="true" src="media/'+nam+'.swf" quality="high" bgcolor="#FFFFFF" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="'+wid+'" height="'+hit+'">';
	obj +='</EMBED>';
  obj +='</OBJECT>';
  if(rtn) obj+="</p><p class=\"SectionBody\">";

	if(typeof(rtn) == 'undefined') document.write(obj)
	else return obj;
    }

thisInterval=0;
otherInterval=0;
thisTimeout=0;
function popup(term){
	if(document.getElementById(term)!='undefined'){
		var place = term.substring(term.indexOf("-"),term.length);
		var e = document.getElementById("toc4"+place);
		if(document.getElementById(term).style.height==""){	document.getElementById(term).style.height=25;}
		clearInterval(thisInterval);
		clearTimeout(thisTimeout);
		if(document.getElementById(term)!=null){
			layerToPop = document.getElementById(term).style;
			layerToPop.left = findPosX(e) - (SF?1:0);
			layerToPop.top = findPosY(e) - (SF?1:0);
			layerToPop.visibility = "visible";
			thisInterval = setInterval("dynamicMove('"+term+"',5)",25);
			}
		}
	}
function hide(lName){
	var st = document.getElementById(lName).style;
	st.visibility = "hidden";
	st.height = 20;
	}
function hidelayer(lName){
	if(document.getElementById(lName)!='undefined'){
		clearInterval(thisInterval)
		clearTimeout(thisTimeout);
		if(!Mac){
			if(document.getElementById(lName)!=null){
				thisInterval = setInterval("dynamicMove('"+lName+"',-5)",25);
				}
			}
		else{
			thisTimeout = setTimeout("hide('"+lName+"')",500);
			}
		}
	}

function dynamicMove(layerToMove, pxInterval){
//moves the tab layers 10 px at a time, starting and stopping at certain points.
	layerMove = document.getElementById(layerToMove);
	var yBeg = layerMove.style.height;
	var y = parseFloat(yBeg);

	y += pxInterval;
	var big = (pxInterval>0)?(SF)?90:95:20;
	var tester = (pxInterval>0)?(y<big):(y>big);
	if(tester) {
		layerMove.style.height = y;
		}
	else{
		clearInterval(thisInterval);
		layerMove.style.height = (pxInterval>0)?(SF)?85:90:25;
		if(pxInterval<0) hide(layerToMove);
		}
	}
function colorup(cll,clr){
	if(document.getElementById(cll)){
		document.getElementById(cll).style.backgroundColor=clr;
		}
	}
function nothing(){}

function writeProbsLink(chnm){
	if(typeof(chapters)!='undefined' && chapters[chnm][2]){
		relpath = "../../problems/StudentManual";
		loc = window.location+"";
		getChapterFolder = loc.split("/");
		document.write("<a href=\""+relpath+"/"+getChapterFolder[getChapterFolder.length-3]+"/index.htm\">");
		document.write("<img src='../../media/chapters/next.gif' border='0'>");
		document.write("</a>");
		}
	}

function writeLongCard(card){
	buildSwfFile();
	lngcrd = "";
	if(typeof(cardBreakAfter) != 'undefined'&&typeof(cardBreakAfter[0]) != 'undefined'){
		document.write("</TD><TD CLASS=\"SectionTableCol2\">&nbsp;</TD><TD class=\"SectionTableCol3\">")
		writeImageCol();
		}
	else{
		lngcrd+="</TD><TD CLASS=\"SectionTableCol2\">&nbsp;</TD><TD class=\"SectionTableCol3\">";
		}
	var i = starter;
	var hi = (i==cardSlide.length-1)?lastSlide-1:cardSlide[i+1]-1-1;
	if(starter == 1 && addNum[classSlide[0]]==1) 	addNum[classSlide[0]] ++;
	lngcrd+="&nbsp;</TD></TR>";
	lngcrd += "<TR><TD colspan=2 style=\"padding:0px; height:200px; padding-top:0px;background:"+liteColor[classSlide[i]]+";\">";
	lngcrd += writeDiagram("crd_0"+(i+1),470,200,false);
	lngcrd+="</TD><TD background=\"../../media/chapters/ILL-00-08.gif\" valign=top style=\"padding-top:0px\">";

	crdTitle="";
	if(i==0) crdTitle = (wbtitle)?wbtitle:"";
	if(cardSlide[i] != "9999" ){
		if(subtitleslide){
			for(j=0;j<subtitleslide.length;j++){
				if(cardSlide[i]==subtitleslide[j]){
					crdTitle = subtitle[j];
					}
				}
			}
		if(questionslide){
			for(k=0;k<questionslide.length;k++){
				if(cardSlide[i] == questionslide[k]){
					crdTitle = question[k];
					}
				}
			}

		var hline;
		if (typeof(headline)!='undefined') {
			hline = (headline[hi])?headline[hi]:"";
			}
		else hline = "temp text until wb's are exported again.";

		if (crdTitle != "" || !(hline =="" || hline == "&nbsp;")){

			lngcrd +='<table border="0" cellspacing="0" cellpadding="0" height="200" width="290" onClick="window.location=\'javascript:aNewWhiteboard('+cardSlide[i]+')\'">\n';
			lngcrd +='<tr>\n';
			lngcrd +='<td colspan="3" height="15"><img src=\"../../media/chapters/'+classSlide[i].substring(0,2)+""+addNum[classSlide[i]];
			addNum[classSlide[i]]++
			lngcrd +='.gif" alt="'+classSlide[i]+'" style=\"border-left:1px solid '+color[classSlide[0]]+';\" height=\"23\" width=\"288\" border=\"0\" class="hand"></td>\n';
			lngcrd +='</tr>\n';
			lngcrd +='<tr bgcolor="'+color[classSlide[i]]+'">\n';
			lngcrd +='<td width="10"><img src="../../media/chapters/clear.gif" width="10" height="10" vspace="0" hspace="0" border="0" class="hand"></td>\n';
			lngcrd +="		<td width=270 valign=top class=\"ImageTableCell hand\">\n";
			lngcrd += (crdTitle==""||crdTitle=="&nbsp;")?"":"		"+wrapLink(crdTitle,cardSlide[i],"cardHeader")+"<br>\n";
			lngcrd += "		"+wrapLink(hline,cardSlide[i],"cardBody");
			lngcrd +="		</td>\n";
			lngcrd +='<td width="10"><img src="../../media/chapters/clear.gif" width="10" height="10" vspace="0" hspace="0" border="0" class="hand"></td>\n';
			lngcrd +='</tr>\n';
			lngcrd +='<tr>\n';
			lngcrd +='<td colspan="3" height="15"><img src="../../media/chapters/'+classSlide[i].substring(0,2)+'.gif" alt="click here" width="290" height="27" vspace="0" hspace="0" border="0" class="hand"></td>\n';
			lngcrd +='</tr>\n';
			lngcrd +='</table>\n';
			}
		}
	lngcrd += "</TD></TR>";
	lngcrd += "<TR><TD CLASS=\"SectionTableCol1\">";
	document.write(lngcrd);
	starter ++;
	}
function getlink(l_id){
	var hgt = 600;
	var wid = 785;
	var base = "http://www.kineticbooks.com/links/link.php?LinkId=";
	var vert = (screen.height - hgt) / 2;
	var horiz = (screen.width - wid) / 2;
	var extras = 'height='+hgt+',width='+wid+',top='+vert+',left='+horiz+',scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes';


	var name = "linkspage";
	var html = base+l_id+"";
	var nwin = window.open(html,name,extras);
	}

function NewWB(crd){
	aNewWhiteboard(cardSlide[crd-1]);
	}
if(cardSlide){
	for(m=cardSlide.length-1;m>0; m--){
		if(typeof(headline)!='undefined'){
			if(m!=cardSlide.length-1){
				//if you strip out all <br> then lines that should break no longer do.
				//The next line replaces the 3rd line down... I hope.
				//this replaces the NEXT card's headlines that match THIS card's headlines.
				//-2 because you have to correct for a 0 based system, and you need the headlines from one slide before the slide you're displaying next
				replaceHeadlines(cardSlide[m+1]-2,cardSlide[m]-2);
				}
			else if(cardSlide[m-1]-2 == -1){
				//this means that the lastSlide is cardSlide[1] and the cardSlide before it is 1, so cardSlide[m-1]-2 is -1, giving an error
				replaceHeadlines(lastSlide-1,cardSlide[m]-2);
				}
			else if(m == cardSlide.length-1 && classSlide[cardSlide[m]]==classSlide[cardSlide[m-1]] && (cardSlide[m]-cardSlide[m-1])!=1){
				// replace the matching headlines on the last slide to the second to last slide.
				replaceHeadlines(headline.length - 1,cardSlide[m]-2);
				}
			else if(m == cardSlide.length-1){
				replaceHeadlines(headline.length - 1,cardSlide[m-1]-1);
				}
			else{
				//replaces the last slide's headlines with the cardSlide before it's last headlines
				headline[lastSlide-1] = headline[lastSlide-1].replace(headline[cardSlide[m-1]-2],"");
				}
			}
		}
	}
function newWB(crd){ NewWB(crd);};

function writeInternalLink(elementid,linkTitle){
var loc = document.location.toString();
var splitter = (loc.indexOf("\\")==-1)?"/":"\\";
var folders = loc.split(splitter);
var chLen = folders[folders.length-2].length;
	var iofNum = elementid.indexOf("#")
	if (iofNum > -1)
	{
		var eid = elementid.substr(0,iofNum);
	}
	else
	{
		eid = elementid;
	}
	if (Link[eid])
	{
	arr = new Array();
	var shref;
	arr = Link[eid].split("|");
	//if using chapter name format, create link using names
	switch (chLen){
		case 2:
			shref= "<a href=\"../../" + arr[3] + "_" + arr[4] + "/" + arr[1] + "/sp.html";
			break;
		case 5:
			shref= "<a href=\"../../"  + arr[5] + "/" + arr[0] + "/sp.html";
			break;
		default:
			shref= "<a href=\"javascript: tlink('../../"  + arr[5] + "/" + arr[0] + "/sp.html";
	}
	if (iofNum > -1)
	{
		shref += "#" + elementid.substr(iofNum + 1);
	}
	shref += (chLen<=5) ? "\"":"')\""; //If < 5 then it is either in staging or fs. > 5 means munged
	if (linkTitle) shref+= " title=\"" + linkTitle + "\"" ;
	shref+= ">" ;
	document.write(shref);
	return;
	}
}

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
			}
		}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
	}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
			}
		}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
	}
function feedbackButton(sec,ch){
	window.onload=init;
	window.onunload = uninit;
	if(ch.indexOf(",")>0){ch=ch.substr(0,ch.indexOf(","));}
	document.write('<img src="../../media/prefs/footer_issues1.gif" class="hand" id="issues" onClick="feedback(\'Textbook&ChId='+ch+'&SecId='+sec+'\');">')
	}
function prefpage(e){
	var loc = document.location.href;
	var title = document.title;
	var url = "../../prefs/prefs.html?loc="+loc+"&title="+title;
	document.location = url;
	}
function feedback(type){
	var base = "http://www.kineticbooks.com/forms/feedback.php";
	var extras = "scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes";
	var name = "fb";
	type += "&ver="+version+"&loc=web&pid="+prodID;
	var html = base+"?product="+type;
	var nwin = window.open(html,name,extras);
	if (parseInt(navigator.appVersion) >= 4) { nwin.focus(); }

	}


function mathMLClick(mml){

	var der = /d(\d+)n(\d+)/;
	var wb = /wb(\d+)/;
	var eq = /eq(\d+)/;
	if(wb.test(mml)){
		var a = mml.match(wb);
		aNewWhiteboard(a[1]);
		}
	else if(der.test(mml)){
		var a = mml.match(der);
		PlayClipMML(a[2],a[1]);
		}
	else{
		var a= mml.match(eq);
		getEquation(a[1]);
		}

	}
function tlink(lnk){
	location.href = lnk;
	}

function capMouseY(e){
	if(e.pageY){
		posy = e.pageY;
		}
	else if (e.clientY){
		posy = e.clientY + document.body.scrollTop;
		}
	return posy;
	}
function capMouseX(e){
	if(e.pageX){
		posx = e.pageX;
		}
	else if (e.clientX){
		posx = e.clientX + document.body.scrollLeft;
		}
	return posx;
	}


function setcookie(){
	var exp = new Date();
	var oneWeekFromNow = exp.getTime() + (3*30*24*60*60*1000);
	exp.setTime(oneWeekFromNow)
	document.cookie = "fs="+((typeof(fs)!='undefined')?fs:"2")+";path=/;expires="+exp.toGMTString();

	}

function writeexcel(ss){
	ssname = ss.substring(0,ss.indexOf(".xls"))+((Mac)?"Mac":"Win")+".xls";
	document.write("<a href=\""+ssname+"\" target=\"_blank\">");
	}

function wSWFt(swfObject) {
	document.write("<object type=\"application/x-shockwave-flash\" " + swfObject + "</object>");
}

function wQTid(qtObject) {
	document.write("<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" " + qtObject + "</object>");
}
