$(document).ready(function() {
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('.slickbox').hide();
  $('.thw').toggle();
  $('.toggle_container').hide();

 // toggles the slickbox on clicking the noted link
 $('a.slick_strat_toggle').click(function() {
   $('.strat').toggle(400);
   $('.auth').hide();
   $('.order').hide();
   $('.prod').hide();
   $('.measure').hide();
   return false;
  });
 
 $('a.slick_auth_toggle').click(function() {
   $('.auth').toggle(400);
   $('.strat').hide();
   $('.order').hide();
   $('.prod').hide();
   $('.measure').hide();
   return false;
  });

 $('a.slick_order_toggle').click(function() {
   $('.order').toggle(400);
   $('.strat').hide();
   $('.auth').hide();
   $('.prod').hide();
   $('.measure').hide();
   return false;
  });

 $('a.slick_prod_toggle').click(function() {
   $('.prod').toggle(400);
   $('.strat').hide();
   $('.auth').hide();
   $('.order').hide();
   $('.measure').hide();
   return false;
  });

 $('a.slick_measure_toggle').click(function() {
   $('.measure').toggle(400);
   $('.strat').hide();
   $('.auth').hide();
   $('.order').hide();
   $('.prod').hide();
   return false;
  });
  
  
   // toggles the slickbox on clicking the noted link
 $('a.slick_thw_toggle').click(function() {
   $('.thw').toggle(400);
   $('.js').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });
  
 $('a.slick_taw_toggle').click(function() {
   $('.taw').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });

 $('a.slick_em_toggle').click(function() {
   $('.em').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });

 $('a.slick_aet_toggle').click(function() {
   $('.aet').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });  

 $('a.slick_et_toggle').click(function() {
   $('.et').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });  

 $('a.slick_jm_toggle').click(function() {
   $('.jm').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });

 $('a.slick_ra_toggle').click(function() {
   $('.ra').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.tk').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });
  
 $('a.slick_tk_toggle').click(function() {
   $('.tk').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.nb').hide();
   $('.krs').hide();
   return false;
  });  

 $('a.slick_nb_toggle').click(function() {
   $('.nb').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.krs').hide();
   return false;
  });
  
 $('a.slick_krs_toggle').click(function() {
   $('.krs').toggle(400);
   $('.js').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   return false;
  });

 $('a.slick_js_toggle').click(function() {
   $('.js').toggle(400);
   $('.krs').hide();
   $('.thw').hide();
   $('.taw').hide();
   $('.em').hide();
   $('.aet').hide();
   $('.et').hide();
   $('.jm').hide();
   $('.ra').hide();
   $('.tk').hide();
   $('.nb').hide();
   return false;
  });
  
  //Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click
	$("h3.trigger").toggle(function(){
		$(this).addClass("active");
		}, function () {
		$(this).removeClass("active");
	});

	//Slide up and down on click
	$("h3.trigger").click(function(){
		$(this).next(".toggle_container").slideToggle("slow");
	});
	
	//Anti-bot Email protection
  /*
      Based on this article:      
      http://www.html-advisor.com/javascript/hide-email-with-javascript-jquery/
  
      Example markup:
      ---------------
      
      <span class="email" title="Send me a letter!">me at mydomain dot com</span>
  
      Example code:
    -------------
    
    // Replaces all the matching elements with a <a href="mailto:..> tag.
      
    $('span.email').email();
      
  */
      
  jQuery.fn.email = function() {
      var at = / at /;
      var dot = / dot /g;
      this.each( function() {
          var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
          var title = jQuery(this).attr('title')
          $(this)
              .after('<a class="email" href="mailto:'+addr+'" title="'+title+'">'+ addr +'</a>')
              .remove();
      });
  };
  
  // Opens external links in a new window while maintaining XHTML strict
  $('a[href^="http://"]')
  .attr({
    target: "_blank", 
    title: "Opens in a new window"
  });


});