//  $RCSfile: menu.js,v $
//  @version $Revision: 1.2 $
//  $Date: 2005/09/01 01:42:14 $
function productPreview( thing ) {
    if( PreviewImages[thing] == false ) {
        document.preview.image.src = loading.src;
        PreviewImages[thing] = new PreviewImage(thing, PI_Locations[ thing ]);
    }
    document.preview.image.src = PreviewImages[thing]['default'].src;
}

function rangePreview( thing ) {
    if( PreviewImages[thing] == false ) {
        document.preview.image.src = loading.src;
        PreviewImages[thing] = new PreviewImage(thing, PI_Locations[ thing ]);
    }
    document.preview.image.src = PreviewImages[thing]['default'].src;
}

function bannerPreview( thing ) {
    if( PreviewImages[thing] == false ) {
        document.preview.image.src = loading.src;
        PreviewImages[thing] = new PreviewImage(thing, PI_Locations[ thing ]);
    }
    document.preview.image.src = PreviewImages[thing]['default'].src;
}

function clearPreview() {
    document.preview.image.src = "/images/site/blank.png";
//    document.preview.image.src = "/images/site/banners/xmasdelivery.png";
}

function openSelectionFrameset( isProduct, id ) {
    top.location =
    "/main_menu.jsp?body_page=/item_selector.jsp?is_product_selector=" + isProduct +
    "&id=" + id;
}

function openPage( page ) {
    top.location = "/main_menu.jsp?body_page=" + page;
}

function PreviewImage( image_name, image ) {
    this['default'] = new Image();
    this['default'].src = image;
}

function addBookmark() {
    if( (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4) ) {
        var url = "http://www.wiredandwonderful.com";
        var title = "Wired and Wonderful";
        window.external.AddFavorite(url, title);
    }
}

function showDescription( txt, image, obj ) {
    // Get the div with the cool boxout in
    // var obj1 = document.getElementById('DescText');

    // set the text
    // obj1.innerHTML = txt;

    // set the image
    img = document.images['ICO_DescImg'];
    try {
        img.src = image;
    } catch( err ) {
        img.src = "/images/site/blank.png";
        img.width = 600;
        img.height = 75;
    }

    // set the location
    var obj2 = document.getElementById('DescriptionBox');
    obj2.style.left = effectiveObjLeft(obj, 300) + 100;
    obj2.style.top = objTop(obj) - 10;

    // Make it so, number one
    obj2.style.visibility = 'visible';
}

function hideDescription() {
    var obj = document.getElementById('DescriptionBox');
    obj.style.visibility = 'hidden';
}

function objLeft( obj ) {
    var x = arguments[1]?arguments[1]:0;
    if( obj.offsetParent == null ) {
        return x + obj.offsetLeft;
    } else {
        return x + obj.offsetLeft + objLeft(obj.offsetParent, x);
    }
}

function objTop( obj ) {
    var x = arguments[1]?arguments[1]:0;
    if( obj.offsetParent == null ) {
        return x + obj.offsetTop;
    } else {
        return x + obj.offsetTop + objTop(obj.offsetParent, x);
    }
}

function topWidth() {
    var obj = window.document.getElementsByTagName('BODY');
    return obj[0].clientWidth;
}

function effectiveObjLeft( obj, objWidth ) {
    if( objLeft(obj) + objWidth > topWidth() ) {
        return topWidth() - objWidth - 1
    } else {
        return objLeft(obj)
    }
}