function PopupCenter(pageURL, title,w,h) {
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}

function rate(photo_id, num, ajaxurl, baseurl) {
    $('#ocena_wybierz').addClass('g tc').html('<img src="'+ baseurl +'media/images/rating/ajax-loader.gif" />');
    $.ajax({
        type: "POST",
        url: ajaxurl,
        dataType: "xml",
        data: 'rating=' + num + '&id=' + photo_id,
        success: function(xml) {
            var result = $('result', xml).text();
            var error = $('error', xml).text();
            var html = $('html', xml).text();
            var text = $('text', xml).text();
            if (result == 1) {
                $('#ocena').hide().html(html + '<div class="mt5 tc c">' + text + '</span>').slideDown('slow')
            } else {
                alert(error)
            }
        }
    })
}

function ageSwitch(obj, id) {
    ageSelect = document.getElementById(id);
    ageSelect.disabled = true;

    if (obj.value == 1) {
        ageSelect.disabled = false;
    }
}

function ageLoad(id, radid) {
    ageSelect = document.getElementById(id);
    levelRadio = document.getElementById(radid);
    if (levelRadio.checked == true) {
        ageSelect.disabled = false;
    } else {
        ageSelect.disabled = true;
    }
}

