$(document).ready(function(){

		
	//Put labels in form fields
	$("label.populate").inFieldLabels(); 
	$("input").attr("autocomplete","off");
	
	//Keyboard hovers
	$('#navBarMain li ul li a').focus(function() {
	  $(this).parent().parent().addClass("active");
	  $(this).parent().parent().parent().addClass("active");
	  $(this).parent().parent().parent().css({'outline' : 'none'});
	});
	$('#navBarMain li ul li a').blur(function() {								  	
	  $(this).parent().parent().removeClass("active");
	  $(this).parent().removeClass("active");
	  $(this).parent().parent().parent().removeClass("active");
	});
	
	$('#navBarMain li a').blur(function() {								  	
	  $(this).parent().removeClass("active");
	});
	
	$('#navBarMain *').mouseleave(function() {
	  $('#navBarMain *').trigger("blur");
	});
		
	//Visual feedback for saving articles
  	$(".story-toolbar .save").click(function()
		{$(".save").addClass("saved").removeClass("save").html("Saved!");});
	$(".save-this").click(function()
		{$(this).addClass("saved-this").removeClass("save-this").html("Saved!");});

	
	//Show good points (commented out, moved to other file)
	/*
	$(".comment-tools .recommend").live('click', function()
		{
			var currentRating = $(this).find('.count').html();
			var newRating = parseInt(currentRating)+1;
			$(this).find('.count').html(newRating);
			$(this).removeClass('recommend').addClass('recommended');
			$(this).children().children().unwrap();
	});*/
	
	
	
	//hide the all of the element
	$(".toggled-content").hide();
	
	//toggle the componenet 
	$(".toggle-switch").live("click",function()
	{
		$(this).next(".toggled-content").slideToggle(100);
		$(this).next(".toggled-content").animate({opacity:"100%"});
		return false;
	});
	
	//zebra striping tables
	$("#mainContent tbody tr:nth-child(odd)").addClass("odd");
	$("#mainContent tbody tr:nth-child(even)").addClass("even");
	
	//for the weather page
	/*
	$('.details').hide();
	$('.more-info').live('click',function() {	
		$(this).next().slideDown(200);
	  });  
	  
	$('.details').live('click',function() {
			$(this).slideUp(200);
	});
	$('.details').live('mouseleave',function() {
			$(this).slideUp(200);
	});*/
	
	$(".article .toggled-content").before("<span class='toggle-switch'>Continue reading</span>");
	$(".article .toggle-switch").click(function () { 
      $(this).hide(); 
    });
	
	//image table
	$('.tile-box li .flyout').hide();
	$('.tile-box li').mouseenter(function() {
		$(this).addClass('z-index-high');
		$(this).nextAll().addClass('z-index-low');
		$(this).children().next().addClass('ie-fix').show(100);
		
		
	});
	$('.tile-box li').mouseleave(function() {
		$(this).removeClass('z-index-high');
		$(this).nextAll().removeClass('z-index-low');								  
		$(this).children().next().removeClass('ie-fix').hide(200);
	});
	
	   
  
	// Reset Font Size
	var originalFontSize = $('html').css('font-size');
	var $resizeTarget = null;
	$resizeTarget = $('.resize > *:not(.story-embed)');
  
	// Increase Font Size
	$("#increaseFont").click(function(){
		var currentFontSize = $resizeTarget.css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum+3;
		$resizeTarget.css('font-size', newFontSize);
		$(".reset-font").addClass('reset-font-enabled');
    return false;
	});
	
	// Decrease Font Size
	$("#decreaseFont").click(function(){
		var currentFontSize = $resizeTarget.css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum-3;
		$resizeTarget.css('font-size', newFontSize);
		$(".reset-font").addClass('reset-font-enabled');
		return false;
  });

});
