﻿function swapBanner(newImagePath)
{
    fld = document.getElementById('ctl00_BannerImage_imgbk');
    if (fld)
        fld.src = newImagePath;
}

function setCopywriteText()
{
    fld = document.getElementById('copywrite');
    if (fld)
        fld.innerHTML = '&copy ' + new Date().getFullYear() + ' The Hawley Company';
    updateMenu();

    var ua = navigator.userAgent.toLowerCase();
    if ((fld) && (ua.indexOf('safari/') != -1))
        toggleDIV('copywrite', 'none');
    
}

function ChangeColor(id, color)
{
    fld = document.getElementById(id);
    if (fld)
    	fld.className = color;
//        fld.style.color = color;
}

function changeItem()  /* is this overload needed in javascript? */
{
    changeItem(null, null, null, null)
}

function changeItem(itemNum, divName, imgPath, scrollToBottom)
{
    for (i = 1; i <= 10; i++)
        toggleDIV('Item' + i.toString(), 'none');
    for (i = 1; i <= 10; i++)
        ChangeColor('Label' + i.toString(), 'Black');

    if ((itemNum != null) && (divName != null))
    {
        toggleDIV(divName, 'block');
        ChangeColor(itemNum, 'silver');
    }
    
    if (imgPath)
        swapBanner(imgPath);

    fld = document.getElementById('divScrollable');
    if ((scrollToBottom) && (fld) && (divName))
        fld.scrollTop = fld.scrollHeight;

}

function toggleDIV(divname, setto)
{	//warning: do not user debug_ within this function
    fld = document.getElementById(divname);

    if (fld == null)
        return;

    var iebody = (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
    scrl = iebody.scrollTop;
    if (scrl > 0)
        fld.style.pixelTop += scrl;

    if (setto == null)
    {
        if (fld.style.display != 'block')
            setto = 'block';
        else
            setto = 'none';
    }

    fld.style.display = setto;
    return;
}

function toggleOnly(divname, setto) 
{
	var fld = document.getElementById(divname);

	if (fld == null)
		return;
    if (setto == null)
    {
		if (fld.style.display != 'block')
			setto = 'block';
		else
			setto = 'none';
	}

	fld.style.display = setto;
}

