﻿
var Page = {

    detailsVisible: null,   // which preview details (ID) is visible
    
    transitionTime: 1,      // duration of transition
    transitionWait: 0.5,    // amount of time to wait on hover before initiating

    transition: null,       // structure representing transition
        
    ready: function() {
        Layout.applyCorners("#Side .Preview .Image");
    },
    
    //
    // initVisible() : Set default visibility.
    //
    initVisible: function(id) {
        this.detailsVisible = id;
    },

    //
    // initShow() : Initiate reveal.
    //    
    initShow: function(id) {
        if (this.transition) {
            this.cancelShow(this.transition.id);
        }
        this.transition = {
            id: id,
            handle: setTimeout("Page.showDetails('" + id + "')", this.transitionWait * 1000)
        };
    },
    
    //
    // cancelShow() : Cancel reveal.
    //
    cancelShow: function(id) {
        if (this.transition) {
            if (this.transition.id == id) {
                clearTimeout(this.transition.handle);
                this.transition = null;
            }
        }
    },

    //
    // showDetails()
    //
    showDetails: function(id) {
        alert('show');
        
        this.transition = null;
        
        if (this.detailsVisible) {
            if (this.detailsVisible == id) {
                return;
            }
            this.hideDetails(this.detailsVisible);
        }

        /*
        Ext.get("clip" + id).scale(undefined, Ext.get("details" + id).getHeight(), {
            duration: this.transitionTime,
            callback: function() {
            }
        });        
        */
        
        this.detailsVisible = id;
    },

    //
    // hideDetails()
    //
    hideDetails: function(id) {

        /*
        Ext.get("clip" + id).scale(undefined, 0, {
            duration: this.transitionTime,
            callback: function() {
            }
        });        
        */
        
        this.detailsVisible = null;
    }

};
$(document).ready(function(){Page.ready();});

