if($.browser.opera) {
    /*$(window).scroll(function() {
        $("html")
            .scrollTop(0)
            .scrollLeft(0);
    });*/
}

// Initialize Controls
function saveScreen() {
    
    $.jStorage.set("collectionIndex", B.collectionManager.activeCollectionIndex);
    $.jStorage.set("screenIndex", B.collectionManager.activeCollection._activeScreenIndex);
    
}

B.dropdown = new B.Dropdown(B.collectionManager.collections, B.collectionManager.activeCollectionIndex);

B.infoButton = new B.InfoButton("", B.collectionManager.activeCollection.infoText, function() {
    B.controller.stopTimer();
}, function() {
    B.controller.startTimer();
});
    
B.dropdown.ui.container.bind({
    optionClick: function(e, self, index){

        B.collectionManager._setActiveCollection(index);
        saveScreen();
        
        B.infoButton.hideOverlay(function(){
            B.infoButton.overlayContent = B.collectionManager.activeCollection.infoText;
            B.infoButton.updateUI();
        });
        
    }
});

$("body").append(B.dropdown.ui.html, B.infoButton.ui.html);

var buttonLeft = $("<div/>", {
    "class": "button back",
    click: function(){
        B.collectionManager.activeCollection.changeScreen(-1);
        B.controller.stopTimer();
        B.collectionManager.activeCollection.isUserManipulated = true;
        saveScreen();
    }
});

var buttonRight = $("<div/>", {
    "class": "button forward",
    click: function(){
        B.collectionManager.activeCollection.changeScreen(1);        
        B.controller.stopTimer();
        B.collectionManager.activeCollection.isUserManipulated = true;
        saveScreen();
    }
});

$("#Footer").before(buttonLeft, buttonRight);

var buttonHandler = function(){
    
    var buttons = $("body").find(".button");

    buttons.css({
        top: ((parseInt($(window).height(), 10) - 45) - parseInt(buttons.height(), 10)) / 2
    });

};
    
$(window).bind({
    
    scroll: buttonHandler,
    resize: $.throttle(50, buttonHandler)
    
});


