/*
 * A jQuery slider on cookies powered by jQuery (http://www.jquery.com)
 * 
 * Based on original code written by Bram Van der Sype (http://www.bramme.net/).
 * 
 * For more info visit http://www.bramme.net/2008/09/a-jquery-slider-on-cookies/
 *
 * Adapted for Miva Merchant by Matt Zimmermann (http://www.mivamerchant.com/) - Version 1.50.
*/

$(document).ready(function(){
	// the div that will be hidden/shown
	var panelUN = $("div.panelUN");
	var panelPW = $("div.panelPW");
	
	//the button that will toggle the panel
	var buttonUN = $("#show_un");
	var buttonPW = $("#show_pw");
	
	// 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 = "hid";
	
	// the text of the button when the panel's expanded
	var visibleText = "Click Here";
	
	// the text of the button when the panel's collapsed
	var hiddenText = "Click Here";

//---------------------------
// Don't edit below this line, unless you really know what you're doing.
// To use the cookie funtions, uncomment them below.
//---------------------------
	$.cookie("panelStateUN", initialState);
/*
 if($.cookie("panelStateUN") == undefined){
		$.cookie("panelStateUN", initialState);
	}
*/
	var stateUN = $.cookie("panelStateUN");
	if(stateUN == "collapsed") {
		panelUN.hide();
		buttonUN.text(hiddenText);
		buttonUN.addClass(activeClass);
	}
	buttonUN.click(function(){
		if($.cookie("panelStateUN") == "expanded"){
			$.cookie("panelStateUN", "collapsed");
			buttonUN.text(hiddenText);
			buttonUN.addClass(activeClass);
		} else {
			$.cookie("panelStateUN", "expanded");
			buttonUN.text(visibleText);
			buttonUN.removeClass(activeClass);
		}
		panelUN.slideToggle("slow");
		return false;
	});

	$.cookie("panelStatePW", initialState);
/*
	if($.cookie("panelStatePW") == undefined){
		$.cookie("panelStatePW", initialState);
	}
*/
	var statePW = $.cookie("panelStatePW");
	if(statePW == "collapsed") {
		panelPW.hide();
		buttonPW.text(hiddenText);
		buttonPW.addClass(activeClass);
	}
	buttonPW.click(function(){
		if($.cookie("panelStatePW") == "expanded"){
			$.cookie("panelStatePW", "collapsed");
			buttonPW.text(hiddenText);
			buttonPW.addClass(activeClass);
		} else {
			$.cookie("panelStatePW", "expanded");
			buttonPW.text(visibleText);
			buttonPW.removeClass(activeClass);
		}
		panelPW.slideToggle("slow");
		return false;
	});
});

