
// Array Function

function makeArray() {
var args = makeArray.arguments;
    for (var i = 0; i < args.length; i++) {
    this[i] = args[i];
    }
this.length = args.length;
}

// This array holds the titles of the pages.

var choices = new makeArray("select a section of the site",
						  "---------------------------------------",
                          "About Information Management Associates",
						  "Briefing Notes on information management",
						  "IMA Articles, Evaluations and Reports",
                          "Best Value &amp; better performance in Libraries",
                          "School Library Self-evaluation Model",
                          "IMA Publications: List and Order Form",
                          "---------------------------------------",
                          "Feedback Form and IMA Contact Details");

// This array hold the URLs of the pages.

var urls = new makeArray("",
						  "#",
                          "aboutmen.html",
						  "notesmen.html",
						  "articmen.html",
                          "bstvlmen.html",
                          "/schoollibraries/",
                          "publish.html",
                          "#",
                          "imafdbk.html");

// This function determines which page is selected and goes to it.

function goPage(form) {
i = form.section.selectedIndex;            
    if (i != 0) {
    location.href = urls[i];  
    }
}

// This function is for addendum popup windows

function open_window(url) {
addenda = window.open(url,"addendawin",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=600,height=300');
	if (addenda.opener == null) addenda.opener = window;
addenda.opener.name = "opener";
}


// functions for school library comment forms

function getLabelForId(id) {
    var label, labels = document.getElementsByTagName('label');
    for (var i = 0; (label = labels[i]); i++) {
        if (label.htmlFor == id) {
            return label;
        }
    }
    return false;
}
function checkEmail() {
    var email = document.getElementById('email');
    var label = getLabelForId('email');
    if (email.value.indexOf('@') != -1 &&
    	email.value.indexOf('.') != -1 && email != '') { 
        label.className = 'completed';
    } else {
        label.className = 'problem';
    }
}
function checkRequired(id) {
    var formfield = document.getElementById(id);
    var label = getLabelForId(id);
    if (formfield.value.length == 0) {
        label.className = 'problem';
    } else {
        label.className = 'completed';
    }
}

addEvent(window, 'load', function() {
    var input;
    var inputs = document.getElementsByTagName('input');
    for (var i = 0; (input = inputs[i]); i++) {
        addEvent(input, 'focus', oninputfocus);
        addEvent(input, 'blur', oninputblur);
    }
    var textareas = document.getElementsByTagName('textarea');
    for (var i = 0; (textarea = textareas[i]); i++) {
        addEvent(textarea, 'focus', oninputfocus);
        addEvent(textarea, 'blur', oninputblur);
    }
});
function oninputfocus(e) {
    /* Cookie-cutter code to find the source of the event */
    if (typeof e == 'undefined') {
        var e = window.event;
    }
    var source;
    if (typeof e.target != 'undefined') {
        source = e.target;
    } else if (typeof e.srcElement != 'undefined') {
        source = e.srcElement;
    } else {
        return;
    }
    /* End cookie-cutter code */
    source.style.border='2px solid #666';
}
function oninputblur(e) {
    /* Cookie-cutter code to find the source of the event */
    if (typeof e == 'undefined') {
        var e = window.event;
    }
    var source;
    if (typeof e.target != 'undefined') {
        source = e.target;
    } else if (typeof e.srcElement != 'undefined') {
        source = e.srcElement;
    } else {
        return;
    }
    /* End cookie-cutter code */
    source.style.border='2px solid #ccc';
}
function addEvent(obj, evType, fn){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, true);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}