$j(function(){

    // automaitcally send these profiles to old case status
   var _old = [
   ],
   // automatically send these profiles to new case status
   _new = [ 
      172,
	  173
   ],
   
   // Their choice: all other accounts
   url = {
     _old   : 'https://www.ga.afhts.com/share/production/my_cases.php',
     _new   : '/share/production/proc_casestatus.php',
     _popup : '/share/production/proc_casestatus_popup.php'
   },
   $csDialog  = $j('#testNewCases').dialog({autoOpen : false, width: 500, height: 350, modal : true, title : 'My Cases' }),
   $link      = $j('#myCasesLink'),
   $button    = $csDialog.find('button'),
   profile_id = parseInt($j('#profile_id').val()),
   user_id    = $j('#user_id').val();

   // click 'My Cases' Link
   $link.click(function(){

      // send profiles in _old array to old case status
      if($j.inArray(profile_id, _old) !== -1){
         return MAIN_OpenSecurePage(url._old);
      }

      // send profiles in _new array to new case status
      if($j.inArray(profile_id, _new) !== -1){
         return MAIN_OpenSecurePage(url._new);
      }

      // everyone else can choose
      $j.post(url._popup, {getid : user_id}, function(d){
         if(d == '1'){
            // send user to new case status
            MAIN_OpenSecurePage(url._new);
         } else {
            // give user choice
            $csDialog.dialog('open');
         }
      });
   });

  // click 'GO TO CASE STATUS' button in dialog
  $button.click(function(){

      $csDialog.dialog('close');

      // did they choose to go to new case status?
      if($csDialog.find("input[type=radio]:eq(1)").attr('checked')){
         // send user to old case status
         MAIN_OpenSecurePage(url._old);
      } else { 
         // send user to new case status
         $j.post(url._popup, {setid : user_id}, function(){
             MAIN_OpenSecurePage(url._new);
         });
      }
   });

});
