var SUB_EXPIRE=30;
var INACTIVE_EXPIRE=1;
var EXIT_EXPIRE=7;
var EXIT_C='adtExit';
var INACTIVE_C='adtInact';

//returns true if cookie for popup type does not exist
function doPopup(popType, popDiv) {
   var doPopup = false
   switch (popType)
   {
   case (popupType = "exit"):
     if(getADTCookie(EXIT_C+popDiv) == '') {doPopup = true;}
     break
   case (popupType = "inact"):
     if(getADTCookie(INACTIVE_C+popDiv) == '') {doPopup = true;}
        break
   } 
   return doPopup;
}
/* There is one cookie for each of the 2 types of popups. EXIT_C for exit popups, INACTIVE_C for inactivity popups.
 * If any popup is displayed, set/reset each cookie to expire in their default number of days.
 * If a form or shopping cart is submitted, set each cookie to expire in SUB_EXPIRE days
 */
function setPopupCookies(isSubmit,ctype){
   if(isSubmit=='true') {
      setADTCookie(EXIT_C+ctype,'true',SUB_EXPIRE);
      setADTCookie(INACTIVE_C+ctype,'true',SUB_EXPIRE);
   } else {
      setADTCookie(EXIT_C+ctype,'true',EXIT_EXPIRE);
      setADTCookie(INACTIVE_C+ctype,'true',INACTIVE_EXPIRE);
   }
}
function getADTCookie(c_name){
   if (document.cookie.length>0){
      c_start=document.cookie.indexOf(c_name + "=");
      if (c_start!=-1){ 
         c_start=c_start + c_name.length+1; 
         c_end=document.cookie.indexOf(";",c_start);
         if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
       } 
  }
return "";

}
function setADTCookie(c_name,value,expiredays){
   var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
   document.cookie=c_name+ "=" +escape(value)+ ";path=/;" + "domain="+ document.domain +";" +
   ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
