// JavaScript Document
imageDefLUT = new Array()

/*
 *  >>>> Define the images and ALT text to be associated with a subject ('navpicture')
 *  Note that each image has an associated ALT text or null.
 *
 *  navpicture      The subject, eg. "About us"
 *  si              The subject image
 *  siURL           The URL if the image is to form a hyperlink, or null if not
 *  siAlt           The ALT text or null if none required
 *
 *  The following parameters with their associated URL and ALT text are optional,
 *  but if any are required, all must be specified.
 *
 *  t1
 *  tr
 *  bl
 *  ad
 */
 
function ImageDef (navpicture, 
                    si, siURL, siAlt, 
                    tl, tlURL, tlAlt, 
                    tr, trURL, trAlt,
                    bl, blURL, blAlt, 
                    ad, adURL, adAlt)
{
    this.navpicture = navpicture    // Use for debug

    this.si = si
    this.siURL = siURL
    this.siAlt = siAlt
    
    if (arguments.length > 4)
    {
        this.tl = tl
        this.tlURL = tlURL
        this.tlAlt = tlAlt
        this.tr = tr
        this.trURL = trURL
        this.trAlt = trAlt
        this.bl = bl
        this.blURL = blURL
        this.blAlt = blAlt
        this.ad = ad
        this.adURL = adURL
        this.adAlt = adAlt
    }
    this.paramCount = arguments.length
    
    imageDefLUT[navpicture] = this
}

defaultImageDef =
    new ImageDef (  "DEFAULT",
                    "", "", "",
                    "Image,21065,en.jpg", "", "home image 1", 
                    "Image,21066,en.jpg", "", "home image 2", 
					"Image,21067,en.gif", "", "home image 3",
					"", "", "" )

    new ImageDef (  "About us",
                    "Image,21079,en.gif", "", "about us",
                    "Image,21075,en.jpg", "", "about us image 1", 
                    "Image,21076,en.jpg", "", "about us image 2", 
					"Image,24723,en.jpg", "", "about us image 3",
					"", "", "" )

    new ImageDef (  "Home warranties",
                    "Image,21080,en.gif", "", "home warranties",
                    "Image,24701,en.jpg", "", "home warranties image 1", 
                    "Image,24693,en.jpg", "", "home warranties image 2", 
					"Image,24698,en.jpg", "", "home warranties image 3",
					"", "", "" )

    new ImageDef (  "Registered builders",
                    "Image,21099,en.gif", "", "registered builders",
                    "Image,24724,en.jpg", "", "registered builders image 1", 
                    "Image,24702,en.jpg", "", "registered builders image 2", 
					"Image,24716,en.jpg", "", "registered builders image 3",
					"", "", "" )

    new ImageDef (  "Claims",
                    "Image,21100,en.gif", "", "claims",
                    "Image,24717,en.jpg", "", "claims image 1", 
                    "Image,24725,en.jpg", "", "claims image 2", 
					"Image,24707,en.jpg", "", "claims image 3",
					"", "", "" )

    new ImageDef (  "NHBC publications",
                    "Image,21101,en.gif", "", "NHBC publications",
                    "Image,24711,en.jpg", "", "NHBC publications image 1", 
                    "Image,24710,en.jpg", "", "NHBC publications image 2", 
					"Image,24712,en.jpg", "", "NHBC publications image 3",
					"", "", "" )

    new ImageDef (  "News centre",
                    "Image,21102,en.gif", "", "News centre",
                    "Image,24694,en.jpg", "", "news centre image 1", 
                    "Image,24696,en.jpg", "", "news centre image 2", 
					"Image,24708,en.jpg", "", "news centre image 3",
					"", "", "" )

    new ImageDef (  "Careers with NHBC", 
                    "Image,21103,en.gif", "", "Careers with NHBC",
                    "Image,24715,en.jpg", "", "careers with NHBC image 1", 
                    "Image,24714,en.jpg", "", "careers with NHBC image 2", 
					"Image,24719,en.jpg", "", "careers with NHBC image 3",
					"", "", "" )

    new ImageDef (  "Site map",
                    "Image,21104,en.gif", "", "Site map",
                    "Image,21081,en.jpg", "", "site map image 1", 
                    "Image,21082,en.jpg", "", "site map image 2", 
					"Image,21083,en.gif", "", "site map image 3",
					"", "", "" )

    new ImageDef (  "Search",
                    "Image,21105,en.gif", "", "Search",
                    "Image,24727,en.jpg", "", "search image 1", 
                    "Image,24728,en.jpg", "", "search image 2", 
					"Image,24726,en.jpg", "", "search image 3",
					"", "", "" )
                    
    new ImageDef (  "Terms of use",
                    "Image,21106,en.gif", "", "Terms of use",
                    "Image,24730,en.jpg", "", "terms of use image 1", 
                    "Image,24731,en.jpg", "", "terms of use image 2", 
					"Image,24729,en.jpg", "", "terms of use image 3",
					"", "", "" )

    new ImageDef (  "Accessibility",
                    "Image,21107,en.gif", "", "Accessibility",
                    "Image,24730,en.jpg", "", "accessibility image 1", 
                    "Image,24731,en.jpg", "", "accessibility image 2", 
					"Image,24729,en.jpg", "", "accessibility image 3",
					"", "", "" )

    new ImageDef (  "Privacy policy",
                    "Image,21108,en.gif", "", "Privacy policy",
                    "Image,24730,en.jpg", "", "privacy policy image 1", 
                    "Image,24731,en.jpg", "", "privacy policy image 2", 
					"Image,24729,en.jpg", "", "privacy policy image 3",
					"", "", "" )

    new ImageDef (  "Award winning site managers", 
                    "Image,21109,en.gif", "", "Award winning site managers",
                    "Image,21081,en.jpg", "", "award winning site managers image 1", 
                    "Image,21082,en.jpg", "", "award winning site managers image 2", 
					"Image,21083,en.gif", "", "award winning site managers image 3",
					"", "", "" )

new ImageDef (  "Approved inspectors",
                    "Image,24485,en.gif", "", "Approved inspectors",
                    "Image,24695,en.jpg", "", "approved inspectors image 1", 
                    "Image,24705,en.jpg", "", "approved inspectors image 2", 
					"Image,24697,en.jpg", "", "approved inspectors image 3",
					"", "", "" )


/**
 *  Return an ImageDef object, where the subject is one of the subjects
 *  from the definitions above, or return a default if the subject name is not found.
 */
 
function getImageDef (subject)
{
    imageDef = imageDefLUT[subject]
    if (imageDef == null)
    {
        imageDef = defaultImageDef
    }    
    return imageDef
}
/*
 *  Output the named image and ALT text as an HTML <img src=...>
 *  using a standard image base of /cms/publish/consumer/media/
 *
 *  image       The name of the image relative to the base
 *  altText     The text to appear in the alt= , or null if none required
 *  width       An optional image width
 *  height      An optional image height (width must be specified
 */
 
function writeImage (image, url, altText, width, height)
{    
    if (image != null && image !="")
    {
        var html = ""
        if (url != null && url !="")
        {
            html += "<a href=" + url + ">"
        }
        html += "<img src=/cms/publish/consumer/custimages/"
        html += image
        if (arguments.length > 3)
        {
            html += " width=" + width
            if (arguments.length > 4)
            {
                html += " height=" + height
            }
        }
        if (url != null && url !="")
        {
            html += " border=0"
        }
        if (altText != null && altText !="")
        {
            html += " alt='" + altText + "'"
        }
        html += ">"
        if (url != null && url !="")
        {
            html += "</a>"
        }
        document.write (html)
    }
}


/**
 *  Modify the style of <A tag (anchor elements) within a "breadcrumbs" <div>.
 */
 
function styleDocElements()
{
    with (document.getElementById("breadcrumbs").getElementsByTagName("A")[0])
    {
        style.fontWeight='bold';
        style.textDecoration='underline';
    }
}

/**
 *  Output " > " and the level text, if the level text is not empty
 */
 
function levelsOutput (levels)
{
    for (var i=0; i < levels.length; i++)
    {
        if (levels[i] !='')
        {
			if (i!=0)
            {
				document.write(" > " + levels[i]);
			}
			if (i==0)
			{
				document.write(levels[i]);
			}
        }
    }
}
