//
// $Id: CMS.js,v 1.1.1.1 2010/02/26 08:30:04 steve Exp $
//
var CMS = function() {

    this.cms              = new CMSGeneric()   
    this.contactUs        = new CMSContactUs()   
    this.contentContactUs = new ContentContactUs()
    this.contentHeading   = new ContentHeading()
    this.contentImage     = new ContentImage()
    this.contentList      = new ContentList()
    this.contentText      = new ContentText()
    this.boats            = new Boats()    
    this.events           = new Events()    
    this.filters          = new Filters()    
    this.manufacturer     = new Manufacturer()
    this.headerImage      = new HeaderImage()
    this.html             = new Html()
    this.menu             = new Menu()
    this.news             = new News()
    this.thickbox         = new ThickBoxGeneric()
    
    this.init = function() {
    
        var self = this
        if ($('#loggedInDiv').length) {
        
            self.thickbox.applyThickBox($('a.thickbox'))

            // CMS Tasks
            //
            $('#cmsTaskButton').click( function() { location.replace($('#cmsTasksSelect').val()) })
            
            // Menu editors
            //
            $('.menu').mouseover(
                function() {
                    self.cms.position($(this), 100, 3)
                    self.cms.showEditor($(this))
                })
            self.menu.init()
            
            // Header Image editors
            //
            $('.contentHeaderImage').mouseover(
                function() {
                    self.cms.position($(this), 10, 10)
                    self.cms.showEditor($(this))
                })
            self.headerImage.init()
            
            // Heading editors
            //
            $('.contentHeading').mouseover(
                function() {
                    self.cms.position($(this), 10, 0)
                    self.cms.showEditor($(this))
                })
            self.contentHeading.init()

            // Text editors
            //
            $('.contentText').mouseover(
                function() {
                    self.cms.position($(this), 10, 0);
                    self.cms.showEditor($(this))
                })
            self.contentText.init()

            // List editors
            //
            $('.contentList').mouseover(
                function() {
                    self.cms.position($(this), 10, 0);
                    self.cms.showEditor($(this))
                })
            self.contentList.init()

            // Contact Us editors
            //
            $('.contentContactUs').mouseover(
                function() {
                    self.cms.position($(this), 10, 0)
                    self.cms.showEditor($(this))
                })
            self.contentContactUs.init()

            // Image editors
            //
            $('.contentImage').mouseover(
                function() {
                    self.cms.position($(this), 10, 10)
                    self.cms.showEditor($(this))
                })
            self.contentImage.init()
            
            $('.editorClose').click( function() { self.cms.hideEditor($(this)) })
            $('.subEditorClose').click( function() { self.cms.hideSubEditor($(this)) })

            $('.newSectionEditorInsert').click( function() { self.cms.addNewSection($(this)) })
            $('.newSectionEditorClose').click( function() { self.cms.hideNewSectionEditor($(this)) })
            
            // CMS News
            //
            self.news.initCMS()

            // CMS Events
            //
            self.events.initCMS()
            
            // CMS Filters
            //
            self.filters.initCMS()

            // CMS Manufacturers
            //
            self.manufacturer.initCMS()
            
            // CMS Brokerage
            //
            self.boats.initCMS()

            // CMS Contact Us
            //
            self.contactUs.initCMS()
        }
    }
}
