
/***********************************************
* Tabbed Document Viewer script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var selectedtablink=""
var tcischecked=false

var selectedtablink2=""
var tcischecked2=false

/* ******************************************************************* */
function handlelink(aobject, d, c){

	dir = d;
	course = c;

	//selectedtablink = aobject.href;
	selectedtablink = d;
	tcischecked = (document.tabcontrol && document.tabcontrol.tabcheck.checked)? true : false;
	
	if (document.getElementById && !tcischecked) {

		var tabobj = document.getElementById("tablist");
		var tabobjlinks = tabobj.getElementsByTagName("A");
		
		for (i=0; i<tabobjlinks.length; i++)
			tabobjlinks[i].className="";
			
		aobject.className="current";
		
		//document.getElementById("tabiframe").src=selectedtablink
		//showCalendar(selectedtablink);

	  	dateChanged(window.calendar);
		show_listassignments_link(dir);

		return false;
	}
	else

		return true;
}

/* ******************************************************************* */
function handleview(){
	
	tcischecked = document.tabcontrol.tabcheck.checked;

	if (document.getElementById && tcischecked) {
		if (selectedtablink!="")
			window.location=selectedtablink;
	} 
}

/* ******************************************************************* */
function handlelink2(aobject){
	selectedtablink2=aobject.href
	tcischecked2=(document.tabcontrol && document.tabcontrol.tabcheck.checked)? true : false
	if (document.getElementById && !tcischecked2){
		var tabobj=document.getElementById("tablist2")
		var tabobjlinks=tabobj.getElementsByTagName("A")
		for (i=0; i<tabobjlinks.length; i++)
			tabobjlinks[i].className=""
		aobject.className="current2"
		document.getElementById("tabiframe2").src=selectedtablink2
		return false
	}
	else
		return true
}

/* ******************************************************************* */
function handleview2(){
	tcischecked2=document.tabcontrol.tabcheck.checked
	if (document.getElementById && tcischecked2){
		if (selectedtablink2!="")
		window.location=selectedtablink2
	}
}

/* ******************************************************************* */
/* This functions properly spaces content below the second iframe */
function afteriframe() {
	if (navigator.product == 'Gecko') {
		document.write("<br />\n");
	}
	else {
		document.write("<br /><br />\n");
	}
}

function afteriframe2() {
	if (navigator.product == 'Gecko') {
		document.write("<br />\n");
	}
	else {
		document.write("<br /><br />\n");
	}
}

/* Javascript Clock Code */

// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
// Edited by Allen Murphy

var clockID = 0;

/* ******************************************************************* */
function UpdateClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }

   var tDate = new Date();

   window.document.getElementById("theClock").innerHTML = "" 
                                   + tDate.getHours() + ":" 
                                   + tDate.getMinutes() + ":" 
                                   + tDate.getSeconds();
   
   clockID = setTimeout("UpdateClock()", 1000);
}

/* ******************************************************************* */
function StartClock() {
   clockID = setTimeout("UpdateClock()", 500);
}

/* ******************************************************************* */
function KillClock() {
   if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
   }
}
/* End Javascript Clock Code */

/* ******************************************************************* */
/* Today's Date */
function gettodaysdate() {
	// Array of day names
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday",
					"Thursday","Friday","Saturday");
	
	// Array of month Names
	var monthNames = new Array(
	"Jan","Feb","Mar","Apr","May","Jun","Jul",
	"Aug","Sep","Oct","Nov","Dec");
	
	var now = new Date();
	document.write(dayNames[now.getDay()] + ", " + 	monthNames[now.getMonth()] + " " + 
		now.getDate() + ", " + now.getFullYear());
}

/* Home page functions */

/* ******************************************************************* */
function getInternetExplorerVersion() {
	// Returns the version of Internet Explorer or a -1
	// (indicating the use of another browser).

	var rv = -1; // Return value assumes failure
	if (navigator.appName == 'Microsoft Internet Explorer') {
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
			rv = parseFloat( RegExp.$1 );
	}
	return rv;
}

/* ******************************************************************* */
function winalign() {
	/*if (getInternetExplorerVersion() > 0 && getInternetExplorerVersion() < 9) {
		window.resizeBy( -10, -10 );
		//window.resizeBy( 10, 10 );
		document.getElementById("tabiframe2").src = "math8/m8ch2resources.php";
	}*/
}

/* ******************************************************************* */
function iewindowresize() {

	//alert("in it");
	/*if (getInternetExplorerVersion() > 0 && getInternetExplorerVersion() < 9) {

		if (course == "Pre-Algebra") {
			handlelink(this, 'math8', 'Pre-Algebra');
		}
		else {
			handlelink(this, 'algebra', 'Algebra');
		}
	}*/
}
	
/* ******************************************************************* */
function check_ie6() {

	var bName = navigator.appName;
	var bVer = getInternetExplorerVersion();
	
	if (bName == "Microsoft Internet Explorer" && bVer < 7.0) {
		window.document.write("<br /><div align=\"center\"><p>Your browser is out-of-date.  Dragonometry recommends upgrading to " +
			"<a href=\"http://www.microsoft.com/windows/downloads/ie/getitnow.mspx\">" +
			"Internet Explorer 7</a> " +
			"or better yet <a href=\"http://www.getfirefox.com\">Firefox 3</a>.</p></div>");
	}
}

/* ******************************************************************* */
function check_ie() {

	var bName = navigator.appName;

	if (bName == "Microsoft Internet Explorer") {
		window.document.write("\t\t\t\t<br />\n");
	}
}

/* ******************************************************************* */
function getfirefox() {

	if (navigator.appName == "Microsoft Internet Explorer") {
		window.document.write("<a href=\"http://getfirefox.com/\" " +
			"title=\"Get Firefox - The Browser, Reloaded.\">" +
			"<img src=\"http://www.mozilla.org/products/firefox/buttons/getfirefox_88x31.png\" " + 
			"width=\"88\" height=\"31\" border=\"0\" style=\"vertical-align: middle;\" " +
			"alt=\"Get Firefox\" /></a>"); 
	}
}

/* ******************************************************************* */
function show_listassignments_link(dir) {

	if (dir == "math8") {
		theclass = "Pre-Algebra";
	}
	else if (dir == "calculus") {
		theclass = "Calculus";	
	}
	else if (dir == "concepts") {
		theclass = "Algebra Concepts";	
	}
	else if (dir == "geometry") {
		theclass = "Geometry";	
	}
	else {
		theclass = "Algebra";
	}
	
	document.getElementById("listassignmentslink").innerHTML = ("" +
					"<p><a title=\"List all assignments in browser\" class=\"boldwhite\" target=\"_top\"" + 
					"href=\"listassignments.php?class=" + dir + "\">View All " + theclass + " Entries</a> " + 
					" | <span class=\"boldwhite\">Feed: </span><a title=\"Subscribe to calendar RSS Feed\" target=\"_top\"" +  
					"href=\"http://dragonometry.net/" + dir + "/assignments-rss.xml\"><img border=\"0\"" +  
					"src=\"images/feed-icon-14x14.png\" /></a></p>");
}

/* ******************************************************************* */
function classtab_click(d, c) {

	dir = d;
	course = c;

	if(dir == "algebra") {
		document.getElementById("algebra").className = "current";
		document.getElementById("calculus").className = "background";
		document.getElementById("assignmentframe").style.backgroundColor ="#dddddd";
	}
	else if(dir == "calculus") {
		document.getElementById("calculus").className = "current";
		document.getElementById("geometry").className = "background";
		//document.getElementById("algebra").className = "background";
		document.getElementById("assignmentframe").style.backgroundColor ="#ffffff";
	}
	else if(dir == "geometry") {
		document.getElementById("geometry").className = "current";
		document.getElementById("calculus").className = "background";
		//document.getElementById("concepts").className = "background";
		document.getElementById("assignmentframe").style.backgroundColor ="#dddddd";
	}
	else if(dir == "concepts") {
		document.getElementById("concepts").className = "current";
		document.getElementById("calculus").className = "background";
		document.getElementById("geometry").className = "background";
		document.getElementById("assignmentframe").style.backgroundColor ="#ffffdd";
	}
	else {
		document.getElementById("algebra").className = "background";
		document.getElementById("math8").className = "current";
		document.getElementById("assignmentframe").style.backgroundColor ="#ffffff";
	}
	
	dateChanged(window.calendar);
	show_listassignments_link(dir);
}

/* ******************************************************************* */
function check_calendar() {

	show_listassignments_link("calculus");
	
	var bName = navigator.appName;
	var bVer = getInternetExplorerVersion();

	if (bName == "Microsoft Internet Explorer" && bVer < 7.0) {
		window.document.write("<div align=\"center\"><p>(If you do not see a calendar above, " + 
			"please click either the " +
			"<b>Calculus</b> tab, the <b>Geometry</b> tab, or the <b>Algebra Concepts</b> tab above.)</p></div>");
	}

}

/* ******************************************************************* */
function openinwindow(vid) {
	vid = "http://www.math.armstrong.edu/faculty/hollis/calcvideos/" + vid;
	window.open(vid,'popup','width=828,height=644, menubar=no, statusbar=no, scrollbars=no,resizable=yes,location=no');
}


