Why does't the pager / log option turn on and off when i want them to?

Code:
on *:connect:{
  if ($a_get(away) == on) {
    if ($a_get(multi) == on) {
      .quote away $a_get(reason) | $iif($a_get(anstat) == on,nick $a_get(anick))
    } 
    elseif ($a_get(multi) == $network) { .quote away $a_get(reason) 
      $iif($a_get(anstat) == on,nick $a_get(anick))
    }
  } 
}

on *:exit: { a_save away off }

alias weg.trug {
  if ($away) { away } | else { mas }
}

alias away {
  if (!$away) { a_save away on | a_save time $ctime | a_save nick $me | if ($left($1,1) == $chr(45)) { if ($left($1,2) != $chr(45)) { a_save pager $iif(p isincs $1,on,off) | a_save multi $iif(m isincs $1,on,$network) | a_save logger $iif(l isincs $1,on,off) | a_save silent $iif(s isincs $1,on,off) | a_save anstat $iif(n isincs $1,on,off) | a_save reason $iif($2- != $null,$2-,afk) } | else { a_save reason $iif($2- != $null,$2-,afk) } } | else { a_save reason $iif($1- != $null,$1-,afk) } | a_set away | if ($a_get(logger) == on) || ($a_get(pager) == on) { $iif($window(@away.log),window -c @away.log) | window -aBhk0s +estxL @away.log } }
  else { a_save away off | a_set back | if ($a_get(logger) == on) || ($a_get(pager) == on) { if ($window(@away.log)) && ($input(Do you want the messages and pages logged when you were away?,y,View logs?)) { window -a @away.log } } }
}
alias a_get { return $readini($mircdirdata\afwezig.ini,settings,$$1) }
alias a_save { writeini $mircdirdata\afwezig.ini settings $1 $2- }
alias -l a_set {
  if ($1 isincs away) { if ($a_get(silent) == off) { $iif($a_get(multi) == on,scid -at1) $a_get(mtype) $replace($a_get(amsg),<b>,$chr(2),<u>,$chr(31),<i>,$chr(22),<c>,$chr(3),<logger>,$a_get(logger),<pager>,$a_get(pager),<reason>,$a_get(reason)) } | $iif($a_get(anstat) == on,$iif($a_get(multi) == on,scid -at1) nick $a_get(anick)) | $iif($a_get(multi) == on,scid -at1) .quote away $replace($a_get(reason),$chr(32),$chr(160)) }
  if ($1 isincs back) { if ($a_get(silent) == off) { $iif($a_get(multi) == on,scid -at1) $a_get(mtype) $replace($a_get(bmsg),<b>,$chr(2),<u>,$chr(31),<i>,$chr(22),<c>,$chr(3),<logger>,$a_get(logger),<pager>,$a_get(pager),<reason>,$a_get(reason),<duration>,$duration($calc($ctime - $a_get(time)))) } | $iif($a_get(anstat) == on,$iif($a_get(multi) == on,scid -at1) nick $a_get(nick)) | $iif($a_get(multi) == on,scid -at1) .quote away }
}
alias mas_combo { if ($$1 == check) {
    var %mas = 1
    while (%mas <= $gettok($a_get($$2),0,181)) {
      if ($$3 == $gettok($a_get($$2),%mas,181)) { return $true }
      if (%mas == $gettok($a_get($$2),0,181)) && ($$3 != $gettok($a_get($$2),%mas,181)) { return $false }
      inc %mas
    } 
  }
  if ($1 == load) {
    did -r mas_dialog $iif($2 == areasons,3,6)
    var %mas = 1
    while (%mas <= $gettok($a_get($2),0,181)) {
      did -a mas_dialog $iif($2 == areasons,3,6) $gettok($a_get($2),%mas,181))
      inc %mas
    } 
  }
  if ($$1 = line) {
    var %mas = 1
    while (%mas <= $did(mas_dialog,$$2).lines) {
      if ($$3 == $did(mas_dialog,$$2,%mas)) { return %mas }
      inc %mas
    }
  } 
}

alias mas { dialog -m mas_dialog mas_dialog }
alias mas_logwin {
  if (!$window(@away.log)) { window -aBhk0s +estxL @away.log }
}

dialog mas_dialog {
  title $_(away0001)
  size -1 -1 131 58
  option dbu
  icon $icodir $+ scrippie.ico, 0
  box "", 1, 1 -2 129 33
  text $_(away0002), 2, 5 6 37 8
  combo 3, 44 5 60 52, drop edit size
  button "", 4, 106 5 20 11
  check $_(away0003), 5, 5 17 37 10
  combo 6, 44 17 60 52, drop edit size
  button "", 7, 106 17 20 11
  box "", 8, 1 29 88 28
  check $_(away0004), 9, 5 34 25 10
  check $_(away0005), 10, 44 34 25 10
  check $_(away0006), 11, 5 45 28 10
  check $_(away0007), 12, 44 45 40 10
  button "", 13, 90 32 40 12, ok
  button $_(away0008), 14, 90 45 40 12, cancel
}

on *:dialog:mas_dialog:*:*:{
  if ($devent == init) {
    did - $+ $iif($away,b,e) $dname 2,3,4,5,6,7,9,10,11,12 | did -a $dname 13 Set $iif($away,Back,Away) | if ($a_get(anstat) == on) { did -c $dname 5 } | else { did -b $dname 6,7 } | if ($a_get(pager) == on) { did -c $dname 9 } | if ($a_get(logger) == on) { did -c $dname 10 } | if ($a_get(silent) == on) { did -c $dname 11 } | if ($a_get(multi) == on) { did -c $dname 12 } | mas_combo load areasons | mas_combo load anicks
    if ($mas_combo(check,areasons,$a_get(reason))) { did -c $dname 3 $mas_combo(line,3,$a_get(reason)) | did -a $dname 4 Del } | else { did -a $dname 3 $a_get(reason) | did -c $dname 3 $did($dname,3).lines | did -a $dname 4 Add } | if ($mas_combo(check,anicks,$a_get(anick))) { did -c $dname 6 $mas_combo(line,6,$a_get(anick)) | did -a $dname 7 Del } | else { did -a $dname 6 $a_get(anick) | did -c $dname 6 $did($dname,6).lines | did -a $dname 7 Add }
  }
  if ($devent == sclick) {
    if ($did == 13) { if ($away) { away } | else { if ($did($dname,5).state) { a_save anick $did($dname,6) } | away - $+ $iif($did($dname,5).state,n) $+ $iif($did($dname,9).state,p) $+ $iif($did($dname,10).state,l) $+ $iif($did($dname,11).state,s) $+ $iif($did($dname,12).state,m) $did($dname,3) } } |  if ($did == 3) || ($did == 6) { did - $+ $iif($did($dname,$did) != $null,e,b) $dname $calc($did +1) | did -ra $dname $calc($did +1) $iif($mas_combo(check,$iif($did == 3,areasons,anicks),$did($dname,$did)),Del,Add) } | if ($did == 5) { if ($did($dname,$did).state) { did -e $dname 6,7 } | else { did -b $dname 6,7 } }
    if ($did == 4) || ($did == 7) { if ($did($dname,$did) == del) { a_save $iif($did == 4,areasons,anicks) $remove($a_get($iif($did == 4,areasons,anicks)),$did($dname,$calc($did -1)) $+ $chr(181)) | mas_combo load $iif($did == 4,areasons,anicks) | did -ra $dname $did Del | did -c $dname $iif($did == 4,3,6) 1 } | else { a_save $iif($did == 4,areasons,anicks) $a_get($iif($did == 4,areasons,anicks)) $+ $did($dname,$calc($did -1)) $+ $chr(181) | mas_combo load $iif($did == 4,areasons,anicks) | did -ra $dname $did Del | did -c $dname $iif($did == 4,3,6) $did($dname,$iif($did == 4,3,6)).lines } }
  }
  if ($devent == edit) { did - $+ $iif($did($dname,$did) != $null,e,b) $dname $calc($did +1) | did -ra $dname $calc($did +1) $iif($mas_combo(check,$iif($did == 3,areasons,anicks),$did($dname,$did)),Del,Add) }
}

on *:connect:{ if ($a_get(away) == on) { if ($a_get(multi) == on) { .quote away $a_get(reason) | $iif($a_get(anstat) == on,nick $a_get(anick)) } | elseif ($a_get(multi) == $network) { .quote away $a_get(reason) | $iif($a_get(anstat) == on,nick $a_get(anick)) } } }
on *:load:{ echo 1 -a * mIRC Away System loaded... | echo 1 -a * mIRC Away System is written by airliner. Email: webmaster@airliner.nl Website: http://www.airliner.nl/ }
on *:unload:{ echo 1 -a * mIRC Away System unloaded... | echo 1 -a * mIRC Away System was written by airliner. Email: webmaster@airliner.nl Website: http://www.airliner.nl/ }
on *:exit:{ a_save away off }
on *:text:*:#:{ if ($a_get(logger) == on) && ($a_get(away) == on) { mas_logwin | if ($me isin $1-) || ($a_get(nick) isin $1-) || ($a_get(anick) isin $1-) { if ($a_get(multi) == on) { aline $color(Nick text) @away.log $timestamp < $+ $nick $+ > $1- ( $+ $chan $+ @ $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Nick text) @away.log $timestamp < $+ $nick $+ > $1- ( $+ $chan $+ ) } } } }
on *:text:*:?:{ if ($a_get(logger) == on) && ($a_get(away) == on) { mas_logwin | if ($a_get(multi) == on) { aline $color(Nick text) @away.log $timestamp < $+ $nick $+ > $1- (PMSG@ $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Nick text) @away.log $timestamp < $+ $nick $+ > $1- (PMSG) } } }
on *:action:*:#:{ if ($a_get(logger) == on) && ($a_get(away) == on) { mas_logwin | if ($me isin $1-) || ($a_get(nick) isin $1-) || ($a_get(anick) isin $1-) { if ($a_get(multi) == on) { aline $color(Nick text) @away.log $timestamp * $nick $1- ( $+ $chan $+ @ $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Nick text) @away.log $timestamp * $nick $1- ( $+ $chan $+ ) } } } }
on *:action:*:?:{ if ($a_get(logger) == on) && ($a_get(away) == on) { mas_logwin | if ($a_get(multi) == on) { aline $color(Nick text) @away.log $timestamp * $nick $1- (PMSG@ $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Nick text) @away.log $timestamp * $nick $1- (PMSG) } } }
on *:notice:*:*:{ if ($a_get(logger) == on) && ($a_get(away) == on) && ($nick !iswm *Serv) { mas_logwin | if ($a_get(multi) == on) { aline $color(Notice text) @away.log $timestamp - $+ $nick $+ - $1- ( $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Notice text) @away.log $timestamp - $+ $nick $+ - $1- } } }
ctcp *:page:*:{ if ($a_get(pager) == on) && ($a_get(away) == on) { mas_logwin | if ($a_get(multi) == on) { aline $color(Ctcp text) @away.log $timestamp [ $+ $nick PAGE] $1- ( $+ $network $+ ) } | elseif ($a_get(multi) == $network) { aline $color(Ctcp text) @away.log $timestamp [ $+ $nick PAGE] $1- } } }