function expandReason(rowid,counter,bid)
{
   for(i=1;i<counter+1;i++)
   {
      complete_id = rowid + '-' + i;
 
      el = document.getElementById(complete_id);
      var display = el.style.display ? '' : 'none';
      el.style.display = display;
   }
   
   bl = document.getElementById(bid);
   
   var oldbutton = bl.src.substring(bl.src.lastIndexOf('\/')+1); 
   var newbutton = '';

   if(oldbutton == 'btn-close.gif')
   {
      newbutton = '/images/btn-open.gif';
   }
   else
   {
      newbutton = '/images/btn-close.gif';
   }
   bl.src = newbutton;
}

function expand_collapse_allreason()
{ 
   var myelement = document.getElementsByTagName("TR");
   for(var i=0;i<myelement.length;i++)
   {
      myelementid = String(myelement[i].id);
      if(myelementid.match("rc")=="rc" && myelementid.match("-")=="-")
      {
         myimgtmp = myelementid;
         myimgtmp = myimgtmp.replace(/rc/,"ac");
         myimgelementid = myimgtmp.split("-",1);
         if(substr_count(document.getElementById("ex_co_allreason").src,'/images/btn-expandallr.gif')>0)
         {
            document.getElementById(myelementid).style.display='';
            document.getElementById(myimgelementid[0]).src = '/images/btn-close.gif';
         }
         else
         {
            document.getElementById(myelementid).style.display='none';
            document.getElementById(myimgelementid[0]).src = '/images/btn-open.gif';
         }
      }
   }
   
   if(substr_count(document.getElementById("ex_co_allreason").src,'/images/btn-expandallr.gif')>0)
   {
      document.getElementById("ex_co_allreason").src = '/images/btn-hideallr.gif';
   }
   else
   {
      document.getElementById("ex_co_allreason").src = '/images/btn-expandallr.gif';
   }
}

function substr_count(str1,str2)
{
   var c = 0;
   for (var i=0;i<str1.length;i++) 
   {
      if (str2 == str1.substr(i,str2.length))
       c++;
   }
   return c; 
}