// -*- mode: javascript; coding: utf-8 -*-
//
// Copyright 2009, 2010, 2011 Andrej A Antonov <polymorphm@gmail.com>.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

(function () {
    'use strict'
    
    var $ = jQuery
    
    var DEFAULT_MINI_WINDOW_WIDTH = 850
    var DEFAULT_MINI_WINDOW_HEIGHT = 650
    
    $('.NewMiniWindowLink').live('click', function (event) {
        event.preventDefault()
        
        var href = $(this).prop('href')
        var width = $(this).data('new-mini-window-link-width')
        var height = $(this).data('new-mini-window-link-height')
        
        if (width === undefined) {
            width = DEFAULT_MINI_WINDOW_WIDTH
        }
        if (height === undefined) {
            height = DEFAULT_MINI_WINDOW_HEIGHT
        }
        
        open(href,
	                '_blank',
	                'width=' + encodeURIComponent(width) +
	                ',height=' + encodeURIComponent(height) +
	                ',resizable=yes,scrollbars=yes')
    })
    
    $('.NewWindowLink').live('click', function (event) {
        event.preventDefault()
        
        var href = $(this).prop('href')
        
        open(href, '_blank')
    })
})()

