$(document).ready(function(){
						   

    
	// set vars
	var windowSize 				= null;
	var largePictureWidth 		= null;
	var offset 					= null;
	var pictureXPictureWidth 	= null;
	
	// show the large image on the post listing page on mouse over
	$(".post-picture").mouseenter(function()
	{
    	
		// show the picture
		$(".post-picture-large",this).css("display","inline-block");
		
		// get some variables for checking where the picture will be displayed
		windowSize 				= $(document).width();
		largePictureWidth 		= $(".post-picture-large",this).width();
		offset 					= $(this).offset();
		pictureXPictureWidth 	= largePictureWidth + offset.left + 120;
		
	
		// check of the picture will go over the browser window
		if (pictureXPictureWidth > windowSize)
		{
			var leftSidePosition = 0;
			if (jQuery.browser.msie || jQuery.browser.safari) 
			{
				leftSidePosition = (largePictureWidth * -1) - 117;				
			}
			else
			{
				leftSidePosition = (largePictureWidth * -1) - 25;
			}
			$(".post-picture-large",this).css("margin-left", leftSidePosition + "px");
		}
		else
		{						
				
			if (jQuery.browser.msie) 
			{
		 		$(".post-picture-large",this).css("margin-left", "10px");	
			}
			else
			{
				$(".post-picture-large",this).css("display","block");
				$(".post-picture-large",this).css("margin-left", "100px");	
			}
			
			
		}
		// position the picture 
		$(".post-picture-large",this).css("position","absolute");
		
    }).mouseleave(function()
	{
		// hide the picture
    	$(".post-picture-large",this).css("display","none");
		// reset the margin
		$(".post-picture-large",this).css("margin-left", "0px");
		
		
		
    });

	
	// hide the large picture if it gets moused over.   
	// sometimes the picture doesn't hide on mouseleave of the user moves the mouse fast.
	// this should try and fix that problem
	$(".post-picture-large").mouseenter(function()
	{
		$(this).css("display","none");
	});
	
	
	//set the character limit for the submission title
	$("#content-title-tf").charCounter(24);

});

// preload function
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)


