var openLayer;
var openBtn;

var openId;
var open = false;

$(function() {
  $(".qs_detail").hide();
  $(".qs_btn").click(function() {
     click($(this).attr("id"));
	});
});

function click(idStr)
{
  var id = idStr.charAt(1);
  
  if(id != openId)
  {
    $("#b"+openId).html("Read more...");
    $("#d"+openId).hide();  
    open = false;
  }
  
  if(open)
  {
    $("#b"+id).html("Read more...");
    $("#d"+id).hide();  
    open = false;
  }
  else
  {
    $("#b"+id).html("Close...");
    $("#d"+id).show();  
    open = true;
    //pageTracker._trackPageview('/quick-start-guide.'+id+'.phtml');
    _gaq.push(['_trackPageview', "/quick-start-guide."+id+".phtml"]);
  }
  
  openId = id;
}

function open(btn)
{
  if(openLayer!=undefined)
  {
    openLayer.hide();
    openBtn.text("Read more...");   
    btn.click(function() {
      open($(this));
    });      
  }
  
  openLayer = $(".qs_item:has(#"+btn.attr("id")+") > .qs_content > .qs_detail");
  openBtn = $("#"+btn.attr("id")+" > a");
  
  openLayer.show();
  openBtn.text("Close...");
  btn.click(function() {
     close($(this));
	});
}

function close(btn)
{
    openLayer.hide();
    openBtn.text("Read more...");   
    btn.click(function() {
      open($(this));
    });     
    
    openLayer = undefined;
    openBtn = undefined;
}
