function showNewsletterPopup(){
  Modalbox.show("/naujienlaiskis/popup", {title: "Naujienlaiškio prenumerata", width: 400, height:380, overlayClose:false});
  newsletterDone();
}
function newsletterDone(){
  jar = new CookieJar({
    expires:44000, // seconds
    path: '/'
  });
  visit.showed = true;
  jar.put('visit', visit);
}

function showResult()
{
   $('NewslaterInput').onfocus = function() {
     // if already cleared, do nothing
     if (this._cleared) return
	 
	 // otherwise clear this
	 this.clear()
     this._cleared = true
   }
   jar = new CookieJar({
    expires:24000, // seconds
    path: '/'
    });
    visit = jar.get('visit');
    if (visit){
      //if (!visit.showed || (visit.time && (visit.time+24000000 < new Date().getTime()))){    
      if (!visit.showed ){
        var time =  visit.time + 40000;
        var nowTime = new Date().getTime();
        if ( nowTime >= time){
          showNewsletterPopup();          
        }else{
          setTimeout("showNewsletterPopup()",  40000);
        }    
      }
    } else {
      visit = {time: new Date().getTime()}; 
      jar.put('visit', visit);
      setTimeout("showNewsletterPopup()",  40000);
    }
}




