﻿

function identifyCurrPage() {
    var divCurr
    if (window.location.pathname.toLowerCase().indexOf('index.shtml') > -1 || window.location.pathname == '/')
        divCurr = document.getElementById('divNavHome')
  
    else if (window.location.pathname.toLowerCase().indexOf('aboutus.shtml') > -1)
        divCurr = document.getElementById('divNavAbout')
    else if (window.location.pathname.toLowerCase().indexOf('programmes.shtml') > -1)
        divCurr = document.getElementById('divNavProgrammes')
    else if (window.location.pathname.toLowerCase().indexOf('publications.shtml') > -1)
        divCurr = document.getElementById('divNavPublications')
    else if (window.location.pathname.toLowerCase().indexOf('charges.shtml') > -1)
        divCurr = document.getElementById('divNavCharges')
    else if (window.location.pathname.toLowerCase().indexOf('contactus.shtml') > -1)
        divCurr = document.getElementById('divNavContact')
    else
        return

    if (divCurr) {
        divCurr.style.background = 'url(picture_library/btnMenu_b.gif) no-repeat'
    }


}


function btnMenu_onmouseover() {
    if (!((this.id == 'divNavHome' && (window.location.pathname.toLowerCase().indexOf('index.shtml') > -1 || window.location.pathname == '/'))
    
        || (this.id == 'divNavAbout' && window.location.pathname.toLowerCase().indexOf('aboutus.shtml') > -1)
        || (this.id == 'divNavProgrammes' && window.location.pathname.toLowerCase().indexOf('programmes.shtml') > -1)
        || (this.id == 'divNavPublications' && window.location.pathname.toLowerCase().indexOf('publications.shtml') > -1)
        || (this.id == 'divNavCharges' && window.location.pathname.toLowerCase().indexOf('charges.shtml') > -1)
        || (this.id == 'divNavContact' && window.location.pathname.toLowerCase().indexOf('contactus.shtml') > -1))) 
        {
            this.style.background = 'url(picture_library/btnMenu_b.gif) no-repeat'
        }

}

function btnMenu_onmouseout() {
    if (!((this.id == 'divNavHome' && (window.location.pathname.toLowerCase().indexOf('index.shtml') > -1 || window.location.pathname == '/'))
        
        || (this.id == 'divNavAbout' && window.location.pathname.toLowerCase().indexOf('aboutus.shtml') > -1)
        || (this.id == 'divNavProgrammes' && window.location.pathname.toLowerCase().indexOf('programmes.shtml') > -1)
        || (this.id == 'divNavPublications' && window.location.pathname.toLowerCase().indexOf('publications.shtml') > -1)
        || (this.id == 'divNavCharges' && window.location.pathname.toLowerCase().indexOf('charges.shtml') > -1)
        || (this.id == 'divNavContact' && window.location.pathname.toLowerCase().indexOf('contactus.shtml') > -1))) 
        {
            this.style.background = 'url(picture_library/btnMenu_a.gif) no-repeat'
    }

}

function writeEmail(strPart) {

    switch (strPart) {
        case 'jeff':
            document.write('<a href="mailto:')
            writeEmail('jeff2')
            break
        case 'jeff2':
            document.write('jeff')
            writeEmail('jeff3')
            break
        case 'jeff3':
            document.write('cohen')
            writeEmail('jeff4')
            break
        case 'jeff4':
            document.write('@tisc')
            writeEmail('jeff5')
            break
        case 'jeff5':
            document.write('ali.co.uk')
            writeEmail('jeff6')
            break
        case 'jeff6':
            document.write('">jeff')
            writeEmail('jeff7')
            break
        case 'jeff7':
            document.write('cohen')
            writeEmail('jeff8')
            break
        case 'jeff8':
            document.write('@tisc')
            writeEmail('jeff9')
            break
        case 'jeff9':
            document.write('ali.co.uk</a>')
            break
    }
}

function writePhone(strPart) {

    switch (strPart) {
        case 'mob':
            document.write('79')
            writePhone('mob2')
            break
        case 'mob2':
            document.write('198')
            writePhone('mob3')
            break
        case 'mob3':
            document.write('938')
            writePhone('mob4')
            break
        case 'mob4':
            document.write('79')
    }
}


function addLoadEvent(func) {

    var funcOnloadOld = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            if (funcOnloadOld) {
                funcOnloadOld();
            }
            func();
        }
    }
}

addLoadEvent(identifyCurrPage)
