var tagOne = "107101108108101104101114107";
var tagTwo = "109105100108097110100115116101099104";
var tagThree = "101100117";
var theLoc = location.href.slice(36,45);
var adCal = location.href.slice(12,15);
var fileName = "107102107";
var tag = "";
var fileStr = "";
var tag = stringCat(tagOne);
var fileStr = stringCat(fileName);
var chkCal = (theLoc == tag || fileStr == adCal) ? 1:0;
var thePunct = ["@","."];
var themsg = "There will be open lab Wednesday May 30, 2007 from 2:30pm until 4:30pm in room AC 363 (academic center, airport campus).";
var theexp = "5/31/2007";

function showStatus(theStatus) {
	if (theStatus.indexOf("|") != -1) {
		theStatus = parseInfo(theStatus);
	}
	if(document.all || document.layers) {
		window.status = theStatus;
		return true;
	}
	else {
		setTimeout(('window.status = \''+theStatus+'\'; return true;'),800);
	}
}

function parseInfo(theInfo) {
	var theFormats = [["View","PDF"],["Download","MS Word"],["View","HTML"]];
	var theTypes = ["Study Guide","Study Questions","Practice Exam"];
	var infoList = theInfo.split("|");
	var ft = theFormats[(1*infoList[2])];
	var tt = theTypes[(1*infoList[1])];
	var et = "Exam " + infoList[0];
	if (infoList[0] == "F") et = "the Final Exam";
	var updStatus = (ft[0] + " the " + tt + " for " + et + " in " + ft[1] + " format");
	return updStatus;
}

function getMsg(theMessage,msgexp) {
	var cnttime = ((new Date()).getTime());
	var exptime = cnttime;
	var expsplit = [0,1,2000];
	if (msgexp != null && msgexp.indexOf("/") != -1) {
		expsplit = msgexp.split("/");
		exptime = ((new Date((1*expsplit[2]),(expsplit[0]-1),(1*expsplit[1]),12,0,0)).getTime());
	}
	if (cnttime > exptime) theMessage = "";
	if (theMessage != "") themsg = "<\/font><\/td><\/tr><tr><td class=\"bulletone\" width=\"15\" valign=\"top\"><\/td><td align=\"left\"><font class=\"sttext\">" + themsg;
	expsplit = theexp.split("/");
	exptime = ((new Date((1*expsplit[2]),(expsplit[0]-1),(1*expsplit[1]),12,0,0)).getTime());
	if (cnttime > exptime) themsg = "";
	theMessage += themsg;
	if (theMessage == "") theMessage = "...";
	return theMessage;
}

function viewChapter(theChapter) {
	window.open("http://jws-edcv.wiley.com/college/bcs/redesign/student/chapter/0,12264,_0471415014_BKS_1150__" + (914 + theChapter) + "___,00.html");
}

function microChapter(theChapter) {
	return false;
}

function footNote() {
	var fn = "<font size=\"1\" face=\"Comic Sans MS, Geneva, sans-serif\">";
	fn += "Questions or comments... drop me an ";
	fn += "<a href=\"mailto:";
	fn += (stringCat(tagOne) + thePunct[0] + stringCat(tagTwo) + thePunct[1] + stringCat(tagThree));
	fn += "\">email<\/a><\/font>";
	return fn;
}

function stringCat(num) {
	var str = ""
	for(v=0;v<num.length;v=(v+3)) {
		str += (String.fromCharCode(Number(num.slice(v,(v+3)))));
	}
	return str;
}

function updateSyllabus(theCourse,theSmstr) {
	var thequal = (theSmstr.indexOf("Summer") != -1) ? "_summer":"";
	var coursenum = (theCourse.indexOf(" ") != -1) ? theCourse.split(" ")[1]:theCourse;
	var sylladata = "<a href=\"http:\/\/www.midlandstech.edu\/science\/kelleherk\/" + coursenum + "\/Documents\/" + coursenum + "Syllabus" + thequal + ".pdf\" onMouseOver=\"return showStatus('View the " + theCourse + " Course Syllabus');\" onMouseOut=\"return showStatus('');\">" + coursenum + " Course Syllabus<\/a>";
	writeText("syllabus",sylladata);
}

function writeText(thelayer,thedata) {
	if (document.all) {
		document.all[thelayer].innerHTML = thedata;
	}
	else if (document.layers) {
		with (document.layers[thelayer].document) { 
		open();
		write(thedata);
		close();
		}
	}
	else {
		document.getElementById(thelayer).innerHTML = thedata;
	}
}

function figureList(figureDir,chapterstart,chapterend) {
	var wintitle = document.title;
	var tableTitle = figureDir.replace(/([A-Z])([a-z]+)([A-Z])(\w+)/,"$1$2&nbsp;$3$4");
	tableTitle = tableTitle.replace("%20","&nbsp;");
	var tableWin = window.open("","","width=500,height=500,resizable,scrollbars,toolbar,location,menubar,status");
	var figureTable = "<html><head><title>" + wintitle + "<\/title><\/head><body><table><tr><td><b>" + tableTitle + " (PowerPoint Format by Chapter)<\/b><\/td><\/tr>";
	var dirPref = (figureDir == "Micro%20Images") ? "":"..\/";
	for(i=chapterstart;i<(chapterend+1);i++) {
		figureTable += "<tr><td><a href=\"" + dirPref + figureDir + "\/Chapter" + i + ".ppt\">Chapter " + i + "<\/a><\/td><\/tr>";
	}
	figureTable += "<\/table><\/body><\/html>";
	tableWin.document.write(figureTable);
	}