function setNewelementsCookie()       {
   if(check_agent() && check_autochat())      {
          var today = new Date();      
          today.setTime( today.getTime() );
          var expires_date = new Date( today.getTime() + (1000 * 60 * 60 * 24) );
                       
          if(document.cookie.indexOf("newelements_autochat=")>=0)    {
               var timer;
               timer = document.cookie.split("newelements_autochat=")[1].split(";")[0].slice(13);  
               if(timer==0)   {
                    if(document.getElementById("newelchatinv").style.visibility=="visible")
                         document.getElementById("newelchatinv").style.visibility="hidden";
               }
               else if(timer==1)      {
                               //löse chateinladung aus
                               if(document.getElementById("newelchatinv").style.visibility=="hidden")
                                       document.getElementById("newelchatinv").style.visibility="visible";
                               setTimeout("setNewelementsCookie()",1000);    
               }
               else    {
                               var newTimer=timer-1;
                               document.cookie ="newelements_autochat=" + new Date().getTime() + newTimer + "; expires=" + expires_date.toGMTString() + "; path=/;";
                               setTimeout("setNewelementsCookie()",1000);                   
               }
          }     
          else  {
                       document.cookie ="newelements_autochat=" + new Date().getTime() + get_autochat_timer() +"; expires=" + expires_date.toGMTString() + "; path=/;";
                       setTimeout("setNewelementsCookie()",1000);    
          }            
   }
}

function sendReaction(reaction) {
        var chatReactionScript = document.createElement("script");
        chatReactionScript.setAttribute("type", "text/javascript");
        //chatReactionScript.setAttribute("src", "http://int.newelements.de/tracker/autochat/chatreaction.php?fingerprint=" + FingerPrint + "&reaction=" + reaction);
        chatReactionScript.setAttribute("src", "http://bitdefender.newelements.de/tracker/bitdefender/autochat/chatreaction.php?fingerprint=" + FingerPrint + "&reaction=" + reaction);
        document.getElementsByTagName("html")[0].appendChild(chatReactionScript);
        return false;
} 

function chat_no() {
        sendReaction("a_no");
        return false;
}

function chat_never() {
        sendReaction("a_never");
        return false;
}

function autoInvitation(action)       {
        var today = new Date();        
          today.setTime( today.getTime() );
          var expires_date = new Date( today.getTime() + (1000 * 60 * 60 * 24) );
        document.cookie ="newelements_autochat=" + new Date().getTime() + "0; expires=" + expires_date.toGMTString() + "; path=/;";
        
        if(action=="yes")
               chat_popup(FingerPrint);
        else if(action=="no")
               chat_no();
               document.getElementById("newelchatinv").style.visibility="hidden";   
        return false;  
}


