//  We really need a proper loading script like scriptaculous

document.write('<script type="text/javascript" src="/js/bse_search.js"></script>');
document.write('<script type="text/javascript" src="/js/combo.packed.js"></script>');

/*
document.write('<script type="text/javascript" src="/js/hotspots.js"></script>');
document.write('<script type="text/javascript" src="/js/hotspots_panorama.js"></script>');
*/


// wait for DOM to load before initialising (now called in the page body)
//document.observe("dom:loaded", dom_init);
Event.observe(window, "load", window_init);

var bse_debug = false;

// set globally so we can reload the tips for generated search data
var tooltips;

//var hotSpotsData = {};

// establish our theme since we have no ImgZoomer in the combo
var Themes = new Object();

Themes.tooltip = {
    imagePath: "/images/imgzoomer/",
    shadowTheme: "light",
    shadowThemeSize: 10,
    shadowDepth: 5,
    shadowClass: "shadowMe",
    blankPixel: "blank.gif"
};

function dom_init() {
    if ($('message')) {
        new Effect.DropOut($('message'),{ delay: 5 });
    }

    var informer = new Informer("input[type=text], textarea");

    var firstChildH2 = $$(".body>h2")[0];
    if (firstChildH2) firstChildH2.addClassName("first");
    
    var firstChildLI = $$("ul.products>li>a")[0];
    if (firstChildLI) firstChildLI.addClassName("first");

    var showMeFade = new ShowMe('ul.products li', {
        //animationDuration: 0.075,
        //initialDelay: 0.25,
        //sequential: true,
        sequentialDelay: 0
    });

    var showMeBlind = new ShowMe('.drawer', {
        animationDuration: 0.1,
        initialDelay: 0.75,
        effect: Effect.BlindDown
    });

// Cheat and define panorama width and height to support loading on dom init

    if ($$('.textures')[0] != undefined) {
        var textures = $$('.textures')[0];
        textures.style.height = "400px";
        textures.style.width = "320px";
    };

    if ($$('.heros')[0] != undefined) {
    var heros = $$('.heros')[0];
        heros.style.width = "720px";
    };

    var fixedPanorama = new FixedPanorama($$('.textures')[0], $$('.textures')[0], '.textures a', {
        callOnShowAfterFade: false,
        useMouseStop: true,
        random: true,
        zIndex: 1,
        autoPlayDelay: 3500
    });

};

function window_init() {
    
//     var fixedPanorama = new FixedPanorama($$('.textures')[0], $$('.textures')[0], '.textures a', {
//         callOnShowAfterFade: false,
//         useMouseStop: true,
//         random: true,
//         zIndex: 1,
//         autoPlayDelay: 3500
//     });

    tooltips = new ToolTips(".article *[title], #header a[title]", {
        //preloadImages: true,
        fadeSpeed: 150,
        //fixed: false,
        offset: { x: 10, y: 0 },
        hook: { target: "right", tip: "left" }
    });

    tooltips.applyShadow(Themes.tooltip);

    tabs = new Tabs(".drawer ul.tabs li a, .tabs ul li a", {
        animation: Tabs.Animations.Slide,
        //animation: Tabs.Animations.Fade,
        animationOptions: { duration: 0.25 }
    });

	var drawers = new Drawers('.drawer', {
        id: "drawers",
        initialDrawer: ($$(".product").size() > 0), // open product spec drawer only
        duration: 0.15,
        drawerHeight: 259
    });

    var tabDrawers = new TabDrawers([ tabs ], [ drawers ]);

    var overflow = new Overflow("ul.series ul, ul.products ul, .article.default .body", {
        scrollBarPadding: { top: 0, bottom: 3 },
        padding: { top: 0, bottom: 0, left: 0, right: 0 },
        focusCheckSelector: "li"
    });

//     var hotSpotsPanorama = new HotSpotsPanorama(fixedPanorama.panorama, {
//         clickerImage: "/images/interface/hotspot.png",
//         editorType: HotSpots.Editors.Normal,
//         clickerZIndex: 2
//     });
// 
//     hotSpotsPanorama.checkIfAdmin();

};
