$(function(){ 
	
	/*--------Global JS----------*/
	
	// Downloads
  //---------------------//
  /*$("#downloads-menu h3 a").toggle(
    function(){
      $(this).addClass("active")
      $(".dl-dropdown").show();
    },
    function(){
      $(this).removeClass("active")
      $(".dl-dropdown").hide();
  });*/
    
  // Email form goodness
  //--------------------//
  $(".email-address").toggleVal({
      focusClass: 'tv-focused',
      changedClass: 'tv-changed',
      populateFrom: 'default',
      text: 'your email address',
      removeLabels: false,
      sticky: false
  });

  // Add class "first"
  //--------------------//
	$("ul.thumbnail-list li:first-child").addClass("first");
	
	// Modal Windows
  //---------------------//
	$(".modal-vimeo").colorbox({iframe:true, innerHeight:338, innerWidth:600});
	$('a[rel="grouped"]').colorbox({transition:"none", maxWidth:"90%"});
	
	// Show/Hide Content
	$("a.sh-button").click(function(){
		var $e = $(this);
		var $id = $e.attr("href");
		
		// if the show button was clicked
		if ($e.hasClass("sh-show")){
			$e.hide()			// hide self
			$($id).show()	// show box
		}
		// otherwise, the hide button was clicked
		else {
			$($id).hide() // hide box
			$("a.sh-show[href="+$id+"]").show() // show the "show" button
		}
		return false;
	});
	
	// Tweets
	//--------------------//
	if ($("#tweets").length > 0){
	 	// get the twitter search term
		var tweet_query = $("#tweet-query").attr("title"); 
		
		$("#tweets").tweet({
			avatar_size: 48,
			count: 4,
			query: tweet_query,
			loading_text: "One moment... we're loading the tweets!"
		});   
	};
	
	
	// Testimonial Slider
	//--------------------//
	if ($(".testimonials-slider").length > 0){
		$('.testimonials-slider').cycle({
		  timeout: 0,
		  fx:     'fade', 
		  speed:  'fast',
		  pager:  '.ts-nav',
		  before: function(){$(this).parent().height($(this).height());},
		  pagerAnchorBuilder: function(idx, slide) { return '<a class="btn" href="#">' + (idx+1) + '</a>'; } 
		});
	};
	

});
