/* jQuery code for Home page slide */
$(document).ready(function () {
   SetMenu();
});

$(document).ready(function () {
	$('a.close1').click(function () {
		$(".btn_picture a").removeClass("active");
	});
	$('a.close2').click(function () {
		$(".btn_success a").removeClass("active");
	});
});

$(document).ready(function () {
    var $div = $('#slider1');
    var height = $div.height();
    $div.hide().css({ height : 0 });
    $('a.slideButton1,a.close1').click(function () {
		
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 600, complete: function () {
                $div.hide();
            } });
        } else {
            $div.show().animate({ height : height }, { duration: 600 });
        }
        return false;
    });
	$('a.slideButton2').click(function () {
		$(".btn_success a").addClass("active");
		$(".btn_picture a").removeClass("active");
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 600, complete: function () {
                $div.hide();
            } });
        } 
        return false;
    });
});

/**/

$(document).ready(function () {
    var $div = $('#slider2');
    var height = $div.height();
    $div.hide().css({ height : 0 });
    $('a.slideButton2,a.close2').click(function () {
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 600, complete: function () {
                $div.hide();
            } });
        } else {
            $div.show().animate({ height : height }, { duration: 600 });
        }
        return false;
    });
	$('a.slideButton1').click(function () {
		$(".btn_success a").removeClass("active");
		$(".btn_picture a").addClass("active");
        if ($div.is(':visible')) {
            $div.animate({ height: 0 }, { duration: 600, complete: function () {
                $div.hide();
            } });
        } 
        return false;
    });
});

/* end of jQuery code for slide */

/**/

$(document).ready(function() {
    $('input.reset_button').click(function() {
        return Clear_Form();
    });
    $('input.submit_button').click(function() {
        return submit_form();
    });
});


function Clear_Form()
{
    $('#aspnetForm')[0].reset();return false;

}
function submit_form() 
{
    var valid = true;
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtFirstName").attr('value')=="")
 {    
    $(".contactusform #first_name_error").show(); valid = false;
 }
 
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtLastName").attr('value')=="")
 {
     $(".contactusform #last_name_error").show(); valid = false;
 } 
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtEmailAdd").attr('value')=="")
 {
     $(".contactusform #email_error").show(); valid = false;
 } 
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtMailingAdd").attr('value')=="")
 {
     $(".contactusform #mailing_address_error").show(); valid = false;
 } 
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtCity").attr('value')=="")
 {
     $(".contactusform #city_state_zip_error").show(); valid = false; 
 } 
 else 
 {
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtZipCode").attr('value')=="")
    {
        $(".contactusform #city_state_zip_error").show(); valid = false;  
        }
}
 

if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtZipCode").attr('value').length!=5)
 {
     $(".contactusform #zip_error").show(); valid = false;
 }  
var elem = document.getElementById("ctl00_MiddleColumnPlaceHolder_ddlState");

if (elem.value==0)
{
    $(".contactusform #state_error").show(); valid = false;
}
 if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtCountry").attr('value')=="")
 {
     $(".contactusform #country_error").show(); valid = false;
 } 
if ($(".contactusform").find("input#ctl00_MiddleColumnPlaceHolder_txtPhoneNumber").attr('value')=="")
 {
     $(".contactusform #phone_number_error").show(); valid = false;
 }
return valid;
}


function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = "";
}
 
function setDefault() {
   if(document.getElementById('enterzip')!=null){
        if(document.getElementById('enterzip').value=="")
           document.getElementById('enterzip').value="Zip Code";
    }
   if(document.getElementById('enterzip2')!=null){
	if(document.getElementById('enterzip2').value=="")
       document.getElementById('enterzip2').value="Enter Zip Code";
     }
  }



/*==================================
	JQuery for Stylish Select
====================================*/
(function($){

	//add class of js to html tag
	$('html').addClass('js');

	//create cross-browser indexOf
	Array.prototype.indexOf = function (obj, start) {
		for (var i = (start || 0); i < this.length; i++) {
			if (this[i] == obj) {
				return i;
			}
		}
	}
	
	//utility methods
	$.fn.extend({
		getSetSSValue: function(value){
						if (value){
							//set value and trigger change event
							$(this).val(value).change();
							return this;
						} else {
							return selText = $(this).find(':selected').text();
						}
					},
		resetSS: function(){
						$this = $(this);
						$this.next().remove();
						//unbind all events and redraw
						$this.unbind().sSelect();
					}
	});

	$.fn.sSelect = function(options) {
	
		return this.each(function(){
			
			var defaults = {
				defaultText: 'Please select',
				animationSpeed: 0, //set speed of dropdown
				ddMaxHeight: '' //set css max-height value of dropdown
			};

			//initial variables
			var opts = $.extend(defaults, options),
				$input = $(this),
				$containerDivText = $('<div class="selectedTxt"></div>'),
				$containerDiv = $('<div class="newListSelected" tabindex="0"></div>'),
				$newUl = $('<ul class="newList"></ul>'),
				itemIndex = -1,
				currentIndex = -1,
				keys = [],
				prevKey = false,
				newListItems = '',
				prevented = false;
				
			//build new list
			$containerDiv.insertAfter($input);
			$containerDivText.prependTo($containerDiv);
			$newUl.appendTo($containerDiv);
			$input.hide();
		
			//test for optgroup
			if ($input.children('optgroup').length == 0){
				$input.children().each(function(i){
					var option = $(this).text();
					//add first letter of each word to array
					keys.push(option.charAt(0).toLowerCase());
					if ($(this).attr('selected') == true){
						opts.defaultText = option;
						currentIndex = i;
					}
					newListItems += '<li>'+option+'</li>';
				});
				//add new list items to ul
				$newUl.html(newListItems);
				newListItems = '';
				//cache list items object
				var $newLi = $newUl.children();
								
			} else { //optgroup
				$input.children('optgroup').each(function(i){
				
					var optionTitle = $(this).attr('label'),
						$optGroup = $('<li class="newListOptionTitle">'+optionTitle+'</li>');
						
					$optGroup.appendTo($newUl);

					var $optGroupList = $('<ul></ul>');

					$optGroupList.appendTo($optGroup);

					$(this).children().each(function(){
						++itemIndex;
						var option = $(this).text();
						//add first letter of each word to array
						keys.push(option.charAt(0).toLowerCase());
						if ($(this).attr('selected') == true){
							opts.defaultText = option;
							currentIndex = itemIndex;
						}
						newListItems += '<li>'+option+'</li>';
					})
					//add new list items to ul
					$optGroupList.html(newListItems);
					newListItems = '';
				});
				//cache list items object
				var $newLi = $newUl.find('ul li');
			
			}
			
			//get heights of new elements for use later
			var newUlHeight = $newUl.height()+0,
				containerHeight = $containerDiv.height()+0,
				newLiLength = $newLi.length;
		
			//check if a value is selected
			if (currentIndex != -1){
				navigateList(currentIndex, true);
			} else {
				//set placeholder text
				$containerDivText.text(opts.defaultText);
			}

			//decide if to place the new list above or below the drop-down
			function newUlPos(){
				var containerPosY = $containerDiv.offset().top,
					docHeight = jQuery(window).height(),
					scrollTop = jQuery(window).scrollTop();

					//if height of list is greater then max height, set list height to max height value
					if (newUlHeight > parseInt(opts.ddMaxHeight)) {
						newUlHeight = parseInt(opts.ddMaxHeight);
					}	

				containerPosY = containerPosY-scrollTop;
				if (containerPosY+newUlHeight >= docHeight){
					$newUl.css({top: '-'+newUlHeight+'px', height: newUlHeight});
					$input.onTop = true;
				} else {
					$newUl.css({top: containerHeight+'px', height: newUlHeight});
					$input.onTop = false;
				}
			}

			//run function on page load
			newUlPos();
			
			//run function on browser window resize
			$(window).resize(function(){
				newUlPos();
			});
			
			$(window).scroll(function(){
				newUlPos();
			});

			//positioning
			function positionFix(){
				$containerDiv.css('position','relative');
			}

			function positionHideFix(){
				$containerDiv.css('position','static');
			}
			
			$containerDivText.click(function(){
			
				if ($newUl.is(':visible')){
					$newUl.hide();
					positionHideFix()
					return false;
				}

				$containerDiv.focus();

				//show list
				$newUl.slideDown(opts.animationSpeed);
				positionFix();
				//scroll list to selected item
				$newUl.scrollTop($input.liOffsetTop);

			});
			
			$newLi.hover(
			  function (e) {
				var $hoveredLi = $(e.target);
				$hoveredLi.addClass('newListHover');
			  },
			  function (e) {
				var $hoveredLi = $(e.target);
				$hoveredLi.removeClass('newListHover');
			  }
			);

			$newLi.click(function(e){
				var $clickedLi = $(e.target);
				//update counter
				currentIndex = $newLi.index($clickedLi);
				//remove all hilites, then add hilite to selected item
				prevented = true;
				navigateList(currentIndex);
				$newUl.hide();
				$containerDiv.css('position','static');//ie
			});

			function navigateList(currentIndex, init){

				//get offsets
				var containerOffsetTop = $containerDiv.offset().top,
					liOffsetTop = $newLi.eq(currentIndex).offset().top,
					ulScrollTop = $newUl.scrollTop();
				
				//get distance of current li from top of list				
				if ($input.onTop == true){
					//if list is above select box, add max height value
					$input.liOffsetTop = (((liOffsetTop-containerOffsetTop)-containerHeight)+ulScrollTop)+parseInt(opts.ddMaxHeight);
				} else {
					$input.liOffsetTop = ((liOffsetTop-containerOffsetTop)-containerHeight)+ulScrollTop;
				}
				
				//scroll list to focus on current item
				$newUl.scrollTop($input.liOffsetTop);
				
				$newLi.removeClass('hiLite')
					.eq(currentIndex)
					.addClass('hiLite');
				var text = $newLi.eq(currentIndex).text();
				//page load
				if (init == true){
					$input.val(text);
					$containerDivText.text(text);
					return false;
				}
				$input.val(text).change();
				$containerDivText.text(text);

			};

			$input.change(function(event){
					$targetInput = $(event.target);
					//stop change function from firing 
					if (prevented == true){
						prevented = false;
						return false;
					}
					$currentOpt = $targetInput.find(':selected');
					currentIndex = $targetInput.find('option').index($currentOpt);
					navigateList(currentIndex, true);
				}
			);
			
			//handle up and down keys
			function keyPress(element) {
				//when keys are pressed
				element.onkeydown = function(e){
					if (e == null) { //ie
						var keycode = event.keyCode;
					} else { //everything else
						var keycode = e.which;
					}
					
					//prevent change function from firing
					prevented = true;

					switch(keycode)
					{
					case 40: //down
					case 39: //right
						incrementList();
						return false;
						break;
					case 38: //up
					case 37: //left
						decrementList();
						return false;
						break;
					case 33: //page up
					case 36: //home
						gotoFirst();
						return false;
						break;
					case 34: //page down
					case 35: //end
						gotoLast();
						return false;
						break;
					case 13:
					case 27:
						$newUl.hide();
						positionHideFix();
						return false;
						break;
					}

					//check for keyboard shortcuts
					keyPressed = String.fromCharCode(keycode).toLowerCase();
					var currentKeyIndex = keys.indexOf(keyPressed);
					if (typeof currentKeyIndex != 'undefined') { //if key code found in array
						++currentIndex;
						currentIndex = keys.indexOf(keyPressed, currentIndex); //search array from current index
						if (currentIndex == -1 || currentIndex == null || prevKey != keyPressed) currentIndex = keys.indexOf(keyPressed); //if no entry was found or new key pressed search from start of array
						navigateList(currentIndex);
						//store last key pressed
						prevKey = keyPressed;
						return false;
					}
				}
			}

			function incrementList(){
				if (currentIndex < (newLiLength-1)) {
					++currentIndex;
					navigateList(currentIndex);
				}
			}

			function decrementList(){
				if (currentIndex > 0) {
					--currentIndex;
					navigateList(currentIndex);
				}
			}

			function gotoFirst(){
				currentIndex = 0;
				navigateList(currentIndex);
			}
			
			function gotoLast(){
				currentIndex = newLiLength-1;
				navigateList(currentIndex);
			}

			$containerDiv.click(function(){
				keyPress(this);
			});

			$containerDiv.focus(function(){
				$(this).addClass('newListSelFocus');
				keyPress(this);
			});
			
			//hide list on blur
			$containerDiv.blur(function(){
			   $(this).removeClass('newListSelFocus');
			   $newUl.hide();
			   positionHideFix();
			});

			//add classes on hover
			$containerDivText.hover(function(e) {
				var $hoveredTxt = $(e.target);
				$hoveredTxt.parent().addClass('newListSelHover');
			  }, 
			  function(e) {
				var $hoveredTxt = $(e.target);
				$hoveredTxt.parent().removeClass('newListSelHover');
			  }
			);

			//reset left property and hide
			$newUl.css('left','0').hide();
			
		});
	  
	};

})(jQuery);

/* Stylish Select ready function */
$(document).ready(function(){
		$('#FADselectRadius, #selectStates, #month, #day, #year, #qus, #qus2, #my-dropdown2').sSelect();
});	

/*==================================
	JQuery video Carousels
====================================*/
(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {			
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			controlsShow:	true,
			controlsBefore:	'',
			controlsAfter:	'',	
			controlsFade:	true,
			firstId: 		'firstBtn',
			firstText: 		'First',
			firstShow:		false,
			lastId: 		'lastBtn',	
			lastText: 		'Last',
			lastShow:		false,				
			vertical:		false,
			speed: 			400,
			auto:			true,
			pause:			5000,
			continuous:		false
		}; 
		
		var options = $.extend(defaults, options);  
				
		this.each(function() {  
			var obj = $(this); 				
			var s = $("li", obj).length;
			var w = $("li", obj).width(); 
			var h = $("li", obj).height(); 
			obj.width(w); 
			obj.height(h); 
			obj.css("overflow","hidden");
			var ts = s-1;
			var t = 0;
			$("ul", obj).css('width',s*w);			
			if(!options.vertical) $("li", obj).css('float','left');
			
			if(options.controlsShow){
				var html = options.controlsBefore;
				if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>';
				html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>';
				html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>';
				if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';
				html += options.controlsAfter;						
				$(obj).after(html);										
			};
	
			$("a","#"+options.nextId).click(function(){		
				animate("next",true);
			});
			$("a","#"+options.prevId).click(function(){		
				animate("prev",true);				
			});	
			$("a","#"+options.firstId).click(function(){		
				animate("first",true);
			});				
			$("a","#"+options.lastId).click(function(){		
				animate("last",true);				
			});		
			
			function animate(dir,clicked){
				var ot = t;				
				switch(dir){
					case "next":
						t = (ot>=ts) ? (options.continuous ? 0 : ts) : t+1;						
						break; 
					case "prev":
						t = (t<=0) ? (options.continuous ? ts : 0) : t-1;
						break; 
					case "first":
						t = 0;
						break; 
					case "last":
						t = ts;
						break; 
					default:
						break; 
				};	
				
				var diff = Math.abs(ot-t);
				var speed = diff*options.speed;						
				if(!options.vertical) {
					p = (t*w*-1);
					$("ul",obj).animate(
						{ marginLeft: p }, 
						speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						speed
					);					
				};
				
				if(!options.continuous && options.controlsFade){					
					if(t==ts){
						$("a","#"+options.nextId).hide();
						$("a","#"+options.lastId).hide();
					} else {
						$("a","#"+options.nextId).show();
						$("a","#"+options.lastId).show();					
					};
					if(t==0){
						$("a","#"+options.prevId).hide();
						$("a","#"+options.firstId).hide();
					} else {
						$("a","#"+options.prevId).show();
						$("a","#"+options.firstId).show();
					};					
				};				
				
				if(clicked) clearTimeout(timeout);
				if(options.auto && dir=="next" && !clicked){;
					timeout = setTimeout(function(){
						animate("next",false);
					},diff*options.speed+options.pause);
				};
				
			};
			// init
			var timeout;
			if(options.auto){;
				timeout = setTimeout(function(){
					animate("next",false);
				},options.pause);
			};		
		
			if(!options.continuous && options.controlsFade){					
				$("a","#"+options.prevId).hide();
				$("a","#"+options.firstId).hide();				
			};				
			
		});
	  
	};

})(jQuery);

$(document).ready(function(){	
			$("#slider").easySlider();
});


/* jQuery code for FAQ Accordion */

/* jQuery code for FAQ Accordion */

var ddaccordion={
	
	contentclassname:{}, //object to store corresponding contentclass name based on headerclass

	expandone:function(headerclass, selected){ //PUBLIC function to expand a particular header
		this.toggleone(headerclass, selected, "expand")
	},

	collapseone:function(headerclass, selected){ //PUBLIC function to collapse a particular header
		this.toggleone(headerclass, selected, "collapse")
	},

	expandall:function(headerclass){ //PUBLIC function to expand all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':hidden').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).click()
		})
	},

	collapseall:function(headerclass){ //PUBLIC function to collapse all headers based on their shared CSS classname
		var $=jQuery
		var $headers=$('.'+headerclass)
		$('.'+this.contentclassname[headerclass]+':visible').each(function(){
			$headers.eq(parseInt($(this).attr('contentindex'))).click()
		})
	},

	toggleone:function(headerclass, selected, optstate){ //PUBLIC function to expand/ collapse a particular header
		var $=jQuery
		var $targetHeader=$('.'+headerclass).eq(selected)
		var $subcontent=$('.'+this.contentclassname[headerclass]).eq(selected)
		if (typeof optstate=="undefined" || optstate=="expand" && $subcontent.is(":hidden") || optstate=="collapse" && $subcontent.is(":visible"))
			$targetHeader.click()
	},

	expandit:function($targetHeader, $targetContent, config, isclicked){
		$targetContent.slideDown(config.animatespeed, function(){config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), isclicked)})
		this.transformHeader($targetHeader, config, "expand")
	},

	collapseit:function($targetHeader, $targetContent, config, isclicked){
		$targetContent.slideUp(config.animatespeed, function(){config.onopenclose($targetHeader.get(0), parseInt($targetHeader.attr('headerindex')), $targetContent.css('display'), isclicked)})
		this.transformHeader($targetHeader, config, "collapse")
	},

	transformHeader:function($targetHeader, config, state){
		$targetHeader.addClass((state=="expand")? config.cssclass.expand : config.cssclass.collapse) //alternate btw "expand" and "collapse" CSS classes
		.removeClass((state=="expand")? config.cssclass.collapse : config.cssclass.expand)
		if (config.htmlsetting.location=='src'){ //Change header image (assuming header is an image)?
			$targetHeader=($targetHeader.is("img"))? $targetHeader : $targetHeader.find('img').eq(0) //Set target to either header itself, or first image within header
			$targetHeader.attr('src', (state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse) //change header image
		}
		else if (config.htmlsetting.location=="prefix") //if change "prefix" HTML, locate dynamically added ".accordprefix" span tag and change it
			$targetHeader.find('.accordprefix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
		else if (config.htmlsetting.location=="suffix")
			$targetHeader.find('.accordsuffix').html((state=="expand")? config.htmlsetting.expand : config.htmlsetting.collapse)
	},

	urlparamselect:function(headerclass){
		var result=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)", "i")) //check for "?headerclass=2,3,4" in URL
		if (result!=null)
			result=RegExp.$1.split(',')
		return result //returns null, [index], or [index1,index2,etc], where index are the desired selected header indices
	},

	getCookie:function(Name){ 
		var re=new RegExp(Name+"=[^;]+", "i") //construct RE to search for target name/value pair
		if (document.cookie.match(re)) //if cookie found
			return document.cookie.match(re)[0].split("=")[1] //return its value
		return null
	},

	setCookie:function(name, value){
		document.cookie = name + "=" + value
	},

	init:function(config){
	document.write('<style type="text/css">\n')
	document.write('.'+config.contentclass+'{display: none}\n') //generate CSS to hide contents
	document.write('<\/style>')
	jQuery(document).ready(function($){
		ddaccordion.urlparamselect(config.headerclass)
		var persistedheaders=ddaccordion.getCookie(config.headerclass)
		ddaccordion.contentclassname[config.headerclass]=config.contentclass //remember contentclass name based on headerclass
		config.cssclass={collapse: config.toggleclass[0], expand: config.toggleclass[1]} //store expand and contract CSS classes as object properties
		config.htmlsetting={location: config.togglehtml[0], collapse: config.togglehtml[1], expand: config.togglehtml[2]} //store HTML settings as object properties
		config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
		config.onopenclose=(typeof config.onopenclose=="undefined")? function(){} : config.onopenclose //attach custom "onopenclose" event handler
		var lastexpanded={} //object to hold reference to last expanded header and content (jquery objects)
		var expandedindices=ddaccordion.urlparamselect(config.headerclass) || ((config.persiststate && persistedheaders!=null)? persistedheaders : config.defaultexpanded)
		if (typeof expandedindices=='string') //test for valid cookie ('string'), invalid being null or 1st page load
			expandedindices=expandedindices.replace(/c/ig, '').split(',') //if valid, change to array value
		var $subcontents=$('.'+config["contentclass"])
		if (!(expandedindices instanceof Array)) //check for invalid expandedindices value
			expandedindices=[]
		if (config["collapseprev"] && expandedindices.length>1)
			expandedindices=[expandedindices.pop()] //return last array element as an array (for sake of jQuery.inArray())
		$('.'+config["headerclass"]).each(function(index){ //loop through all headers
			if (/(prefix)|(suffix)/i.test(config.htmlsetting.location) && $(this).html()!=""){ //add a SPAN element to header depending on user setting and if header is a container tag
				$('<span class="accordprefix"></span>').prependTo(this)
				$('<span class="accordsuffix"></span>').appendTo(this)
			}
			$(this).attr('headerindex', index+'h') //store position of this header relative to its peers
			$subcontents.eq(index).attr('contentindex', index+'c') //store position of this content relative to its peers
			var $subcontent=$subcontents.eq(index)
			if (jQuery.inArray(index, expandedindices)!=-1){ //check for headers that should be expanded automatically
				if (config.animatedefault==false)
					$subcontent.show()
				ddaccordion.expandit($(this), $subcontent, config, false) //Last Boolean value sets 'isclicked' parameter
				lastexpanded={$header:$(this), $content:$subcontent}
			}  //end check
			else{
				$subcontent.hide()
				config.onopenclose($(this).get(0), parseInt($(this).attr('headerindex')), $subcontent.css('display'), false) //Last Boolean value sets 'isclicked' parameter
				ddaccordion.transformHeader($(this), config, "collapse")
			}
		})
		$('.'+config["headerclass"]).click(function(){ //assign behavior when headers are clicked on
				var $subcontent=$subcontents.eq(parseInt($(this).attr('headerindex'))) //get subcontent that should be expanded/collapsed
				if ($subcontent.css('display')=="none"){
					ddaccordion.expandit($(this), $subcontent, config, true) //Last Boolean value sets 'isclicked' parameter
					if (config["collapseprev"] && lastexpanded.$header && $(this).get(0)!=lastexpanded.$header.get(0)){ //collapse previous content?
						ddaccordion.collapseit(lastexpanded.$header, lastexpanded.$content, config, true) //Last Boolean value sets 'isclicked' parameter
					}
					lastexpanded={$header:$(this), $content:$subcontent}
				}
				else{
					ddaccordion.collapseit($(this), $subcontent, config, true) //Last Boolean value sets 'isclicked' parameter
				}
				return false
 	})
		config.oninit($('.'+config["headerclass"]).get(), expandedindices)
		$(window).bind('unload', function(){ //clean up and persist on page unload
			$('.'+config["headerclass"]).unbind('click')
			var expandedindices=[]
			$('.'+config["contentclass"]+":visible").each(function(index){ //get indices of expanded headers
				expandedindices.push($(this).attr('contentindex'))
			})
			if (config.persiststate==true){ //persist state?
				expandedindices=(expandedindices.length==0)? '-1c' : expandedindices //No contents expanded, indicate that with dummy '-1c' value?
				ddaccordion.setCookie(config.headerclass, expandedindices)
			}
		})
	})
	}
}

ddaccordion.init({ //top level headers initialization
	headerclass: "expandable",
	contentclass: "categoryitems",
	collapseprev: true,defaultexpanded: [4], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
	animatedefault: false,
	persiststate: false,
	toggleclass: ["", "openheader"],
	togglehtml: ["prefix", "", ""],
	animatespeed: "normal",
	oninit:function(headers, expandedindices){
	},
	onopenclose:function(header, index, state, isclicked){
	}
})

ddaccordion.init({ //2nd level headers initialization
	headerclass: "subexpandable",
	contentclass: "subcategoryitems",
	collapseprev: true,
	defaultexpanded: [0],
	animatedefault: false,
	persiststate: false,
	toggleclass: ["opensubheader", "closedsubheader"],
	togglehtml: ["none", "", ""],
	animatespeed: "normal",
	oninit:function(headers, expandedindices){
	},
	onopenclose:function(header, index, state, isclicked){
	}
})

//Initialize first demo:
ddaccordion.init({
	headerclass: "questions", //Shared CSS class name of headers group
	contentclass: "answers",
	collapseprev: true,defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
	animatedefault: false,
	persiststate: false,
	toggleclass: ["", "openquestions"],
	togglehtml: ["none", "", ""],
	animatespeed: "fast",
	oninit:function(expandedindices){
	},
	onopenclose:function(header, index, state, isclicked){
	}
})

/* */


/* */
