$(function()
{
    $('#demo-store a').click(
        function(e)
        {
            var tempheight = screen.height - 80,
                tempwidth = screen.width - 15,
                windowprops = "top=0,left=0,resizable=yes" +
                ",width=" + tempwidth + ",height=" + tempheight;

            window.open(this.href,'popup', windowprops);
            return false;
        }
    );
});

function showLoader()
{
    var left = document.documentElement.clientWidth / 2;
    var top = (document.documentElement.clientHeight / 2) + document.documentElement.scrollTop;
    $('#pending').show().css('top', top +'px').css('left', left +'px');
}

function hideLoader()
{
    $('#pending').hide();
}

var Feedback = function()
{
    this.init();
}

Feedback.prototype = {

    div: false,

    init: function()
    {
        var div = $( '#feedback' );
        if( !div.length )
        {
            div = this.createFeedback();
        }
        this.div = div;
        $( document.body ).append( div );
    },

    createFeedback: function()
    {
        var div = $( '<div id="feedback"><h2>Meddelande</h2><ul></ul>\
                      <input type="submit" id="feedbacksubmit" onclick="this.parentNode.parentNode.removeChild( this.parentNode );return false;" value="OK" class="button_small"></div>' );

        return div;
    },

    addFeedback: function( str )
    {
        var found = false;
        this.div.find( 'li' ).each(
            function()
            {
                if( $( this ).html() == str ) found = true;
            }
        );

        if( !found )
        {
            this.div.append( $( '<li>'+ str +'</li>' ) );
        }
    },

    removeFeedback: function()
    {
        this.div.remove();
    }

};
