  jQuery(document).ready( function( ) {

	cyclePosts( );
	rightNav( );
	topNav( );
	sidebar( );
	icons( );
	element( );
	lists( );
	textColor( );
	showHide( );
	siteNav( );
	metaSidebar( );

	
  });


  
  function cyclePosts( ) {
    var timer = 0;
	var count = 0;
	$('.blog .recent-post:first').show( ).css({"opacity":1});
    $('.blog .recent-post').each(function (i) {
	  var post = $(this);
	  count ++;
	  if (post.hasClass('rpID-'+count) == false) { 
	    post.addClass('rpID-'+count);
	  }	  
	  var nextPost = function( ) { showPost(post); };
	  setTimeout(nextPost, timer);
	  timer += 5000;
	});
	setTimeout("cyclePosts( )", count*5000);
	$('#blog-page a').each(function (i) {
	  var postid = $(this).html( );
	  var pageclick = function( ) { showPost($('rpID-'+postid)); }
	  $(this).bind('click', pageclick);
	});
  }
  function showPost(post) {
    post.show( ).animate({opacity:1}, "normal");
	var fadePost = function( ) { hidePost(post); };
    setTimeout(fadePost, 4000);
  }
  function hidePost(post) {
    post.animate({opacity:0}, "normal", "linear", function( ) { $(this).hide(); } );
  }
  
  
  function siteNav( ) {
    $('#footer a').hover(function( ) {
	  var site = $(this).attr('id');
	  $(this).toggleClass(site+"Off");
	  $(this).toggleClass(site);
	}, function( ) {
	  var site = $(this).attr('id');
	  $(this).toggleClass(site+"Off");
	  $(this).toggleClass(site);
	});
  }
  
  function rightNav ( ) {
    $('#navRight a').hover(function( ) {
      $(this).stop( );
      $(this).animate({ right: "-100px", backgroundColor: "#d8d8d8" }, 500);
	  var site = $(this).children('.site').html( );
	  $(this).children('.sprite').toggleClass(site+"Off");
	  $(this).children('.sprite').toggleClass(site);
    }, function( ) {
      $(this).stop( );
      $(this).animate({ right: "0px", backgroundColor: "#262626" }, 500);
	  var site = $(this).children('.site').html( );
	  $(this).children('.sprite').toggleClass(site+"Off");
	  $(this).children('.sprite').toggleClass(site);
    });
  }
  
  function topNav ( ) {
    if ($('body').hasClass('page-id-101') == true) {
	  $('.nav-home').addClass('active');
	} else if ($('body').hasClass('page-id-2') == true) {
	  $('.nav-about').addClass('active');
	} else if ($('body').hasClass('page-id-51') == true) {
	  $('.nav-profile').addClass('active');
	} else if ($('body').hasClass('page-id-4') == true) {
	  $('.nav-education').addClass('active');
	} else if ($('body').hasClass('page-id-6') == true) {
	  $('.nav-portfolio').addClass('active');
	} else if ($('body').hasClass('page-id-7') == true) {
	  $('.nav-contact').addClass('active');
	} else if ($('body').hasClass('page-id-25') == true) {
	  $('.nav-resume').addClass('active');
	} 

    $('#navTop a').hover(function( ) {
	  $(this).stop( );
	  if ($(this).hasClass('active') == false) {
        var page = $(this).html( ).toLowerCase( );
		$('.'+page).show( );
	    $(this).animate({ top: "-3px", backgroundColor: "#548dd4" }, 100);
	  }
    }, function( ) {
      $(this).stop( );
	  if ($(this).hasClass('active') == false) {
        var page = $(this).html( ).toLowerCase( );
		$('.'+page).hide( );		  
        $(this).animate({ top: "0px", backgroundColor: "#262626" }, 100);
	  }
	});
  }
  
  function sidebar( ) {

    $('#sidebar a').hover(function( ) {
	  $(this).stop( );
	  $(this).animate({ backgroundColor: "#9bbb59" }, 300);
    }, function( ) {
      $(this).stop( );
      $(this).animate({ backgroundColor: "#262626" }, 300);
	});
  }
  
  function icons( ) {
    $('#icons div').hover(function( ) {
	  var site = $(this).attr('id');
	  $(this).toggleClass(site+"Off");
	  $(this).toggleClass(site);
	  $(this).children('.tooltip').stop( );
	  $(this).children('.tooltip').animate({ opacity:1,bottom: "0px" }, 500);
    }, function( ) {
	  var site = $(this).attr('id');
	  $(this).toggleClass(site+"Off");
	  $(this).toggleClass(site);
	  $(this).children('.tooltip').stop( );
	  $(this).children('.tooltip').animate({ opacity:0,bottom: "10px" }, 500);
	});
  }
  
  function element( ) {
    $('.text').hover(function( ) {
	  var element = $(this).children('.element').html( );
	  $(this).children('.element').toggleClass(element+"Off");
	  $(this).children('.element').toggleClass(element);
    }, function( ) {
	  var element = $(this).children('.element').html( );
	  $(this).children('.element').toggleClass(element+"Off");
	  $(this).children('.element').toggleClass(element);
	});
  }  
  
  function lists( ) {
    $('.text2 li').addClass("off");
    $('.text2 li').hover(function( ) {
	  $(this).toggleClass("off");
	  $(this).toggleClass("on");
    }, function( ) {
	  $(this).toggleClass("off");
	  $(this).toggleClass("on");
	});
  }
  
  function textColor( ) {
    $('.text3').hover(function( ) {
	  $(this).stop( );
	  $(this).animate({ color: "#000000", backgroundColor: "#95b3d7" }, 500);
	  $(this).prev('h2').stop( );
	  $(this).prev('h2').animate({ color: "#ffffff", backgroundColor: "#1f497d"}, 500);
	  $(this).find('li').stop( );
	  $(this).find('li').animate({ color: "#000000"}, 500); 
	}, function( ) {
	  $(this).stop( );
	  $(this).animate({ color: "#bfbfbf", backgroundColor: "#262626"}, 500);	
	  $(this).prev('h2').stop( );
	  $(this).prev('h2').animate({ color: "#7f7f7f", backgroundColor: "#262626" }, 500);
	  $(this).find('li').stop( );
	  $(this).find('li').animate({ color: "#bfbfbf"}, 500);
	});
  }
  
  function showHide( ) {
	$('.collapse').click(function( ) {
		$(this).children('.collapsebody').slideToggle('normal', 'linear');
	});
  }
  
  function metaSidebar( ) {
    $('#metaHotspot').hover(function( ) {
	  $(this).stop( ).children('#metaSidebar').animate({ opacity:1, bottom:"30px" }, 500);
	}, function( ) {
	  $(this).stop( ).children('#metaSidebar').animate({ opacity:0, bottom:"0px" }, 500);
	});
	$('#metaSidebar a').hover(function( ) {
	  $(this).stop( ).animate({ backgroundColor: "#95b3d7" }, 300);
    }, function( ) {
      $(this).stop( ).animate({ backgroundColor: "#262626" }, 300);
	});
  }
  