﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("TUI.TipsCommunity.Templates.Units");

TUI.TipsCommunity.Templates.Units.TipTargetView = function(element) {
    TUI.TipsCommunity.Templates.Units.TipTargetView.initializeBase(this, [element]);
    this._$element = $(element);
}

TUI.TipsCommunity.Templates.Units.TipTargetView.prototype = {
    initialize: function() {
        TUI.TipsCommunity.Templates.Units.TipTargetView.callBaseMethod(this, 'initialize');
        if (this.get_images().length > 1)
        {
            this._$element.find('div.panel-center img.prev').click( Function.createDelegate(this, this.previousClick) );
            this._$element.find('div.panel-center img.next').click( Function.createDelegate(this, this.nextClick) );
        }

        var $dropdown = this._$element.find('div.panel-bottom div.simple-dropdown');
        $dropdown.find('span.selected-item').bind
        (
            'mouseenter',
            function()
            {
                $(this).parent().find('ul').show();
            }
        );
        $dropdown.find('ul').bind
        (
            'mouseleave',
            function(e)
            {
                $(this).hide();
            }
        ); 
    },
    dispose: function() {
        //Add custom dispose actions here
        TUI.TipsCommunity.Templates.Units.TipTargetView.callBaseMethod(this, 'dispose');
    },
    get_images: function() {
        return this._images;
    },
    set_images: function(value) {
        this._images = value;
    },
    get_currentImage: function() {
        return this.get_images()[this.get_currentIndex()];
    },
    get_currentIndex: function() {
        return this._currentIndex;
    },
    set_currentIndex: function(value) {
        this._currentIndex = value;
    }
}
TUI.TipsCommunity.Templates.Units.TipTargetView.registerClass('TUI.TipsCommunity.Templates.Units.TipTargetView', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
