



  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
    
  


/*
Functions for the Text Resizing buttons in the top bar of the common template
*/

function setSize(iSize)
{
    if(!document.getElementsByTagName)
        return false;
    var bodyTag = document.getElementsByTagName("body");
    for(var i=0; i < bodyTag.length; i++)
    {
        if(!bodyTag[i].style.fontSize)
        {
            if(!readCookie("UoB-textSize") || iSize == 'reset')
                bodyTag[i].style.fontSize = "80%";
            else
                bodyTag[i].style.fontSize =((parseFloat(readCookie("UoB-textSize"))) + "%");
        }
        else
        {
            if(!readCookie("UoB-textSize") || iSize == 'textnormal')
                bodyTag[i].style.fontSize = "80%";
            else if(iSize == 'textlarge')
                bodyTag[i].style.fontSize = "90%";
            else if(iSize == 'textlargest')
                bodyTag[i].style.fontSize = "100%";
            else if((iSize.charAt(0) == '+' && parseFloat(readCookie("UoB-textSize")) < 100) ||
                    (iSize.charAt(0) == '-' && parseFloat(readCookie("UoB-textSize")) > 60))
                bodyTag[i].style.fontSize = (((parseFloat(iSize)) + (parseFloat(readCookie("UoB-textSize")))) + "%");
        }
        var cookieValue = bodyTag[i].style.fontSize;
        writeCookie("UoB-textSize", cookieValue, 168);
    }
    return false;
}
function initResizeButton(id)
{    
    if(document.getElementById && document.getElementById(id))
    {
        var link = document.getElementById(id);
        link.onclick = function() { 
          pageTracker._trackPageview('/'+id+'/'+ document.location);
          setSize(id); 
          return false; 
        }
    }
    return false;
}
function writeCookie(name, value, hours)
{
    var expire = "";
    if(hours != null)
    {
        expire = new Date((new Date()).getTime() + hours * 3600000);
        expire = "; expires=" + expire.toGMTString();
    }
    document.cookie = name + "=" + escape(value) + expire + '; path=/';
}
function readCookie(name)
{
    var cookieValue = "";
    var search = name + "=";
    if(document.cookie && document.cookie.length > 0)
    {
        var offset = document.cookie.indexOf(search);
        if(offset != -1)
        {
            offset += search.length;
            var end = document.cookie.indexOf(";", offset);
            if(end == -1)
                end = document.cookie.length;
            var cookieValue = unescape(document.cookie.substring(offset, end))
        }
    }
    return cookieValue;
}

/*
Functions for the expading menus in the left column of the common template
*/

$(document).ready(function() {

    $("dd > ul > li").each(function() {
            
        // add the "submenu" class to each <li> if it has a list under it
        if ($(this).children("ul").length > 0) {
            $(this).addClass("submenu");
            
            // get all <a> elements immediately after the <li> and add a click event for toggling the menu state
            $(this).children("a").click(function(event){
                event.preventDefault();
                $(this).parent().toggleClass("open");
            });
        }

        // open anything the CMS has chosen to highlight
        $(this).find("a.highlight").parents("li.submenu").addClass("open");

    });
    
    // Text resize buttons
    initResizeButton("textnormal", "textnormal");
    initResizeButton("textlarge", "textlarge");
    initResizeButton("textlargest", "textlargest");
    setSize("80%");
});

// CSS for expanding menus
document.write("<style type='text/css'>\n#leftcol dd ul li ul {display:none}\n#leftcol dd ul li.submenu ul {display:none}\n#leftcol dd ul li.submenu a {background-image:url(/common/jsp/arrow.gif?p=36c);background-position:191px 4px;background-repeat:no-repeat;padding-right:12px;width:185px}\n#leftcol dd ul li.submenu a:hover {background:#cde url(/common/jsp/arrow.gif?p=36c) 191px 4px no-repeat}\n#leftcol dd ul li.submenu.open > a {background-image:url(/common/jsp/arrow.gif?p=36c&d=down);background-position:188px 10px;background-repeat:no-repeat;padding-right:12px;width:185px}\n#leftcol dd ul li.submenu.open ul li a {padding-right:0}\n#leftcol dd ul li.submenu.open > a:hover {background:#cde url(/common/jsp/arrow.gif?p=36c&d=down) 188px 10px no-repeat}\n#leftcol dd ul li ul.static {display:block}\n#leftcol dd ul li.submenu.open ul {display:block}</style>");
