// Javascript effects for digitalExpress theme

jQuery(document).ready(function($) {
	// function to hide the photo
	// as the document is loaded
	jQuery('#photo').hide();
});

jQuery(window).load(function () {
	// once all the document has loaded
	// fade in the photo
	jQuery('#photo').fadeIn(750);
});

//comments slide in out
function showdelay() {
	document.getElementById("prev-next-links").style.marginBottom = '20px';
}
function hidedelay() {
	document.getElementById("prev-next-links").style.marginBottom = '0px';
}
function toggle() {
	var x=document.getElementById("prev-next-links").style.marginBottom;
	if ( x != '20px' ) {
		setTimeout('showdelay();',0);
	}
	else {
		setTimeout('hidedelay();',200);
	}
}

jQuery(document).ready(function($) {
        // the div's that will be hidden/shown
	var panel = $("#section");
	var panel2 = $("#respond");
	var panel3 = $(".commentlist");
	//the button that will toggle the panel
	var button = $("a#show");
	// do you want the panel to start off collapsed or expanded?
	var initialState = "collapsed"; // "expanded" OR "collapsed"
	// the class added when the panel is hidden
	var activeClass = "hidden";
	// the text of the button when the panel's expanded
	var visibleText = "hide comments";
	// the text of the button when the panel's collapsed
	var hiddenText = "show comments";
        //---------------------------
	// don't    edit    below    this    line,<
	// unless you really know what you're doing
	//---------------------------</p>
	if($.cookie("panelState") == undefined) {
		
$.cookie("panelState", initialState, { path: '/' });
}

var state = $.cookie("panelState");

if(state == "collapsed") {
document.getElementById("prev-next-links").style.marginBottom="0px";

panel.hide();
panel2.hide();
panel3.hide();
button.html(hiddenText);
button.addClass(activeClass);

}

button.click(function(){
					  
if($.cookie("panelState") == "expanded") {
$.cookie("panelState", "collapsed", { path: '/' });
button.html(hiddenText);
button.addClass(activeClass);

} else {
$.cookie("panelState", "expanded", { path: '/' });
button.html(visibleText);
button.removeClass(activeClass);
}

panel.slideToggle("fast");
panel2.slideToggle("fast");
panel3.slideToggle("fast");
toggle()
return false;
});
});
