var doc = window.document,
    cats = ['cat46subs', '5subs', 'cat5subs', 'cat7subs'],
    nowCat;

function changeCategory(id)
{
 var elm = $('#' + id);
 nowSubCat = id;

 if(elm.parent() != null)
 {
  nowCat = elm.parent().attr('id');

  var pflag = false;
  for(var i = 0, ilen = cats.length; i < ilen; i++)
  {
   if(cats[i] == nowCat)
   {
     pflag = true;
     break;
   }
  }

  var cid = id + 'cat';
  if(pflag)
      cid = nowCat.replace(/subs$/, 'cat');

  var p = $('#' + cid + '>a>img');
  p.attr('src', p.attr('src').replace('_new', '').replace('-o', '').replace('-trans.png', '-o-trans.png'));
  
 }
 else
 {
  nowCat = null;
 }

 elm.css({
  'font-weight': 'bold',
  'color': 'red',
  'text-decoration': 'none',
  'cursor': 'default'
 });
 elm.attr('href', 'javascript:void(0);');

 catClick(nowCat);

}

function catClick(id)
{
 for(var i = 0, ilen = cats.length; i < ilen; i++)
 {
  var elm = doc.getElementById(cats[i]);

  if(id == cats[i] || nowCat == cats[i])
  {
    elm.style.display = 'block';
  }
  else
  {
	if(elm != null) elm.style.display = 'none';
  }
 }
}

