(function () { //Protect global namespace

   var readCookie = function (name) {
   	var nameEQ = name + "=";
   	var ca = document.cookie.split(';');
   	for(var i=0;i < ca.length;i++) {
   		var c = ca[i];
   		while (c.charAt(0)==' ') c = c.substring(1,c.length);
   		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   	}
   	return null;
   }
   
   var createCookie = function (name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


   ddaccordion.init({
   	headerclass: "expandable", //Shared CSS class name of headers group that are expandable
   	contentclass: "categoryitems", //Shared CSS class name of contents group
   	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
   	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
   	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
   	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
   	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
   	animatedefault: false, //Should contents open by default be animated into view?
   	persiststate: true, //persist state of opened contents within browser session?
   	toggleclass: ["", "expanded"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
   	togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
   	animatespeed: "normal", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
   	oninit:function(expandedindices){ //custom code to run when headers have initalized
   		/*
//do nothing
		var dapage = window.location.href.split("/").pop();
		if(dapage != ""){
	  		$('.categoryitems a[href*='+ '/' + dapage +']').addClass('currentpage').parent().parent().prev().click().next().stop(true,true);
		}
		if(dapage == 'mobile-access-unit-truck.cfm'){
			$('#first-menu').addClass('expanded');	
		}
		else if(dapage == 'mobile-access-unit-railcar.cfm'){
			$('#second-menu').addClass('expanded');		
		}
*/
   	},
   	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
   		//do nothing
   	}
   })
   // ddaccordion.init({
   //    revealtype: "click",
   //    collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
   //    defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content
   //    animatedefault: false, //Should contents open by default be animated into view?
   //    persiststate: true, //persist state of opened contents within browser session?
   //    toggleclass: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
   //    togglehtml: ["prefix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
   //    animatespeed: "normal" //speed of animation: "fast", "normal", or "slow"
   // });
   // var expanded = readCookie('expandable');
   // $(document).ready(function () {ddaccordion.toggleone('expandable', expanded.substring(0, expanded.length-1 ));});




})();

//Used on kudos pages; shows the 'read more' and 'read less' links
$(document).ready(function() {
  // hides the slickbox as soon as the DOM is ready
  // (a little sooner than page load)
  $('.slickbox').hide();
  // shows the slickbox on clicking the noted link
  $('a.slick-show').click(function() {
    $('.slickbox').show('slow');
    return false;
  });
  // hides the slickbox on clicking the noted link
  $('a.slick-hide').click(function() {
    $('#slickbox,.slickbox').hide('fast');
    return false;
  });
  // toggles the slickbox on clicking the noted link
  $('a.slick-toggle').click(function() {
    $(this).parents().eq(2).find('.slickbox').slideDown(400);
    $(this).fadeOut(400);
  });
  $('a.less').click(function(){
    $(this).parents().eq(1).slideUp(400);
    $('a.slick-toggle').fadeIn(400);
  });
});


