change text on label based on toggle?

change text on label based on toggle?

Hi All. I have a div that is either shown or hidden via the toggle function and controlled by a click event on a label.

What I am trying to do is change the label text to display either "open" or "close" based on whether the div is shown or hidden. Having trouble pinning down the syntax... have pasted what I have so far below...

Many thanks in advance!

<script type="text/javascript">
$(document).ready(function(){

$('#lblpi').click(function () {
$('#divpi').toggle("slow");
var lblpi = $('#lblpi');
var displaystatus = $('#divpi').css("display");

/ if (displaystatus == "none") {
lblpi.text("open");
}else{
lblpi.text("close");
}

});
});
</script>

In my page I have :

<label id="lblpi">open</label>
<div id="divpi" style="display:none;">
some info here
</div>