// JavaScript Document

var recentStudentBlog = '';

function setSize(size)
{
	jQuery("html").css("font-size", size + "px");
	jQuery.cookie("fontsize", size, {path:"/", expires:100});
}

		
jQuery(document).ready(function(){

	
	/************************
	***** HAND MOUSEOVER
	*************************/
	$('.calender-activity-hover').mouseover(function() {
	  $(this).next().css('background-image', 'url("wp-content/themes/helsefagarbeider/images/hand.png")');
	  //$(this).next().css( 'background-position', '0 40%');
	});
	$('.calender-activity-hover').mouseout(function() {
	 	if( !$(this).next().hasClass('calender-hand') ) 
			 $(this).next().css('background-image', 'none');
	});
	
	
	
	/************************
	***** STUDENT BLOG SELECTOR
	*************************/
	
	$('.blog-sort').mouseover(function() {
	  $(this).clearQueue();
	  $(this).animate({
			top: '-20px',
			height: '40px'
		  })
	});
	$('.blog-sort').mouseout(function() {
	  $(this).clearQueue();
	  $(this).animate({
			top: '0px',
			height: '20px'
		  })
	});
	
	$('.blog-sort').click(function() {
		
		var feedUrl = $(this).attr('data-feedurl');
		var author = $(this).attr('data-author');
		
		
		if ( author != recentStudentBlog ){
			recentStudentBlog = author;
			$('.student-blog').html('');
			$.ajax({
				  url: AJAX_URL,
				  type: "POST",
				  data: {author : author, studentfeed : feedUrl, action : 'getStudentPosts'},
				  
				  success: function(html){
					//alert(html);
					$(".student-blog").append(html);
			  }
			});
		}else{
			recentStudentBlog = '';
			
			$('.student-blog').html('');
			$.ajax({
				  url: AJAX_URL,
				  type: "POST",
				  data: { action : 'getRecentStudentPosts' },
				  
				  success: function(html){
					//alert(html);
					
					$(".student-blog").append(html.substring(1, html.length -1));
			  }
			});
			
			
		}
		
		
		
	 	
	});
	
	
	/************************
	***** FONT SIZE SELCTOR
	*************************/
	
	jQuery("#fontsize").show();
	
	jQuery("#fontsize #small").click(function(){
		setSize(10);
	});
	jQuery("#fontsize #medium").click(function(){
		setSize(12);
	});
	jQuery("#fontsize #large").click(function(){
		setSize(14);
	});

	

});
		
