﻿$("document").ready(function() {


	var HideAllBlogPosts = function(smoothHide){

		$("#blog p").each(
			function(index)
			{
				
				if(smoothHide != undefined && 
					$(this).attr('style') != null &&
					$(this).attr('style') == ""){
					
					$(this).slideUp(300);

				} else {

					$(this).css("display", "none");

				}
				
			}
		);
	}

	 var articleFunction = function(e){
		if($(this).attr('class') == 'more'){
			var article = $(this).parentsUntil("article").parent();
			var id = article.attr('id')

			HideAllBlogPosts(false);
				
			var content = $(this).parentsUntil("article").parent().children("p");
			content.slideDown(300);
			
	    	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
			
			e.preventDefault();
		}
	};

	var BlogContent = function(){
		
		HideAllBlogPosts();
		
		$("#blog a").click(
			function(e){
				if($(this).attr('class') == 'more'){
					var article = $(this).parentsUntil("article").parent();
					var id = article.attr('id')
		
					HideAllBlogPosts(false);
						
					var content = $(this).parentsUntil("article").parent().children("p");
					content.slideDown(300);

			    	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
					
					e.preventDefault();
				}
			}
		);
		
	}

	$(".socialicon").bind("mouseover mouseout", 
		function(e){
			
			var current = $(this);
			
			if(current.hasClass("twitter")){
				$(this).toggleClass("twitterhover");
			}
			
			if(current.hasClass("facebook")){
				$(this).toggleClass("facebookhover");
			}

			if(current.hasClass("xing")){
				$(this).toggleClass("xinghover");
			}
			
			if(current.hasClass("linkedin")){
				$(this).toggleClass("linkedinhover");
			}


		}
	)


	BlogContent();
	load_tweets();
	setInterval(load_tweets, 20000);

	function callback() {
			setTimeout(function() {
				$(this).removeClass( "newClass" );
			}, 1500 );
		}
		
});













