google.load("jquery", "1.3.2");

var active=0;
var closedwidth="7%";
var openwidth="72%";
var colordown="#fefefe";
var colors=['#6D999F','#A48FBF','#CAC377','#CA9F77','#DFB253'];

function lightup(){
	$(this).stop().css({backgroundColor:colors[$(".button").index(this)]});
	//$(this).css({'border-left':'1px solid black'});
}

function lightdown(){
	$(this).stop().animate({backgroundColor:colordown},{ queue:false, duration:700 });
	//$(this).find("h1").css({'border-bottom':'0px solid black'});
}

function openpanel(obj){
	obj.css({'cursor':'default'});
	active=$(".button").index(obj);
	//$(obj).children("h1").css({backgroundColor:colors[active]});
    //$(obj).find("h1").css({'border-bottom':'1px solid black'});
	$(obj).find(".content h2").css({backgroundColor:colors[active]});
	$(obj).css({backgroundColor:colordown});
	obj.stop().animate({"width": openwidth},{ queue:false, duration:1000, complete: function (){
	    $(".button:gt("+active+")").hover(lightup,lightdown).one('click',clicktab).css({'cursor':'pointer'});
		$(".button:lt("+active+")").hover(lightup,lightdown).one('click',clicktab).css({'cursor':'pointer'});
		obj.children(".content").show();
	}});
}

function closepanel(obj){
    $(obj).children("h1").css({backgroundColor:colordown});
	obj.children(".content").hide();
	obj.stop().animate({"width":closedwidth},{ queue:false, duration:1000 });
}

function clicktab(){
	$('.button').unbind();
    closepanel($(".button:eq("+active+")"));
	openpanel($(this));
}

function init(){
    $(".content").hide();
    //$("#buttons").corner();
    //$(".button h1").corner();  
}

$(document).ready(function() {
	init();
	openpanel($(".button:eq(0)"));
});
