jQuery(document).ready(function() {

	// Document Ready Stuff Below (jQuery)
	
	/* ----- Activate Quovolver ----- */
	jQuery('#quote_container blockquote').quovolver(800, 10000);

	/* ----- Table of Contents ----- */
	
	jQuery('.table_of_contents_btn').addClass('active').click(function() {
	
		jQuery(this).toggleClass('active');
		jQuery('.table_of_contents').slideToggle();
		return false;
		
	});
	
	jQuery('.table_of_contents a').anchorAnimate();

	/* ----- Activate Popup ----- */

	jQuery('.list-careermatch a').lightBox();
	
	/* ----- Activate Popup ----- */
	
	equalHeight(jQuery('.charts_desc, .charts'));
	
	jQuery('.charts_desc .graph_item_01 .info_box').clone()
		.insertAfter('.charts .graph_item_01 .target');
	jQuery('.charts_desc .graph_item_02 .info_box').clone()
		.insertAfter('.charts .graph_item_02 .target');
	jQuery('.charts_desc .graph_item_03 .info_box').clone()
		.insertAfter('.charts .graph_item_03 .target');
	jQuery('.charts_desc .graph_item_04 .info_box').clone()
		.insertAfter('.charts .graph_item_04 .target');
	jQuery('.charts_desc .graph_item_05 .info_box').clone()
		.insertAfter('.charts .graph_item_05 .target');
	jQuery('.charts_desc .graph_item_06 .info_box').clone()
		.insertAfter('.charts .graph_item_06 .target');
	
	jQuery('.target').popup();
	
	/* ----- Wrap Comments ----- */
	
	jQuery('.comment-body').each(function() {
		jQuery(this).find('p').wrapAll('<div class="the_comment"></div>');
	});
	jQuery('.the_comment').append('<span class="comment_image"></span>');
	
	/* ----- Media Page Shit ----- */
	
	jQuery('#media .flashmovie').appendTo('#media_container').hide().filter(':first').show();
	
	jQuery('#media_listing li').filter(':first').addClass('active');
	
	/*
	jQuery(function(){
        jQuery('#media_listing li').click(function(){
            list_index = jQuery('.mylist li').index(this)+1;
            jQuery('.active').removeClass('active');
            jQuery('.object_selection').removeClass('object_selection');
            jQuery(this).addClass('active');
            jQuery('#media_container object:nth-child('+list_index+')').addClass('object_selection');
            alert(jQuery('.flashmovie:nth-child('+list_index+')').attr('id'))
        });
    });
	*/
	
	jQuery('#media_listing li').click(function() {
		jQuery('#media_listing li').removeClass('active');
		jQuery(this).addClass('active');
		
		jQuery('#media .flashmovie').fadeOut();
		
        jQuerythis = this;
        jQuery(this).parent().children().each( function( i ) {
			if ( jQuerythis == this ) {
				jQuery('#media .flashmovie:eq('+(i)+')').fadeIn();
			}
        }); 		
	});
	
	/* ----- Homepage Graph Hover Bindings ----- */
		
	jQuery('.graph_item_01').hover(
		function() { jQuery('.graph_item_01').addClass('active'); }, 
		function() { jQuery('.graph_item_01').removeClass('active'); }
	);
	
	jQuery('.graph_item_02').hover(
		function() { jQuery('.graph_item_02').addClass('active'); },
		function() { jQuery('.graph_item_02').removeClass('active'); }
	);
	
	jQuery('.graph_item_03').hover(
		function() { jQuery('.graph_item_03').addClass('active'); },
		function() { jQuery('.graph_item_03').removeClass('active'); }
	);
	
	jQuery('.graph_item_04').hover(
		function() { jQuery('.graph_item_04').addClass('active'); },
		function() { jQuery('.graph_item_04').removeClass('active'); }
	);
	
	jQuery('.graph_item_05').hover(
		function() { jQuery('.graph_item_05').addClass('active'); },
		function() { jQuery('.graph_item_05').removeClass('active'); }
	);
	
	jQuery('.graph_item_06').hover(
		function() { jQuery('.graph_item_06').addClass('active'); },
		function() { jQuery('.graph_item_06').removeClass('active'); }
	);
	
	/* ----- number chart ----- */
	
	jQuery('.charts_desc .numbers').click(function() { return false; });
	
	jQuery('.graph_vert_01').hover(
		function() { jQuery('.graph_vert_01').addClass('active'); },
		function() { jQuery('.graph_vert_01').removeClass('active'); }
	);
	
	jQuery('.graph_vert_02').hover(
		function() { jQuery('.graph_vert_02').addClass('active'); },
		function() { jQuery('.graph_vert_02').removeClass('active'); }
	);
	
	jQuery('.graph_vert_03').hover(
		function() { jQuery('.graph_vert_03').addClass('active'); },
		function() { jQuery('.graph_vert_03').removeClass('active'); }
	);
	
	jQuery('.graph_vert_04').hover(
		function() { jQuery('.graph_vert_04').addClass('active'); },
		function() { jQuery('.graph_vert_04').removeClass('active'); }
	);
	
	jQuery('.graph_vert_05').hover(
		function() { jQuery('.graph_vert_05').addClass('active'); },
		function() { jQuery('.graph_vert_05').removeClass('active'); }
	);
	
	/* ----- Accordion Sidebar Items 2 ----- */
	
	jQuery('.product_details').hide();
	
	jQuery('.view_details a').addClass('accordion closed').click(function() {
		jQuery(this).toggleClass('open').toggleClass('closed').parent().parent().parent().next('.product_details').slideToggle();
		return false;
	});	

	/* ----- drop down login form ----- */
	
	jQuery('#login_error').animate({opacity: 1.0}, 3000).slideUp('slow', function() { jQuery(this).remove(); });
	
	/* ----- drop down site menu ----- */
	
	// initiation stuff
	var btn = '#menu span.network a';
	var list = '#site_listing';
	var tr = '#site_listing tr';
	
	// dropdown btn 
	jQuery(btn).click(function () {
      if (jQuery(list).is(':hidden')) jQuery(list).fadeIn();
      else jQuery(list).fadeOut();
      return false;
    });
    
    // slide up on mouseOut from menu
	jQuery(list).hover( 
		function() { },
  		function() { jQuery(this).animate({opacity: 1.0}, 500).fadeOut();
    });
    
    // give table rows hover effects
	jQuery(tr).hover(
	  function () { jQuery(this).addClass('hover'); },
	  function () { jQuery(this).removeClass('hover'); }
	);
	
	
	/* ----- footer entire block clickable ----- */
	jQuery('#footer_links li').click(function() {
		window.location=jQuery(this).find('a').attr('href');
		return false;
	});
	
	
	/* ----- equal height banner elements ----- */
	
	// fund number of elements
	// var banElem = jQuery('.section_element').size();
	
	// set proper widths and heights
	jQuery('.section_element').css({ height: jQuery('#banner_menu').height() });
	// jQuery('#section_wrap').css({ width: ((jQuery('.section_element').width()) * (banElem)) });
	
	
	/* ----- banner scroller ----- */
	
	var jQuerypanels = jQuery('#banner .section_element');
	var jQuerycontainer = jQuery('#banner #section_wrap');
	
	// if false, we'll float all the panels left and fix the width 
	// of the container
	var horizontal = true;
	
	// float the panels left if we're going horizontal
	if (horizontal) {
	  jQuerypanels.css({
	    'float' : 'left',
	    'position' : 'relative' // IE fix to ensure overflow is hidden
	  });
	  
	  // calculate a new width for the container (so it holds all panels)
	  jQuerycontainer.css('width', jQuerypanels[0].offsetWidth * jQuerypanels.length);
	}
	
	// collect the scroll object, at the same time apply the hidden overflow
	// to remove the default scrollbars that will appear
	var jQueryscroll = jQuery('#banner #section_window').css('overflow', 'hidden');
		
	// handle nav selection
	function selectNav() {
	  jQuery(this)
	    .parents('ul:first')
	      .find('li')
	        .removeClass('selected')
	      .end()
	    .end()
	    .parent().addClass('selected');
	}
	
	jQuery('#banner').find('a').click(selectNav);
	
	// go find the navigation link that has this target and select the nav
	function trigger(data) {
	  var el = jQuery('#banner #banner_menu').find('a[hrefjQuery="' + data.id + '"]').get(0);
	  selectNav.call(el);
	}
	
	if (window.location.hash) {
	  trigger({ id : window.location.hash.substr(1) });
	} else {
	  jQuery('#banner #banner_menu a:first').click();
	}
	
	// offset is used to move to *exactly* the right place, since I'm using
	// padding on my example, I need to subtract the amount of padding to
	// the offset.  Try removing this to get a good idea of the effect
	var offset = parseInt((horizontal ? 
	  jQuerycontainer.css('borderSizeLeft') : 
	  jQuerycontainer.css('borderSizeRight')) 
	  || 0) * -1;
	
	
	var scrollOptions = {
	  target: jQueryscroll, // the element that has the overflow
	  
	  // can be a selector which will be relative to the target
	  items: jQuerypanels,
	  
	  navigation: '#banner_menu a',
	  
	  // selectors are NOT relative to document, i.e. make sure they're unique
	  prev: 'img.left', 
	  next: 'img.right',
	  
	  // allow the scroll effect to run both directions
	  axis: 'xy',
	  
	  onAfter: trigger, // our final callback
	  
	  offset: offset,
	  
	  // duration of the sliding effect
	  duration: 300,
	  
	  // easing - can be used with the easing plugin: 
	  // http://gsgd.co.uk/sandbox/jquery/easing/
	  easing: 'swing'
	};
	
	// apply serialScroll to the slider - we chose this plugin because it 
	// supports// the indexed next and previous scroll along with hooking 
	// in to our navigation.
	jQuery('#banner').serialScroll(scrollOptions);
	
	// now apply localScroll to hook any other arbitrary links to trigger 
	// the effect
	jQuery.localScroll(scrollOptions);
	
	// finally, if the URL has a hash, move the slider in to position, 
	// setting the duration to 1 because I don't want it to scroll in the
	// very first page load.  We don't always need this, but it ensures
	// the positioning is absolutely spot on when the pages loads.
	scrollOptions.duration = 1;
	jQuery.localScroll.hash(scrollOptions);
		
});