﻿// buttons input behaviour

function openPopup (strSeite, intBreite, intHoehe, strName, strScrollbars, strResizeable)
{
    var intScreenWidth = screen.width;
    var intScreenHeight = screen.height;
    var intPosX = (intScreenWidth / 2) - (intBreite / 2);
    var intPosY = (intScreenHeight / 2) - (intHoehe / 2);
    var winPopup = window.open(strSeite, strName, 'width='+ intBreite +',height='+ intHoehe +',left='+ intPosX +',screenX='+ intPosX +',top='+ intPosY +',screenY='+ intPosY +',menubar=no,scrollbars='+ strScrollbars +',resizable='+ strResizeable +',location=no,status=no,directories=no,dependent');
    winPopup.focus();
}

function backwards()
{
    var buttons = document.getElementsByTagName('button');

    for
    (
        var i=0;
        i<buttons.length;
        i++
    )
    {
        if 
        ( 
            buttons[i].className == 'back'
        )
        {
            buttons[i].onclick = function(){
                window.location = '/katalog/';
                return false;
            };
        }
        if
        (
            buttons[i].className == 'refresh'
        )
        {
            buttons[i].onclick = function(){
                window.refresh();
                //location.reload(true)
                return false;
            };
        }
        if
        (
            buttons[i].className == 'view'
        )
        {
            buttons[i].onclick = function(){
                //openPopup( '/media/static/pics/dynamic/teilung_popup.jpg', '629', '520', 'teilung_popup', 'no', 'no' );
                
                //openPopup( '/katalog/teilung/', '629', '520', 'teilung_popup', 'no', 'no' );
                openPopup( '/katalog/teilung', '629', '520', 'teilung_popup', 'no', 'no' );
                return false;
            };
        }
    }
    
    var elem = document.getElementsByTagName('p');

    for
    (
        var i=0;
        i<elem.length;
        i++
    )
    {
        if
        (
            elem[i].className == 'popclose'
        )
        {
            elem[i].onclick = function(){
                window.close();
                return false;
            };
        }
    }
}

window.onload = backwards;
