function walkTheDOM(node, func) {
    func(node);
    node = node.firstChild;
    
    while (node) {
        walkTheDOM(node, func);
        node = node.nextSibling;
    }
    
}

function getElementsByClassName(className) {
    var results = [];
    walkTheDOM(document.body, function(node) {
        var a;
        var c = node.className;
        var i;
        
        if (c) {
            a = c.split(' ');
            for (i = 0; i < a.length; i += 1) {
                if (a[i] === className) {
                    results.push(node);
                    break;
                }
            }
        }
        
    } );
    return results;
}

function addEvent(obj, evt, fn) {

    if (obj.addEventListener) {
        obj.addEventListener(evt, fn, false);
    }
    else if (obj.attachEvent) {
        obj.attachEvent('on' + evt, fn);
    }
    
}

function removeEvent(obj, evt, fn) {

    if (obj.removeEventListener) {
        obj.removeEventListener(evt, fn, false);
    }
    else if (obj.detachEvent) {
        obj.detachEvent('on' + evt, fn);
    }
    
}

function createMenu() {
    var clicked;
    var cookie = new Cookie("menudata");
    var isExpanded=false;
    var isSubmenuExpanded=false;
    var submenuClicked;
      
    function createSubMenu() {
        var i;
        var n;
        var x;
           
        x = document.getElementById('subNav').getElementsByTagName('DIV');
        
        for (i = 0; x[i]; i += 1) {
            n = x[i].className;
            
            if (n === 'menu') {
                x[i].onclick = clickMenu;
            }
            else if (n ==='submenu') {
                x[i].onclick = clickSubmenu;
            }
        }
    }

    function clickMenu(e){
        var evt = e || window.event;
        var tg = evt.target || evt.srcElement;
   
        while (tg.nodeName != 'DIV') {    
            tg = tg.parentNode;
        }
                     
        cookie.menuId = tg.id;
        cookie.store(10, '/~aottenbe/', 'web.gccaz.edu');
        
        // cancel event capturing/bubbling to stop propagation to parent/child
        evt.cancelBubble = true;
        if (evt.stopPropagation) {
            evt.stopPropagation();
        }
           
        if( tg.className === 'menu') { // if not an anchor nested within menu DIV 
            
            if( tg !== clicked) { // selected another menu already or is first click 
                closeAllChildren();
                showTargetChildren(tg);
            }
            else if (isExpanded) { // consecutive clicks on this target 
                closeAllChildren(tg);
            }
            else
                showTargetChildren(tg); 
                
            clicked = tg;
        }
                
    }

    function clickSubmenu(e){
        var evt = e || window.event;
        var tg = evt.target || evt.srcElement;
        
        while (tg.nodeName != 'DIV') {
            tg = tg.parentNode;
        }
                               
        cookie.menuId = tg.id;
        cookie.store(10, '/~aottenbe/', 'web.gccaz.edu');
       
        // cancel event capturing/bubbling to stop propagation to parent/child
        evt.cancelBubble = true;
        if (evt.stopPropagation) {
            evt.stopPropagation();
        }
       
            if (tg != submenuClicked) { // selected another submenu already or 1st click  
                closeSiblings(tg);
                showTargetChildren(tg);
            }
            else if (isSubmenuExpanded) { // consecutive clicks on this target
                closeTargetChildren(tg);
            }
            else {
                showTargetChildren(tg);
            }
            
            submenuClicked = tg;
    }

    function closeMenu() {
        var i,
            x;
        
        x = document.getElementById('subNav').getElementsByTagName('DIV');
        
        for (i = 0; x[i]; i += 1) {
            if (x[i].className === 'child' || x[i].className === 'submenu') {
                x[i].style.display = 'none';
            }
        }
        
    }    
            
    function closeTargetChildren(n) {
        var children;
        var i;
        
        children = n.childNodes; // get all children of n (target of click)
        
        for (i = 0; children[i]; i++) {
        
            if (children[i].nodeName === 'DIV') {
                children[i].style.display = 'none';
                isSubmenuExpanded = false;
            }
        }
    }

    function showTargetChildren(n) {
        var children,
            i;
                       
        children = n.childNodes; // get all children of n (target of click)
        
        for (i = 0; children[i]; i += 1) {
        
            if (children[i].nodeName=='DIV') { 
                children[i].style.display='block';   
            }
            
        }   

        if(n.className === 'submenu' || n.className === 'child') { 
            isSubmenuExpanded=true;    
        }
        else if (n.className == 'menu') {
            isExpanded = true;
        } 
        
    }

    function closeAllChildren() {
        var x;
        var i;
        
        x = document.getElementById('subNav').getElementsByTagName('DIV');
        
        for (i = 0; x[i]; i += 1) {
        
            if (x[i].className === 'child' || x[i].className === 'submenu') {
                x[i].style.display = 'none';
                isExpanded = false;
                isSubmenuExpanded = false;
            }
            
        }
        
    }

    function closeSiblings(n) {
        var i;
        var p;
        var children;
        
        p = n.parentNode;
        children = p.childNodes; // get children of p (parent of clicked node)
        
        for (i = 0; children[i]; i += 1) {
        
            if (children[i].nodeName === 'DIV') {
            
                if (children[i].id !== n.id && (children[i].className === 
                    'submenu')) {
                    closeTargetChildren(children[i]);
                    isSubmenuExpanded=false;
                }
                
            }
            
        }
        
    }
    
    function isMainNav() {
        var aMainNav = ['aboutMe', 'index', 'contact'],
            loc,
            hash,
            page,
            x;
    
        loc = location.href;        
        hash = loc.lastIndexOf('/');       
        page = loc.slice(hash + 1, loc.length - 4);              
              
        for (x = 0; aMainNav[x]; x += 1) {

            if ( aMainNav[x] === page) {
                return true;
            }
        }
    
    }
        
    function setNav(){
        var newId, 
            otg,
            tg;
            
        newId = cookie.menuId;
        cookie.remove(newId);
        
        if(newId) {        
            tg = document.getElementById(newId);        
            otg = tg;
                       
            while (tg.className != 'menu') {                 
                tg = tg.parentNode;
            }
            
            clicked = tg;
            showTargetChildren(tg);
            
           if (otg.parentNode.className === 'submenu') {
               showTargetChildren(otg.parentNode);
            }             
                
        }
        else {
            closeAllChildren();
        }
       
	} // end setNav  
    
    function getBeat(){
        var beatTime=document.getElementById('beatTime');
        var now=new Date();
        var off=(now.getTimezoneOffset()+60)*60;
        var seconds=now.getHours()*3600+now.getMinutes()*60+now.getSeconds()+off;
        var beat=Math.floor(seconds/86.4);
        if(beat>1000){beat-=1000;}
        if(beat<0){beat+=1000;}
        beatTime.innerHTML="Internet Beat time : " + beat;
    }
      
    getBeat(); 
    createSubMenu();  
    closeMenu(); 
      
    if (!isMainNav()) {
        setNav(); // track what page is open
    }
     
} // end createMenu


 /**
 * This is the Cookie() constructor function.
 *
 * This constructor looks for a cookie with the specified name for the
 * current document.  If one exists, it parses its value into a set of
 * name/value pairs and stores those values as properties of the newly created
 * object.
 *
 * To store new data in the cookie, simply set properties of the Cookie
 * object.  Avoid properties named "store" and "remove" since these are 
 * reserved as method names.
 * 
 * To save cookie data in the web browser's local store, call store().
 * To remove cookie data from the browser's store, call remove().
 *
 * The static method Cookie.enabled() returns true if cookies are
 * enabled and returns false otherwise.
 */
function Cookie(name) {
    this.$name = name;  // Remember the name of this cookie

    // First, get a list of all cookies that pertain to this document
    // We do this by reading the magic Document.cookie property
    // If there are no cookies, we don't have anything to do 
    var allcookies = document.cookie;
    if (allcookies == "") return;

    // Break the string of all cookies into individual cookie strings
    // Then loop through the cookie strings, looking for our name
    var cookies = allcookies.split(';');
    var cookie = null;
    for(var i = 0; i < cookies.length; i++) {
        // Does this cookie string begin with the name we want?
        if (cookies[i].substring(0, name.length+1) == (name + "=")) {
            cookie = cookies[i];
            break;
        }
    }

    // If we didn't find a matching cookie, quit now
    if (cookie == null) return;

    // The cookie value is the part after the equals sign
    var cookieval = cookie.substring(name.length+1);

    // Now that we've extracted the value of the named cookie, we
    // must break that value down into individual state variable 
    // names and values. The name/value pairs are separated from each
    // other by ampersands, and the individual names and values are
    // separated from each other by colons. We use the split() method
    // to parse everything.
    var a = cookieval.split('&'); // Break it into an array of name/value pairs
    for(var i=0; i < a.length; i++)  // Break each pair into an array
        a[i] = a[i].split(':');

    // Now that we've parsed the cookie value, set all the names and values
    // as properties of this Cookie object. Note that we decode
    // the property value because the store() method encodes it
    for(var i = 0; i < a.length; i++) {
        this[a[i][0]] = decodeURIComponent(a[i][1]);
    }
}

/**
 * This function is the store() method of the Cookie object.
 *
 * Arguments:
 *
 *   daysToLive: the lifetime of the cookie, in days. If you set this
 *     to zero, the cookie will be deleted.  If you set it to null, or 
 *     omit this argument, the cookie will be a session cookie and will
 *     not be retained when the browser exits.  This argument is used to
 *     set the max-age attribute of the cookie.
 *   path: the value of the path attribute of the cookie
 *   domain: the value of the domain attribute of the cookie
 *   secure: if true, the secure attribute of the cookie will be set
 */
Cookie.prototype.store = function(daysToLive, path, domain, secure) {
    // First, loop through the properties of the Cookie object and
    // put together the value of the cookie. Since cookies use the
    // equals sign and semicolons as separators, we'll use colons
    // and ampersands for the individual state variables we store 
    // within a single cookie value. Note that we encode the value
    // of each property in case it contains punctuation or other
    // illegal characters.
    var cookieval = "";
    for(var prop in this) {
        // Ignore properties with names that begin with '$' and also methods
        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
            continue;
        if (cookieval != "") cookieval += '&';
        cookieval += prop + ':' + encodeURIComponent(this[prop]);
    }

    // Now that we have the value of the cookie, put together the 
    // complete cookie string, which includes the name and the various
    // attributes specified when the Cookie object was created
    var cookie = this.$name + '=' + cookieval;
    if (daysToLive || daysToLive == 0) { 
        cookie += "; max-age=" + (daysToLive*24*60*60);
    }

    if (path) cookie += "; path=" + path;
    if (domain) cookie += "; domain=" + domain;
    if (secure) cookie += "; secure";

    // Now store the cookie by setting the magic Document.cookie property
    document.cookie = cookie;
};

/**
 * This function is the remove() method of the Cookie object; it deletes the
 * properties of the object and removes the cookie from the browser's 
 * local store.
 * 
 * The arguments to this function are all optional, but to remove a cookie
 * you must pass the same values you passed to store().
 */
Cookie.prototype.remove = function(path, domain, secure) {
    // Delete the properties of the cookie
    for(var prop in this) {
        if (prop.charAt(0) != '$' && typeof this[prop] != 'function') 
            delete this[prop];
    }

    // Then, store the cookie with a lifetime of 0
    this.store(0, path, domain, secure);
};

/**
 * This static method attempts to determine whether cookies are enabled.
 * It returns true if they appear to be enabled and false otherwise.
 * A return value of true does not guarantee that cookies actually persist.
 * Nonpersistent session cookies may still work even if this method 
 * returns false.
 */
Cookie.enabled = function () {
    // Use navigator.cookieEnabled if this browser defines it
    if (navigator.cookieEnabled != undefined) return navigator.cookieEnabled;

    // If we've already cached a value, use that value
    if (Cookie.enabled.cache != undefined) return Cookie.enabled.cache;

    // Otherwise, create a test cookie with a lifetime
    document.cookie = "testcookie=test; max-age=10000";  // Set cookie

    // Now see if that cookie was saved
    var cookies = document.cookie;
    if (cookies.indexOf("testcookie=test") == -1) {
        // The cookie was not saved
        return Cookie.enabled.cache = false;
    }
    else {
        // Cookie was saved, so we've got to delete it before returning
        document.cookie = "testcookie=test; max-age=0";  // Delete cookie
        return Cookie.enabled.cache = true;
    }
};

function clickExpand() {
    var i;
    var list;

    list = document.getElementsByTagName('DIV');

    for (i = 0; list[i]; i += 1) {
    
        if (list[i].className === 'expand') {
            list[i].onclick = expandCollapse;
        }
        else if (list[i].className === 'collapse') {
                list[i].onclick = expandCollapse;
                list[i].style.display = 'none';
        }
        
    }
    
}

function changeExpand() {
    var i;
    var selected;
    
    selected = document.getElementsByTagName('select');
    
    for (i = 0; selected[i]; i += 1) {
    
        if (selected[i].className === 'expand') {
            selected[i].onchange = foldUnFold;
        }
        else if ( selected[i].className==='collapse') {
            selected[i].onchange = foldUnFold;
        }
        
    }
}

function expandCollapse(e) {
    var evt = e || window.event;
    var tg = evt.target || evt.srcElement;
    
    var startDatesEL=document.getElementById('startDates');

    while (tg.nodeName!='DIV') {
        tg=tg.parentNode;
    }

    if (startDatesEL === null) {
        if( tg.className === 'expand') {
            tg.style.display='none';
            while(tg.className!=="collapse") {
                tg=tg.nextSibling;
            }
            tg.style.display='block';
        }
        else if (tg.className === 'collapse') {
            tg.style.display='none';
            while(tg.className!=="expand") {
                tg=tg.previousSibling;
            }
            tg.style.display='block';
        }
    }
}

function foldUnFold(e){
    var evt = e || window.event;
    var tg = evt.target || evt.srcElement;
    while(tg.nodeName!='DIV'){
        tg=tg.parentNode;
    }
    if(tg.nodeName==='DIV'){
        tg=tg.nextSibling;	
        while(tg.nodeName!='DIV') {
            tg=tg.nextSibling;
        }
    }
    if(tg.className==='expand'||'collaspe'){
        tg.style.display='block';
    }
}

String.prototype.supplant = function (o) {
    return this.replace(/{([^{}]*)}/g,
        function (a, b) {
            var r = 0[b];
            return typeof r ==='string' ? r : a;
        }
    );
};


function nths(day){
    if(day==1||day==21||day==31){
        return'st';
    }
    if(day==2||day==22){
        return'nd';
    }
    if(day==3||day==23){
        return'rd';
    }
    return'th';
}

function getLastModified(){
    var d;
    var days;
    var last;
    var lastUpdate;
    var months;
    
    days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
        "Saturday"];
    months = ['January', 'February', 'March', 'April', 'May', 'June', 'July',
        'August', 'September', 'October', 'November', 'December'];
    last=document.lastModified;
    d=new Date(last);
    lastUpdate="Last updated on "+days[d.getDay()]+' the '+
        d.getDate()+nths(d.getDate())+" of "+ months[d.getMonth()]+", "+
        d.getFullYear()+".";
    return lastUpdate;
}

function buildFooter(){
    var footer=document.getElementById('footer');
    footer.innerHTML="<a href='#'>Top</a>" + " | " +
        "<a href='/~aottenbe/admin/siteMap.htm'>Site Map</a> | "  +
        "<a href='http://www.gc.maricopa.edu/Disclaimer.html'>Legal Disclaimer</a><br />" +
        "Maintained by Alicia K. Ottenberg. " + getLastModified();
}

function showDate(){
    var dateEl=document.getElementById('date');
    var d=new Date();
    dateEl.innerHTML=d.toLocaleDateString();
}   

/*javascript for Bubble Tooltips by Alessandro Fulciniti
- http://pro.html.it - http://web-graphics.com */

function enableTooltips(id){
    var links,i,h;
    
    if(!document.getElementById || !document.getElementsByTagName){ 
        return; 
    }
    // AddCss();
    h=document.createElement("span");
    h.id="btc";
    h.setAttribute("id","btc");
    h.style.position="absolute";
    document.getElementsByTagName("body")[0].appendChild(h);
    if(id===null) { 
        links=document.getElementsByTagName("a");
    }
    else {
        links=document.getElementById(id).getElementsByTagName("a");
    }
    for(i=0;i<links.length;i++){
        Prepare(links[i]);
    }
}

function Prepare(el){
    var tooltip,t,b,s,l;
    t=el.getAttribute("title");
    if (!t){ 
        return; 
    }
    if(t===null || t.length===0){ 
        t="link:"; 
    }
    el.removeAttribute("title");
    tooltip=CreateEl("span","tooltip");
    s=CreateEl("span","top");
    s.appendChild(document.createTextNode(t));
    tooltip.appendChild(s);
    b=CreateEl("b","bottom");
    l=el.getAttribute("href");
    //AKO ADDED IF 8-9-08
    if (l){
         if(l.length>30){ 
            l=l.substr(0,27)+"...";
         }
         b.appendChild(document.createTextNode(l));
         tooltip.appendChild(b);
         setOpacity(tooltip);
         el.tooltip=tooltip;
         el.onmouseover=showTooltip;
         el.onmouseout=hideTooltip;
         el.onmousemove=Locate;
    }
}

function showTooltip(e){
    document.getElementById("btc").appendChild(this.tooltip);
    Locate(e);
}

function hideTooltip(e){
    var d=document.getElementById("btc");
    if(d.childNodes.length>0){ d.removeChild(d.firstChild); }
}

function setOpacity(el){
    el.style.filter="alpha(opacity:95)";
    el.style.KHTMLOpacity="0.95";
    el.style.MozOpacity="0.95";
    el.style.opacity="0.95";
}

function CreateEl(t,c){
    var x=document.createElement(t);
    x.className=c;
    x.style.display="block";
    return(x);
}

function AddCss(){
    var l=CreateEl("link");
    l.setAttribute("type","text/css");
    l.setAttribute("rel","stylesheet");
    l.setAttribute("href","bt.css");
    l.setAttribute("media","screen");
    document.getElementsByTagName("head")[0].appendChild(l);
}

function Locate(e){
    var posx=0,posy=0;
    if(!e) {e=window.event;}
    if(e.pageX || e.pageY){
        posx=e.pageX; posy=e.pageY;
        }
    else if(e.clientX || e.clientY){
        if(document.documentElement.scrollTop){
            posx=e.clientX+document.documentElement.scrollLeft;
            posy=e.clientY+document.documentElement.scrollTop;
            }
        else{
            posx=e.clientX+document.body.scrollLeft;
            posy=e.clientY+document.body.scrollTop;
            }
        }
    document.getElementById("btc").style.top=(posy+10)+"px";
    document.getElementById("btc").style.left=(posx-20)+"px";
} /* End Bubble Tooltips */


// Splintered striper 1.3
// reworking of Zebra Tables and similar methods which works not only for tables and even/odd rows,
// but as a general DOM means of assigning any number of classes to children of a parent element.
// Patrick H. Lauke aka redux / www.splintered.co.uk
// Distributed under the Creative Commons Attribution-ShareAlike license - http://creativecommons.org/licenses/by-sa/2.0/


/*
 * Summary:      Core experiment function that applies any number of classes to all child elements
 *               contained in all occurences of a parent element (either with or without a specific class)
 * Parameters:   parentElementTag - parent tag name
 *               parentElementClass - class assigned to the parent; if null, all parentElementTag elements will be affected
 *               childElementTag -  tag name of the child elements to apply the styles to
 *               styleClasses - comma separated list of any number of style classes (using 2 classes gives the classic "zebra" effect)
 * Return:       none
 */
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses)
{
    var i=0,currentParent,currentChild;
    // capability and sanity check
    if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {
        // turn the comma separate list of classes into an array
        var styles = styleClasses.split(',');
        // get an array of all parent tags
        var parentItems = document.getElementsByTagName(parentElementTag);
        // loop through all parent elements
        while (currentParent = parentItems[i++]) {
            // if parentElementClass was null, or if the current parent's class matches the specified class
            if ((parentElementClass === null)||(currentParent.className == parentElementClass)) {
                var j=0,k=0;
                // get all child elements in the current parent element
                var childItems = currentParent.getElementsByTagName(childElementTag);
                // loop through all child elements
                while (currentChild = childItems[j++]) {
                    // based on the current element and the number of styles in the array, work out which class to apply
                    k = (j+(styles.length-1)) % styles.length;
                    // add the class to the child element - if any other classes were already present, they're kept intact
                    currentChild.className = currentChild.className+" "+styles[k];
                }
            }
        }
    }
    }	

//--------------------------------------------------------------------------
//
//   Zooming link script by Paul Anderson, copyright 2001 CNET Builder.com.
//   May be freely used with attribution. Not for resale. All rights reserved. 
//   Make a link zoom open by adding the event handler
//   
//   onclick="zoomBox(event,this);return false"
//   
//   To zoom into a new, positioned window add width, height, left, and top
//   
//   onclick="zoomBox(event,this,640,480,100,50);return false"
// old values - zoomBox(event,this,650,500,10,10,0);return false   8/13/09
//--------------------------------------------------------------------------

function zoomZoom(){
		//,fromX,fromY,toX,toY
var maxW,maxH,fromX,fromY,toX,toY,adjX,adjY,zBox,zLink,zNew,showModal,winArg,
zStep=0;

    var zZoomers = getElementsByClassName('zoomer');
    for(var i=0;i<zZoomers.length;i++){
		zZoomers[i].onclick=zoomBox;
	}
    // addEvent(zZoomers, "click", zoomBox);

    function getScrollXY() {
      var scrOfX = 0, scrOfY = 0;
      if( typeof( window.pageYOffset ) == 'number' ) {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
      } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
      }
      return [ scrOfX, scrOfY ];
    }

    // evt,zlink,maxw,maxh,tox,toy,modal,arg
    function zoomBox(e) {
    // evt,
    var zlink,maxw=650,maxh=500,tox=50 ,toy=50,modal=1,arg;
    var evt = e || window.event;
    var tg = evt.target || evt.srcElement;

    showModal=modal;
    winArg=arg;
    // if (arguments.length > 2){ zNew=1; }
    zNew=1;
    var a = [], x, y; 
    a = getScrollXY();
    var scrollH = a[1];
    // scrollH=(window.pageYOffset!==null)?window.pageYOffset:document.body.scrollTop;
        // And stop the actual click happening
        if (window.event) {
          window.event.cancelBubble = true;
          window.event.returnValue = false;
        }
        if (e && e.preventDefault && e.stopPropagation) {
          e.preventDefault();
          e.stopPropagation();
        }
        
    maxW=maxw?maxw:window.innerWidth?innerWidth:document.body.clientWidth;
    maxH=maxh?maxh:window.innerHeight?innerHeight:document.body.clientHeight;
    toX=tox?tox:0;
    toY=(toy?toy:0)+scrollH;
    fromX=evt.pageX?evt.pageX:evt.clientX;
    fromY=(evt.pageY?evt.pageY:evt.clientY)+(document.all?scrollH:0);
    adjX=toX+evt.screenX-fromX;
    adjY=toY+evt.screenY-fromY;    
    zLink=this;
    if (document.createElement && document.body.appendChild && !zBox) {
        zBox=document.createElement("div");
        zBox.style.position="absolute";
        document.body.appendChild(zBox);
    }

    doZoom();
    }

    function doZoom() {
       zStep+=1;	
       zBox.style.display='block';

        if (zStep < 10) { 
                 
            zPct=(10-zStep)/10;
            zBox.style.border="2px solid #999999";
            zBox.style.left=toX+zPct*(fromX-toX);
            zBox.style.top=toY+zPct*(fromY-toY);
            zBox.style.width=maxW*(1-zPct);
            zBox.style.height=maxH*(1-zPct);
            zStep += 1;  
            setTimeout(doZoom, 50); 
        }
        else {
             zBox.style.display='none';
            zStep=0;
            if (zLink && !zNew) { 
                location.href=zLink.href;
            }
            else if (zLink && zNew) {
                if (showModal === 0){
                var w;
                  w=window.open(zLink.href,'','width='+maxW+',height='+maxH+',left='+adjX+',top='+adjY+',scrollbars,resizable');
                }
                else {
                  maxW+=20;
                  maxH+=40;
                  w=window.showModalDialog(zLink.href,winArg,'dialogWidth='+maxW+'px;dialogHeight='+maxH+'px;dialogLeft='+adjX+'px;dialogTop='+adjY+'px;status=no;resizable=yes');
                }
                zNew=null;
            }

          }
    }
}
/* end zoom link */


function calcTimeTable(initDate, numDays, occurences) {
    var startDate = new Date(initDate);
    var msStartDate = startDate.getTime();
    var msWk = 1000 * 60 * 60 * 24 * numDays;
    var wk, nextDate, startDates = new Array(occurences);
    
    for(wk=0;wk<occurences;wk++){
        startDates[wk] = new Date(msStartDate + msWk * wk);
    }
    return startDates;
}
        
HttpRequest.prototype.createXmlHttpRequest = function () {
    var oHttp = false;   // no support

    if (window.XMLHttpRequest) {
        oHttp = new XMLHttpRequest(); // IE 7 and all other browsers XMLHttpRequest is a native object
    } 
    else if (window.ActiveXObject) {  // IE 6 and earlier XMLHttpRequest is an ActiveX object
        var versions =         // all possible names for ActiveX object
        [
            "MSXML3.XMLHTTP",  // which one is supported depends on the user's windows configuration, not on the browser
            "MSXML2.XMLHTTP",
            "MICROSOFT.XMLHTTP"
        ];
        for (var i = 0; i < versions.length; i++) {
            try {
                oHttp = new ActiveXObject(versions[i]);		// try each ActiveX version		                     
            } 
            catch (e) {
              continue;  
            }
            break; 
        } 
    }       
    return oHttp; 
};
         
function HttpRequest(sUrl, fpCallback, postData) {
    this.request = this.createXmlHttpRequest();

    if(this.request) {
      var method = (postData) ? "POST" : "GET";
      
      // open a new request, which means preparing it for sending
      this.request.open(method, sUrl, true);
      // enable server-side programs to determine type of request
      this.request.setRequestHeader('User-Agent', 'XMLHTTP'); 

      if(postData) {
        this.request.setRequestHeader('Content-type', 
            'application/x-www-form-urlencoded');        
      }    

      var tempRequest = this.request;

      function request_readystatechange() {
        if (tempRequest.readyState === 4) { // all data has been received
        
            // status code server returns, 200 is ok, 304 is NOT Modifed (Opera)
            if (tempRequest.status === 200 || tempRequest.status === 304) {  
                 fpCallback(tempRequest.responseText);
            } 
            else {
                alert("An error occurred while attempting to contact the " + 
                       "server." + ' Request.status = ' + tempRequest.status );
            }
        } // end if readyState == 4
      }  // end function request_readystatechange 
        this.request.onreadystatechange = request_readystatechange; 
    } // end if(this.request)
} // end function HttpRequest

HttpRequest.prototype.send = function (postData) {

  if (this.request.readyState != 4) { 
    // sends request with postData (either POST data or null) as the argument.
    this.request.send(postData);  
  }
};

function getHttpData(fileURL,fpCallback){
    var myRequest=new HttpRequest(fileURL,fpCallback);
    myRequest.send(null);
}

function courseData(sResponseText){
    var newHTML=sResponseText;
    document.getElementById('subNav').innerHTML=newHTML;
    createMenu();
}

function messageData(sResponseText){
    var newHTML=sResponseText;
    var messageBox=document.getElementById('messages');
    var messageList=eval("("+sResponseText+")");
    for(i in messageList.alerts){
        messageBox.innerHTML+="<div class='alert'>"+"<img src='/~aottenbe/images/alert.jpg' width='68' height='68' alt='exclamation icon' />"+"<p>"+
        messageList.alerts[i].message+"</p>"+"</div>";
    }
    for(j in messageList.infos){
        messageBox.innerHTML+="<div class='info'>"+"<img src='/~aottenbe/images/info.jpg' width='68' height='68' alt='information icon' />"+"<p>"+
        messageList.infos[j].message+"</p>"+"</div>";
    }
}

function officeData(sResponseText){
    var newHTML=sResponseText;
    document.getElementById('office').innerHTML=newHTML;
}

function setupEvents() {
    var url = getDataFileURL();
    getHttpData(url, listDueDates);
    return false;
}

function listStartDates(sResponseText){
    var numDays = 7;
    var dueDateData=eval("("+sResponseText+")");
    var semEl=document.getElementById('startSem');
    var startDatesEL=document.getElementById('startDates');
    var numStarts = dueDateData.due.length;  
    var dueDates = calcTimeTable(dueDateData.start, numDays, numStarts);
        
    semEl.innerHTML=dueDateData.sem + " semester, " + dueDateData.yr;

    for(var x= 0; x<dueDates.length; x++) {
        var newOpt = new Option(dueDates[x].toLocaleDateString(), x + 1);
        startDatesEL.options[x] = newOpt;
    }

    startDatesEL.selectedIndex=-1;
    addEvent(startDatesEL, 'change', setupEvents);
    }

function listDueDates(sResponseText) {
    var numDays = 7;
    var dueDateData=eval("("+sResponseText+")");
    var wkSelectedEl = document.getElementById('wkSelected');
    var dueDataEl = document.getElementById('dueData');
    var startDatesEl = document.getElementById('startDates');
    var weekNumEl = document.getElementById('weekNum');	
    var idx = startDatesEl.selectedIndex;
    var opt = startDatesEl.options[idx];
    var numWeeks = dueDateData.due[idx].length;
    var dueDates = calcTimeTable(dueDateData.firstDue, numDays, numWeeks);  
    var timeTableCapEL = document.getElementById('timeTableCap');

    weekNumEl.innerHTML= opt.value;
    wkSelectedEl.innerHTML=opt.text;
    timeTableCapEL.innerHTML="Schedule for Week " + opt.value + " Start Date";
        
    while(dueDataEl.childNodes[0]) {
        dueDataEl.removeChild(dueDataEl.childNodes[0])
    }

    for (var j=0; j < numWeeks; j++) {
        var row = document.createElement('tr');

        var cell1 = document.createElement('td');
        var text1 = document.createTextNode(j + 1);
        cell1.appendChild(text1);
        row.appendChild(cell1);
        
        var cell2 = document.createElement('td');
        var text2 = document.createTextNode(dueDates[j].toDateString());
        cell2.appendChild(text2);
        row.appendChild(cell2);
        
        var cell3 = document.createElement('td');
        var text3 = document.createTextNode(dueDateData.due[idx][j]);
        cell3.appendChild(text3);
        row.appendChild(cell3);

        dueDataEl.appendChild(row);
    }
    striper('tbody', 'striped', 'tr', 'odd, even');
}

function getDataFileURL() {
    var docId = document.getElementById('docId');
    var url;

    if(docId){
        docId.className="hiddenPic";
        
        switch(docId.innerHTML){ 
        case'W1_2003':
            // url = "http://localhost/dueDatesW1.txt";
            url = "http://web.gccaz.edu/~aottenbe/Text/dueDatesW1.txt";
        break;
        case'W1_2007':
            // url = "http://localhost/dueDatesW1.txt";
            url = "http://web.gccaz.edu/~aottenbe/Text/dueDatesW1.txt";				
        break;
        case'W2_2003':
            // url = "http://localhost/dueDatesW2_2003.txt";
            url = "http://web.gccaz.edu/~aottenbe/Text/dueDatesW2_2003.txt";
            
        break;
        case'W2_2007':
            // url = "http://localhost/dueDatesW2_2007.txt";	
            url = "http://web.gccaz.edu/~aottenbe/Text/dueDatesW2_2007.txt";								
        break;
        }
        
    }
    return url;
}

var ss = {
    fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
        ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
    },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeName.toLowerCase() != 'a') {
      target = target.parentNode;
    }
  
    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;
  
    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    if (!destinationLink) destinationLink = document.getElementById(anchor);

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;
  
    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }
  
    // Stop any current scrolling
    clearInterval(ss.INTERVAL);
  
    cypos = ss.getCurrentYPos();
  
    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL =
    setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);
  
    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;
    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
};

ss.STEPS = 50;
  
window.onload = function () {
    var datafile;

    getHttpData("http://web.gccaz.edu/~aottenbe/Text/courseList.txt", courseData);
    getHttpData("http://web.gccaz.edu/~aottenbe/Text/messages.txt", messageData);
    getHttpData("http://web.gccaz.edu/~aottenbe/Text/hrs.txt", officeData);    
    
//   getHttpData("http://localhost/courseList.txt", courseData); 
//    getHttpData("http://localhost/messages.txt", messageData);
//    getHttpData("http://localhost/hrs.txt", officeData);

    showDate();
    buildFooter();
    clickExpand();
    changeExpand();
    striper('tbody','striped','tr','odd,even');
    enableTooltips('primaryContent');
    ss.fixAllLinks();
    zoomZoom();
    datafile = getDataFileURL();
    if(datafile) {
        getHttpData(datafile, listStartDates);
    }
  
};










