// 01/08/02 Initial release for BDG site based on CFPS fns2.js
// 28/01/03 doCount() added for hit logging
// 14/02/04 getAddress antispam measure introduced
// 28/07/08 Phot gallery 9 added
// 10/01/09 Phot gallery 10 added

var fullLog = false; //true to send full browser log details
var ver = parseFloat(navigator.appVersion);
var isOnline = (window.location.protocol.indexOf('http') > -1);
var isNav4 = (navigator.appName.indexOf('Netscape')> -1 && ver >= 4.0 && ver < 5.0);


//Get gallery number from query string
function getNewGallery()
{
   if (document.location.search.length)
   {
        var galleryNum = parseInt(document.location.search.substring(1));
        return (isNaN(galleryNum))?0:galleryNum; // default to main gallery if passed value u/s
   }
   else return 0; // default to main gallery ref if no value passed
}
////////////////////////////////


// Get photo gallery number from page URL
function getGallery()
{
    var page = new String(window.document.location.pathname);
    var galleryNum = parseInt(page.substring(page.indexOf('gallery')+7, page.length));
    return (isNaN(galleryNum))?0:galleryNum; // default to main gallery if return value u/s
}
////////////////////////////////


// Check & load parent frameset for resepective photo gallery
// all gallery filenames must begin with 'galleryN' where N is the gallery number
// all gallery inner framesets must be named 'galleryN' where N is the gallery number
function checkFrames()
{

//    if (window.document.location.pathname == parent.window.location.pathname)// if page not in frameset
    if (parent.window.location.pathname.indexOf('photogallery') < 0)
    {
        window.location.replace('photogallery.htm?' +getGallery() );// not to UK2 redirect top frame
        return false;
    }
    else return true;
}
////////////////////////////////


//Set page title in header
function setTitle(num)
{
    var titles = new Array();
        titles[0] = "ELR Bury Diesel Group - visitors & other events photo gallery";
        titles[1] = "ELR Bury Diesel Group - hydraulics photo gallery";
        titles[2] = "ELR Bury Diesel Group - English Electric photo gallery";
        titles[3] = "ELR Bury Diesel Group - Sulzer photo gallery";
        titles[4] = "ELR Bury Diesel Group - holiday photo gallery";
        titles[5] = "ELR Bury Diesel Group - 2004 diesel events and views photo gallery";
        titles[6] = "ELR Bury Diesel Group - 2005 diesel events and views photo gallery";
        titles[7] = "ELR Bury Diesel Group - 2006 diesel events and views photo gallery";
        titles[8] = "ELR Bury Diesel Group - 2007 diesel events and views photo gallery";
        titles[9] = "ELR Bury Diesel Group - 2008 diesel events and views photo gallery";
        titles[10] = "ELR Bury Diesel Group - 2009 diesel events and views photo gallery";

    window.document.write('<TITLE>' +titles[num] +'</TITLE>')

}
////////////////////////////////

// get current page filename
function getPage()
{
    var page = window.document.location.pathname;

    // trap for default page without filename

    if (page.indexOf(".htm") < 0) page = "index.htm";

    else
    {
        // location check must use "\\" for IE local HDD but "/" live
        delChar = (page.indexOf(":\\") > -1) ? "\\" : "/";
        page = page.substring(page.lastIndexOf(delChar)+1);
    }

    return page;
}

////////////////////////////////


//call counter script in IFRAME
function doCount()
{

/* ////// logging suspended

*/

}

////////////////////////////////
// Email antispam measure

var charAt = "@";
var address = new Array();
address[0] = 'blackclag' + charAt +'burydiesel.freeserve' +'.co.uk?body=[%20NB%20please%20note%20-%20no%20attachments%20bigger%20than%201MB%20without%20dropping%20us%20a%20line%20first!%20Many%20thanks!%20]';
address[1] = 'admin' + charAt + 'east-lancs-rly' +'.co.uk?subject=Diesel%20Driving%20Experience%20enquiry';
address[2] = 'htservices' + charAt +'btopenworld.com' +'?subject=Diesel%20Group%20Volunteer%20Enquiry';
address[3] = 'treasurer' + charAt + 'd8233' +'.org.uk?subject=Generator%20Fund%20standing%20order%20donation%20details';

    
// Create generic mailto
// Pass array index plus CSS stylename if applicable
// Pass link text string, otherwise link text defaults to email address less any query string
function getAddress(num, style, linktext)
{
    if (num <= address.length)
    {
        if (linktext)
        {
            document.writeln('<A CLASS="' +style +'" HREF="mailto:' +address[num] +'">' +linktext +'</A>')
        }
        else 
        {
            // strip any query string for default link text
            linktext = address[num];
            if (linktext.indexOf('?') > 8 ) // otherwise it's a duff address anyway
            {
                linktext = linktext.substring(0,linktext.indexOf('?'));
            }
            document.writeln('<A CLASS="' +style +'" HREF="mailto:' +address[num] +'">' +linktext +'</A>')
        }
        
    }
}
////////////////////////////////