function showInt(projectId, p, lang)
{
     if (p == null) p = 1;
     var rv = p == 1 ? 1 : Math.random(1);
     if (rv <= p && document.cookie.indexOf('ANK6=' + projectId) == -1)
    {
        var win = window.open('https://capi.pentor.com.pl/' + projectId + '.pg' + (lang == null ? '' : '?questionaire_language=' + lang), 'Ankieta','width=650,height=800,toolbars=no,resizable=yes,location=no,status=no,scrollbars=yes');
        if (win == null)
        {
        }

        if (win != null)
        {
             var expires=new Date();
             expires.setTime(expires.getTime()+1000*60*60*24*30);
             document.cookie ='ANK6=' + projectId + ';expires=' + expires.toGMTString();;

        }
    }
} 

function addEvent(eventName, func)
{
  if (window.attachEvent)
     window.document.body.attachEvent(eventName, func);
  else
  if (window.addEventListener)
  {
     if (eventName.indexOf('on') == 0) eventName = eventName.substring(2);  
     window.addEventListener(eventName, func, false);
  }
} 

var _navigateURL = null;

function _onclick(e)
{
  var src = e.srcElement ? e.srcElement : e.target;
  if (src.tagName == 'A')
  {
     _navigateURL = '' + src;
  }
  else
     _navigateURL = null;
}

function _wyjscie(e)
{
  if (_navigateURL == null)
     openWin(); 
}

function openWin()
{
  showInt('4d20700af3cd35efd67569f14d540d0f', 0.05, 'pl_PL')
}

setTimeout(openWin, 20000);
if (window.attachEvent)
     window.document.body.attachEvent('onclick', _onclick);
else
if (window.addEventListener)
   window.addEventListener('click', _onclick, false);

if (window.attachEvent)
     window.attachEvent('onbeforeunload', _wyjscie);
else
if (window.addEventListener)
   window.addEventListener('beforeunload', _wyjscie, false);

