function OpenImage(src, alt)
{
  image = window.open('','image','left=50, top=50, width=400, height=400, toolbar=no, menubar=no, status=no, resizable=no, scrollbars=no');
  image.focus();
  image.document.write('<html><head><title>' + alt + '</title>');
  image.document.write('<script language="javascript"> var NS = (navigator.appName=="Netscape") ? true:false; function FitPic() { iWidth = (NS)?window.innerWidth:document.body.clientWidth; iHeight = (NS)?window.innerHeight:document.body.clientHeight; iWidth = document.images[0].width - iWidth; iHeight = document.images[0].height - iHeight; window.resizeBy(iWidth, iHeight); self.focus(); } </script>');
  image.document.write('</head><body onload="FitPic();" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" align="center"><a href="javascript: window.close();"><img src="'+src+'" alt="'+alt+'" border="0" /></a></body></html>');
  image.document.close();
}


// AJAX - anketa

var surveyID = 0;

function survey_vote(answer, lang) {
    
    $.ajax({
            url: '/public/survey.php?survey=' + surveyID + '&answer=' + answer + '&lang=' + lang,
            dataType: 'xml',
            type: 'GET',
            timeout: 2999,
            global: false,
            success: function(data) {
                         surveyID = $('survey', data).attr('id');
                         
                         var content = '<p>' + $('survey question', data).text() + '</p>';
                         
                         $.each($('answer', data), function(i, item) {
                             content += '<a class="answer" href="javascript:survey_vote(' + $(item).attr('id') + ', \'' + lang + '\'); void(0);">' + $(item).text() + ' - ' + $(item).attr('perc') + '%</a>' +
                                        '<span><img class="surveyBar" src="/images/survey-bar-' + (i+1) + '.png" alt="' + $(item).text() + '" style="width: ' + (Math.round(205 * $(item).attr('perc') / 100)) + 'px;" /></span>';
                         });
                         
                         $('#survey_content').html(content);
                     }
           });
}
