
// Initialize variables:

var qq = '\"';						// Escaped double quote character
var d=document;


function preloadGIF() {					// Load button highlights into the browser's memory cache

	if (d.images){ 
		if(!d.allImages) d.allImages=new Array();
		var i,j=d.allImages.length, imgList=preloadGIF.arguments;

		for(i=0; i<imgList.length; i++)
			if (imgList[i].indexOf("#")!=0){ 
					d.allImages[j]=new Image; 
					d.allImages[j++].src='images/' + imgList[i] + '.gif';
			}
		}
}


function preloadGIFsub() {				// Load button highlights from a subdirectory

	if (d.images){ 
		if(!d.allImages) d.allImages=new Array();
		var i,j=d.allImages.length, imgList=preloadGIFsub.arguments;

		for(i=0; i<imgList.length; i++)
			if (imgList[i].indexOf("#")!=0){ 
					d.allImages[j]=new Image; 
					d.allImages[j++].src='../images/' + imgList[i] + '.gif';
			}
		}
}



function getObjectByID(name) {				// Get an object's ID tag for easy referencing

	if (document.getElementById) {				// Firefox and Safari
		return document.getElementById(name);
	} else if (document.all) {				// IE
		return document.all[name]; 
	} else if (document.layers) {
		return document.layers[name];
	} else {
		return document.getElementById(name);		// Default for unknown browsers
	}
}


function embedFlash(thisFile, w, h, thisColor) {	// Shows the activeX control without an annoying 'activate' prompt

	var embedCode = "<td valign='top' bgcolor='" + thisColor + "'><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' "
		+ "codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='" + w + "' height='" + h + "'>"
		+ "     <param name='movie' value='" + thisFile + "'>"
		+ "     <param name='quality' value='high'>"
		+ "     <embed src='media/introduction.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' "
		+ "type='application/x-shockwave-flash' width='" + w + "' height='" + h + "'></embed></object>";

	document.write(embedCode);
}


function buttonState(buttonID, state) {			// Change button state by replacing .gif files:
							// Valid states are '', '_h', and '_s'
	var buttonName = buttonID + 'Btn';
	var newImgFile = 'images/mmBtn_' + buttonID + state + '.gif';

	buttonObj = getObjectByID(buttonName);

	buttonObj.src = newImgFile;
}


function toggleMenu(menuID) {				// If table is visible, hide it and vice versa

	var menuName = menuID + "Menu";
	menuObj = getObjectByID(menuName);

	if (menuObj.style.display == "none") {
		menuObj.style.display = "";
	} else {
		menuObj.style.display = "none";
	}
}


function showTable(menuID) {				// Show a dynamic rollover menu

	var menuName = menuID + "Menu";
	menuObj = getObjectByID(menuName);

	menuObj.style.display = "";
}



function hideTable(menuID) {				// Hide a dynamic rollover menu

	var menuName = menuID + "Menu";
	menuObj = getObjectByID(menuName);

	menuObj.style.display = "none";
}


function expandMenu(menuID) {				// Show menu and highlight associated button

	buttonState(menuID, '_h');
	showTable(menuID);
}


function collapseMenu(menuID) {				// Hide menu and de-highlight associated button

	buttonState(menuID, '');
	hideTable(menuID);
}


function openWin(whichURL,winW,winH) {			// Open document in a new window

screenH = 600;
if (parseInt(navigator.appVersion)>3) {
 screenH = screen.height;
 screenW = screen.width;
}
else if (navigator.appName == "Netscape" 
    && parseInt(navigator.appVersion)==3
    && navigator.javaEnabled()
   ) 
{
 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
 var jScreenSize = jToolkit.getScreenSize();
 screenH = jScreenSize.height;
 screenW = jScreenSize.width;
}

popWin=window.open(whichURL,"pWin","toolbar=no,scrollbars=yes,resizable=no,width="+winW+",height="+winH+",left="+Math.round((screenW/2)-(winW/2)));
}


function setFormDate() {				// Places the current date on the EDLST212 Registration Form

        var now = new Date();
	var m = now.getMonth();
	m+=1;
	var d = now.getDay();
	var y = now.getFullYear();

	thisDate = m + '/' + d + '/' + y;

		// Set hidden Date field on the form:

	var dateObj = getObjectByID('date');
	dateObj.value = thisDate;

		// Display Semester Year on the form (i.e., "Fall 2007")

	var yearObj = getObjectByID('year');
	yearObj.innerHTML = y+' ';
}


function updateAnnouncements() {		// Shows the EDLST212 Registration announcement Mar through Sep

        var now = new Date();
	var m = now.getMonth();
	m+=1;

	var mar_sepAnnouncementObj = getObjectByID('march-septemberAnnouncement');


	if ((m > 2) && (m < 10)) {				// Current date is March - September: show it

		mar_sepAnnouncementObj.style.display = "";

	} else {						// Current date is October - February: hide it

		mar_sepAnnouncementObj.style.display = "none";
	
	}
}
