function w(s) {document.writeln(s)}

function nh( name, html, highlight )
{
    w('<td width=80 height=30 align=center><a href="' + html + '">&nbsp;' + name + '</a></td>')
}

function nv( name, html, highlight )
{
    w('<tr valign=middle align=left>')
//    if ( highlight || gMenuItem == name || gSubCategory == name )
//    {
//       w('<td width=125 height=25><span class="nav2"><a href="' + html + '">&nbsp;' + name + '</a></span></td>')
//    }
//    else
//    {
       w('<td width=125 height=25><a href="' + html + '">&nbsp;' + name + '</a></td>')
//    }
    w('</tr>')
    w('<tr valign=middle align=left>')
}

function nv2( parent, name, html, highlight )
{
    if ( gSubCategory == parent || gMenuItem == parent )
    {
        w('<tr valign=middle align=left>')
        if ( highlight || gMenuItem == name )
        {
           w('<td width=125 height=17><span class="nav2"><a href="' + html + '">&nbsp;&nbsp;&nbsp;' + name + '</a></span></td>')
        }
        else
        {
           w('<td width=125 height=17><a href="' + html + '">&nbsp;&nbsp;&nbsp;' + name + '</a></td>')
        }
        w('</tr>')
        w('<tr valign=middle align=left>')
    }
}

function header( title, parent, parenthtml, parent2, parent2html )
{
    gTitle = title
    gParent = parent
    gParenthtml = parenthtml
    gParent2 = parent2
    gParent2html = parent2html

    w('<body bgcolor="#000000" text="#ffffff" link="#0000ff" vlink="#800080" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>')
    w('<table border=0 cellspacing=0 cellpadding=0 width=930 summary=banner>')
    w('<tr valign=top align=left>')
    w('<td height=50 bgcolor="#000000" align=center valign=middle><span class="banner"><a href=./>Andrew Trevor-Jones Nature Photography</a></span></td>')
    w('</tr>')
    w('</table>')

    w('<div class="nav">')
    w('<table border=0 cellspacing=0 cellpadding=0 width=930 summary=navigator>')
    w('<tr valign=top align=left>')
    w('<td height=22 width=800>')

    w('<table id="navigationbar2" border=0 cellspacing=0 cellpadding=0 width=800 summary=navigator>')
    w('<tr valign=middle align=left>')
    w('<td width=80 height=30 align=center>&nbsp;</td>')
    w('<td width=40 height=30 align=center><a href=./aboutme.html>&nbsp;About</a></td>')
    w('<td width=40 height=30 align=center><a href=./blog.html>&nbsp;Blog</a></td>')
    w('<td width=40 height=30 align=center><a href=./feedback.html>&nbsp;Feedback</a></td>')
    w('<td width=40 height=30 align=center><a href=./galleries.html>&nbsp;Galleries</a></td>')
    w('<td width=40 height=30 align=center><a href=./publications.html>&nbsp;Publications</a></td>')
    w('<td width=40 height=30 align=center><a href=./copyright.html>&nbsp;Purchase</a></td>')
    w('</tr>')
    w('</table>')

    w('</td>')
    w('</tr>')
    w('</table>')
    w('</div>')

//--------------------------------------------------------------------------------------------

    w('<table cellpadding=0 cellspacing=0 border=0 width=930 summary=navigator>')
    w('<tr valign=top align=left>')
    w('<td>')

    w('<div class="nav">')

    w('<table border=0 cellspacing=0 cellpadding=0 width=60 summary=navigator>')
    w('<tr valign=top align=left>')
    w('<td height=3></td>')
    w('</tr>')
    w('<tr valign=top align=left>')
    w('<td height=150 width=10>')

    w('<table id="verticalnavigationbar1" border=0 cellspacing=1 cellpadding=0 width=60 summary=navigator>')
    w('</table>')

    w('</td>')
    w('</tr>')
    w('</table>')

    w('</div>')

    w('</td>')
    w('<td>')
    w('<table border=0 cellspacing=0 cellpadding=0 width=800 summary=content>')

    w('<tr valign=top align=left>')
    w('<td height=3></td>')
    w('</tr>')
    w('<tr valign=top align=left>')
    w('<td height=366 width=600><div id="externalhtml1color">')
    w('<table border=0 width=800 summary=content>')

//    if ( parent != '' )
//    {
//        w('<tr align=left valign=top>')
//        w('<td align=left><p><button type=button title="Previous" id="Previous" onclick="javascript:prev()">Previous</button></td>' );
//        w('<td align=centre><p><button type=button title="Up" id="Up" onclick="javascript:up()">Up</button></td>' );
//        w('<td align=right><p><button type=button title="Next" id="Next" onclick="javascript:next()">Next</button></td>' );
//    }

    if ( typeof title != 'undefined' )
    {
        if ( typeof parent2 != 'undefined' )
        {
            w('<tr align=left valign=top>')
            w('<td align=right width=200>&nbsp;</td>' );
            w('<td align=center width=400><span class="navl"><a href="./' + parent2html + '">' + parent2 + '</a></span></td>' );
            w('<td align=left width=200>&nbsp;</td>' );
            w('</tr>')
        }

        if ( title == parent )
        {
            recent = false;
//            window.alert( document.location.search );
            if (document.location.search == "?recent")
            {
                htmlfiles = recenthtmlfiles;
                numhtmlfiles = numrecenthtmlfiles;
                recent = true;
            }
            url = new String (document.location.pathname);
//            window.alert( url );
            filename = url.substr( Math.max( url.lastIndexOf( '/'), url.lastIndexOf( '\\')) + 1 );
//            filename = url.substr( url.lastIndexOf( '/') + 1 );
//            window.alert( filename );
            numhtmlfiles--;

            var i;
            i = 0;

            while ( i < numhtmlfiles && htmlfiles[i] != filename )
            {
                i++;
            }

            nextentry = i + 1;

            if (nextentry >= numhtmlfiles)
                nextentry = 0;

            preventry = i - 1;

            if (preventry < 0)
                preventry = numhtmlfiles - 1;

            w('<tr align=left valign=top>');
            w('<td align=center valign=bottom width=200>');
            if ( preventry == i )
                w('&nbsp;' );
            else
                if (recent)
                    w('<span class="navl"><a href=./' + htmlfiles[preventry] + '?recent>Previous</a></span>');
                else
                    w('<span class="navl"><a href=./' + htmlfiles[preventry] + '>Previous</a></span>');
            w('</td>' );
            if (i >= 12)
            {
                pagenumber = parseInt((i/12)+1);
                parenthtmlstring = new String( parenthtml);
                newparenthtml = parenthtmlstring.substring(0, parenthtmlstring.indexOf('.html')) + pagenumber + '.html';
                w('<td align=center width=400><span class="titlelink"><a href=./' + newparenthtml + '>' + parent + ' ' + pagenumber + '</a></span></td>' );
            }
            else
            {
                w('<td align=center width=400><span class="titlelink"><a href="./' + parenthtml + '">' + title + '</a></span></td>' );
            }
            w('<td align=center valign=bottom width=200>');
            if ( nextentry == i )
                w('&nbsp;' );
            else
                if (recent)
                    w('<span class="navl"><a href=./' + htmlfiles[nextentry] + '?recent>Next</a></span>');
                else
                    w('<span class="navl"><a href=./' + htmlfiles[nextentry] + '>Next</a></span>');
            w('</td>' );
            w('</tr>')
        }
        else
        {
            if ( typeof parent != 'undefined' )
            {
                w('<tr align=left valign=top>');
                w('<td align=center width=200>&nbsp;</td>' );
                w('<td align=center width=400><span class="navl"><a href="./' + parenthtml + '">' + parent + '</a></span></td>' );
                w('<td align=center width=200>&nbsp;</td>' );
                w('</tr>');
            }
            numhtmlfiles--;

            var i;
            i = 0;

            while ( i < numhtmlfiles && htmlfiles[i] != title )
            {
                i++;
                i++;
            }

            nextentry = i + 2;

            if (nextentry >= numhtmlfiles)
                nextentry = 0;

            preventry = i - 2;

            if (preventry < 0)
                preventry = numhtmlfiles - 2;

            w('<tr align=left valign=top>');
            w('<td align=center valign=bottom width=200>');
            if ( preventry == i )
                w('&nbsp;' );
            else
                w('<span class="navl"><a href=./' + htmlfiles[preventry+1] + '>' + htmlfiles[preventry] + '</a></span>' );
            w('</td>' );
            w('<td align=center valign=bottom width=400><span class="title1">' + title + '</span></td>' );
            w('<td align=center valign=bottom width=200>');
            if ( nextentry == i )
                w('&nbsp;' );
            else
                w('<span class="navl"><a href=./' + htmlfiles[nextentry+1] + '>' + htmlfiles[nextentry] + '</a></span>' );
            w('</td>' );
            w('</tr>')
        }
    }
}

function footer( )
{
    w('</td>')
    w('</tr>')
    w('</table>')
    w('</div></td>')
    w('</tr>')
    w('</table>')
    w('<table border=0 cellspacing=0 cellpadding=0 summary=navigator>')
    w('<tr valign=top align=left>')
    w('<td nowrap>')
    w('</td>')
    w('</tr>')
    w('</table>')
    w('</td>')
    w('</tr>')
    w('</table>')
    w('<table border=0 cellspacing=0 cellpadding=0 width=744 summary=formatting>')
    w('<tr valign=top align=left>')
    w('<td width=80>&nbsp;</td>')
    w('<td width=600>')
    w('<p align=left><span class=lnk><a href=./copyright.html>&#169; Copyright 2007-2010 Andrew Trevor-Jones</a></span></p>')
    w('</td>')
    w('</tr>')
    w('</table>')
    w('</body>')

}

function prev()
{
    url = new String (document.URL);
    filename = url.substr( url.lastIndexOf( '/') + 1 );
    numhtmlfiles--;

    var i;
    i = 0;

    while ( i < numhtmlfiles && htmlfiles[i] != filename )
    {
        i++;
    }

    i--;

    if ( i < 0 )
    {
        i = numhtmlfiles-1;
    }

    window.location = htmlfiles[i];

}
function next()
{
    url = new String (document.URL);
    filename = url.substr( url.lastIndexOf( '/') + 1 );

    var i;
    i = 0;

    while ( i <= numhtmlfiles && htmlfiles[i] != filename )
    {
        i++;
    }

    i++;
    i++;

    if ( i > numhtmlfiles )
    {
        i=1;
    }

    window.location = htmlfiles[i];

}
function up()
{
    window.location = gParenthtml;
}

function MapIt ( displayedLocation, latitude, longitude, zoom, type )
{
    if (type != 'h' && type != 's' & type != 'm' )
    {
       type = 'h'
    }
    urlSite = 'http://maps.google.com/maps?f=q&hl=en&q=' + latitude + ',' + longitude + '+(' + displayedLocation + ')&ie=UTF8&om=1&z=' + zoom + '&t=' + type + '&iwloc=addr'
    w( '<a href=' + urlSite + ' target=GoogleMaps> (Map It)</a>' )
}