var ContentWidth = 550;
var TimeToSlide =200.0;

var openAccordion = '';
var openPanel = '';
var expand=0;
function tabArea()
	{
		state=false;
		md();
	}

function md()
{
	
	document.getElementById("panel1").style.width="303px";
	document.getElementById("tab1").style.width="302px";
	document.getElementById("tab2").style.width="302px";
	document.getElementById("tab3").style.width="302px";
	document.getElementById("panel1").style.height="245px";
	document.getElementById("panel1Top").style.width="303px";
	document.getElementById("Accordion1Content").style.width = '0px';
	document.getElementById("Accordion1Content").style.display = 'none';
	document.getElementById("panel2").style.width="303px";
	document.getElementById("panel2").style.height="245px";
	document.getElementById("panel2Top").style.width="303px";
	document.getElementById("Accordion2Content").style.width = '0px';
	document.getElementById("Accordion2Content").style.display = 'none';
	document.getElementById("panel3").style.width="303px";
	document.getElementById("panel3").style.height="245px";
	document.getElementById("panel3Top").style.width="303px";
	document.getElementById("Accordion3Content").style.width = '0px';
	document.getElementById("Accordion3Content").style.display = 'none';
	
}	
	
function runAccordion(index)
{
	if(expand== index)
	{
	return;
	}
	
  var nID = "Accordion" + index + "Content";
  var cID = "Accordion" + expand + "Content";
 
  //if(openAccordion == nID)
    //nID = '';
   
//setTimeout("animate(" 
    //+ new Date().getTime() + "," + TimeToSlide + ",'" 
   // + cID + "','" + nID + "','"+ index +"')", 33);
	animate(new Date().getTime(), TimeToSlide, cID, nID, index);
  
  openAccordion = nID;
  expand= index;
}
function animate(lastTick, timeLeft, closingId, openingId, ind)
{  
	//if(expand!= ind)
	//{
	//return;
	//}
	var myId="panel" + ind;
	var myTop="panel" + ind +"Top";
  var curTick = new Date().getTime();
  var elapsedTicks = curTick - lastTick;
  
  var opening = (openingId == '') ? 
      null : document.getElementById(openingId);
  var closing = (closingId == '') ? 
      null : document.getElementById(closingId);
 
  if(timeLeft <= elapsedTicks)
  {
    if(opening != null)
      opening.style.width = ContentWidth + 'px';
    
    if(closing != null)
    {
      closing.style.display = 'none';
      closing.style.width = '0px';
    }
    return;
  }
 
  timeLeft -= elapsedTicks;
  var newClosedWidth = 
      Math.round((timeLeft/TimeToSlide) * ContentWidth);

  if(opening != null)
  {
    if(opening.style.display != 'block')
      opening.style.display = 'block';
	  if(myId != "panel1")
	  {
	  	document.getElementById("panel1").style.width="180px";
		document.getElementById("tab1").style.width="180px";
		document.getElementById("panel1").style.height="245px";
		document.getElementById("panel1Top").style.width="180px";
		}
	if(myId != "panel2")
	{
	  document.getElementById("panel2").style.width="180px";
	  document.getElementById("tab2").style.width="180px";
	  document.getElementById("panel2").style.height="245px";
	  document.getElementById("panel2Top").style.width="180px";
	  }
	 if(myId != "panel3")
	  {
	  document.getElementById("panel3").style.width="180px";
	  document.getElementById("tab3").style.width="180px";
	  document.getElementById("panel3").style.height="245px";
	  document.getElementById("panel3Top").style.width="180px";
	  }
	  document.getElementById(myId).style.width="0px";
	  document.getElementById(myId).style.height="0px";
	  document.getElementById(myTop).style.width="550px";
	  
	  
    opening.style.width = 
        (ContentWidth - newClosedWidth) + 'px';
  }
  
  if(closing != null)
    closing.style.width = newClosedWidth + 'px';

 //setTimeout("animate(" + curTick + "," + timeLeft + ",'" 
   //+ closingId + "','" + openingId + "','"+ ind + "')", 111);
	animate(curTick, timeLeft, closingId, openingId, ind);
	  //expand= ind;
}
//runAccordion(1);

