curSel="st";
tbc_clicked = false;
$('.topbar_item').click(function(){
	var curTop = $('#topbar_container').css('top');
	switch($(this).attr('id')){
		case "topbar_item_st":
			nextSel = "st";
			notSel = "og";
			notSel2 = "story";
		break;
		case "topbar_item_og":
			nextSel = "og";
			notSel = "st";
			notSel2 = "story";
		break;
		case "topbar_item_story":
			nextSel = "story";
			notSel = "st";
			notSel2 = "og";
		break;
	}
	if(curTop!='0px'){
		$('#topbar_container_'+nextSel).show();
		$('#topbar_container_'+notSel).hide();
		$('#topbar_container_'+notSel2).hide();
		$('#topbar_container').animate({"top": "0px"}, 'slow');
		$('#menu_bar').animate({"top": "6px"},'slow');
	} else {
		if(curSel==nextSel){
			$('#topbar_container').animate({"top": "-132px"}, 'slow');
			$('#menu_bar').animate({"top": "0px"},'slow');
		} else {
			$('#topbar_container_'+notSel).fadeOut(function(){
				$('#topbar_container_'+notSel2).fadeOut(function(){
					$('#topbar_container_'+nextSel).fadeIn();
				});
			});
			
		}
	}
	curSel = nextSel;
});



// TOPBAR ANIMATIONS
$('#topbar_close').click(function(){
	$('#topbar_container').animate({"top": "-132px"}, 'slow');
	$('#menu_bar').animate({"top": "0px"},'slow');
});
$('#topbar_container').click(function(){
	tbc_clicked = true;
});
$('html').click(function(){
	$('.gsc-input').css({'background-color':'#cfccc9;'})
	if(tbc_clicked==true){
		tbc_clicked=false;
	} else {
		$('#topbar_container').animate({"top": "-132px"}, 'slow');
		$('#menu_bar').animate({"top": "0px"},'slow');
	}
	
});


// SEARCH
$('#chapelsearch').focus(function(){ // USERNAME
	if($(this).val()=="search"){
		$(this).css({'cursor':'text'});
		$(this).css({'text-align':'left'});
	 	$(this).animate({'width':'160px'}, 'slow', function(){
			$(this).val("");
		});
	}
}).blur(function(){
	if($(this).val()==""){
		$(this).css({'cursor':'pointer'});
		$(this).css({'text-align':'center'});
		$(this).animate({'width':'50px'}, 'slow', function(){
			$(this).val("search");
		});
	}
});

$("#min_back").hover(function(){
	$("#backarrow").attr("src","/images/backarrow_hover.jpg");
}, function(){
	$("#backarrow").attr("src","/images/backarrow.jpg");
});

$("img.rollover").hover(function(){
	this.src = this.src.replace("_off","_on");
}, function(){
	this.src = this.src.replace("_on","_off");
});
