function dsp(d,v)
{
   if (v==undefined)
   {
      return d.style.display;
   }
   else
   {
      d.style.display=v;
   }
}

function sh(d,v)
{
	if (v==undefined)
   {
      if (dsp(d) != 'none' && dsp(d) != '' )
      {
         return d.offsetHeight;
		}
      viz = d.style.visibility;
      d.style.visibility = 'hidden';
      o = dsp(d);
      dsp(d,'block');
      r = parseInt(d.offsetHeight);
      dsp(d,o);
      d.style.visibility = viz;
      return r;
   }
   else
   {
      d.style.height=v;
   }
}

s=7;
t=10;
function ct(d)
{
   d = document.getElementById(d);
   if (sh(d) > 0)
   {
      v = Math.round(sh(d)/d.s);
      v = (v<1) ? 1 :v ;
      v = (sh(d)-v);
      sh(d,v+'px');
      d.style.opacity = (v/d.maxh);
      d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
   }
   else
   {
      sh(d,0);
      dsp(d,'none');
      clearInterval(d.t);
	}
}

function et(d){
   d = document.getElementById(d);
   if(sh(d)<d.maxh)
   {
      v = Math.round((d.maxh-sh(d))/d.s);
      v = (v<1) ? 1 :v ;
      v = (sh(d)+v);
      sh(d,v+'px');
      d.style.opacity = (v/d.maxh);
      d.style.filter= 'alpha(opacity='+(v*100/d.maxh)+');';
   }
   else
   {
      sh(d,d.maxh);
      clearInterval(d.t);
	}
}

function cl(d)
{
   clearInterval(d.t);
	d.t = setInterval('ct("'+d.id+'")',t);
}

function ex(d)
{
   if(dsp(d)=='none')
   {
      dsp(d,'block');
      d.style.height='0px';
      clearInterval(d.t);
      d.t = setInterval('et("'+d.id+'")',t);
   }
}

function cc(n,v)
{
   s = n.className.split(/\s+/);
   for(p=0 ; p<s.length ; p++){
      if(s[p] == v+n.tc)
      {
         s.splice(p,1);
         n.className = s.join(' ');
         break;
      }
   }
}

//Accordian Initializer
function accordeon(d,s,tc)
{
   l=document.getElementById(d).getElementsByTagName('div');
   c=[];
   for(i=0 ; i<l.length ; i++)
   {
		h = l[i].id;
		if (h.substr(h.indexOf('-')+1, h.length) =='content')
      {
         c.push(h);
      }
	}
	sel = null;
	for(i=0 ; i<l.length ; i++)
   {
      h = l[i].id;
      if (h.substr(h.indexOf('-')+1, h.length) == 'header')
      {
         d = document.getElementById(h.substr(0,h.indexOf('-'))+'-content');
         n = h.substr(0,h.indexOf('-'));
         n1 = document.getElementById(n+'-header');
         if (n1.className.indexOf(tc) == -1)
         {
            d.style.display = 'none';
         }
         d.style.overflow = 'hidden';
			d.maxh = sh(d);
			d.s = ( s == undefined ? 7 : s);
			h = document.getElementById(h);
			h.tc = tc;
			h.c = c;
			h.onmouseover = function () {
         this.style.textDecoration = 'underline';
      }
			h.onmouseout = function () {
         this.style.textDecoration = 'none';
      }
			h.onclick = function()
         {
	         for (i=0 ; i<this.c.length ; i++)
            {
               cn = this.c[i];
               n = cn.substr(0, cn.indexOf('-'));
               var open = false;
               if ((n+'-header') == this.id)
               {
                  n1 = document.getElementById(n+'-header');
                  if (n1.className.indexOf(n1.tc) == -1)
                  {
                     open = true;
                  }
                  open = true;
               }
               if(open)
               {
                  ex(document.getElementById(n+'-content'));
						n = document.getElementById(n+'-header');
						cc(n,'__');
						n.className = n.className+' '+n.tc;
					}
               else
               {
						cl(document.getElementById(n+'-content'));
						cc(document.getElementById(n+'-header'),'');
					}
				}
			}
			if (h.className.match(/selected+/) != undefined)
			{
            sel=h;
         }
		}
	}
	if (sel!=undefined)
	{
	   sel.onclick();
	}
}

