$(document).ready(function(){

	if ($( '.subnav_content' ).length ) {
		$( '.subnav_content:not(.subnav_content_plain) article header' ).click( function(){
			$( this ).parent().children( 'section' ).toggle();
			$( this ).parent().toggleClass( 'invisible' );
		});
		$( '.subnav_content article:not(:first) header' ).trigger( 'click' );		
	}

	// data-expand are the elements to expand
	// data-container is the element to remove the .invisible class
	$( 'a.expand_all' ).click( function(){
		$( $( this ).data( 'expand' ) ).show();
		$( $( this ).data( 'container' ) ).removeClass( 'invisible' );
		return false;
	});

	// Hide FAQs
	if( $( '.faq' ).length ) {
		$( '.faq dd' ).hide();
		$( '.faq dt' ).click( function(){
			$( this ).toggleClass( 'active' );
			$( this ).next().slideToggle( 'fast' );
		});
	}

	// Inputs with class placeholder use the attr data-placeholder as there placeholder
	$( 'input.placeholder' ).focus(function(){
		if ( $(this).val() == $(this).data('placeholder') ) {
			$(this).val('');
		}
	});
	$( 'input.placeholder' ).blur(function(){
		if ( $(this).val().trim() == '' ) {
			$(this).val( $(this).data('placeholder') );
		}
	});
	
	// Every element with class placeholder will have their placeholder data filled with their value
	$( '.placeholder' ).each(function(){
		ph = $(this);
		$(this).data( 'placeholder', ph.val() );
	});

	$(".home .slide_pages li a").click(function(){
		return false;
	});
	
	// basics tabs

		/*
$("#tabs").tabs().tabs('rotate', 4000);
		$('#tabs').hover(function(){
			$(this).tabs('rotate', 0, false);
		},function(){
			$(this).tabs().tabs('rotate', 4000);
		}
	);
*/


	$("#tabs").tabs({
		event: "mouseover"
		});

	
	
	$(function() {

        var $tabs = $('#tabs').tabs();

        $(".ui-tabs-panel").each(function(i){

          var totalSize = $(".ui-tabs-panel").size() - 1;

          if (i != totalSize) {
              next = i + 2;
                  $(this).append("<a href='#' class='next-tab mover' rel='" + next + "'>Next Slide</a>");
          }

          /*
if (i != 0) {
              prev = i;
                  $(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>Previous Slide</a>");
          }
*/

        });

        $('.next-tab').click(function() {
           $tabs.tabs('select', $(this).attr("rel"));
           return false;
       });

});

});
