/* Author: Steve Mason */
$(function(){
	'use strict';

	$('#home #cta').imageSwapper();
	$('#what-we-do').whatWeDo();
	$('#our-work .carousel,#epi .carousel').carousel();
//	$('#our-work > nav,#epi > nav').scrollFixed();
	$('#contact-us #map').googleMap();
	$('#contact-us #callback-and-support form').ajaxSubmit();
	$('#blog #get-latest-posts form').ajaxSubmit();
	$('#blog #popular-people nav li').order('span.number-of-posts');
});

// http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/
Modernizr.addTest('fontsmoothing', function hasSmoothing(){
	// IE has screen.fontSmoothingEnabled - sweet!
	if (typeof(screen.fontSmoothingEnabled) !== "undefined") {
		 return screen.fontSmoothingEnabled;
	} else {
		 try {
				// Create a 35x35 Canvas block.
				var i, j, ctx, alpha,
					c = document.createElement('canvas');
				c.width = "35";
				c.height = "35";

				// We must put this node into the body, otherwise
				// Safari Windows does not report correctly.
				c.style.display = 'none';
				document.body.appendChild(c);
				ctx = c.getContext('2d');

				// draw a black letter 'O', 32px Arial.
				ctx.textBaseline = "top";
				ctx.font = "32px Arial";
				ctx.fillStyle = "black";
				ctx.strokeStyle = "black";

				ctx.fillText("O", 0, 0);

				// start at (8,1) and search the canvas from left to right,
				// top to bottom to see if we can find a non-black pixel.  If
				// so we return true.
				for (j = 8; j <= 32; j++) {
					 for (i = 1; i <= 32; i++) {
							alpha = ctx.getImageData(i, j, 1, 1).data[3];

							if(alpha !== 255 && alpha !== 0){
								return true; // font-smoothing must be on.
							}
					 }
				}

				// didn't find any non-black pixels - return false.
				return false;
		 }
		 catch (ex) {
				// Something went wrong (for example, Opera cannot use the
				// canvas fillText() method.  Return false.
				return false;
		 }
	}
});

