/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */

(function($) {
	/*
	 *	Slide Away 1.4.2 - jQuery plugin
	 *	written by Nico De Backer
	 *
	 *	Copyright (c) 2009-2010 Nico De Backer (http://iamwebdeveloper.com)
	 *	Dual licensed under the MIT and GPL licenses:
	 *	http://www.opensource.org/licenses/mit-license.php
	 *	http://www.gnu.org/licenses/gpl.html
	 *
	 *	Built for jQuery library (1.4 and higher)
	 *	http://jquery.com
	 *
	 *	Turns a list (ol or ul) into a slider
	 *	Requires the easing plugin (http://gsgd.co.uk/sandbox/jquery/easing/) for advanced effects
	 *
	 *	@name			slideaway
	 *	@param		btnFirstId									ID of the navigation button to navigate to first item																								'btnFirst'
	 *	@param		btnFirstShow								Boolean to indicate if button to navigate to first item should be shown															false
	 *	@param		btnFirstText								Text to display on button to navigate to first item																									'first'
	 *	@param		btnLastId										ID of the navigation button to navigate to last item																								'btnLast'
	 *	@param		btnLastShow									Boolean to indicate if button to navigate to last item should be shown															false
	 *	@param		btnLastText									Text to display on button to navigate to last item																									'last'
	 *	@param		btnNextId										ID of the navigation button to navigate to next item																								'btnNext'
	 *	@param		btnNextShow									Boolean to indicate if button to navigate to next item should be shown															true
	 *	@param		btnNextText								Text to display on button to navigate to next item																									'next'
	 *	@param		btnPrevId										ID of the navigation button to navigate to previous item																						'btnPrev'
	 *	@param		btnPrevShow									Boolean to indicate if button to navigate to previous item should be shown													true
	 *	@param		btnPrevText									Text to display on button to navigate to previous item																							'prev'
	 *	@param		navigationShow								Boolean to indicate if navigation should be shown																									true
	 *	@param		numericEnabled							Boolean to indicate if navigation should be numeric (true) or through buttons (false)								false
	 *	@param		numericId										ID of the numeric control list (<ol>)																																'numControls'
	 *	@param		slideAutorun								Boolean to indicate if slider should run by itself (true) or only after user interaction (false)		true
	 *	@param		slideContinueAfterClick			Boolean to indicate if slider should continue its autorun after the user clicked the navigation			true
	 *	@param		slideEasing								String to define type of easing (requires easing plugin)															'swing'
	 *	@param		slideHorizontal							Boolean to indicate if slider works horizontally (true) or vertically (false)												true
	 *	@param		slidePause									Number of miliseconds an item should stay visible on autorun																				3000
	 *	@param		slidePerItem								Number of items that should be shown per slice																											1
	 *	@param		slideSpeed									Speed by which slider slides (ms or keyword)																												'normal'
	 *	@example	$('#slider').slideaway();
	 */
	$.fn.slideaway = function(options) {
	  var settings = $.extend({}, $.fn.slideaway.defaults, options),
				timeout;
		settings.DIRECTIONS = {
			FIRST:'first',
			LAST:'last',
			NEXT:'next',
			PREV:'prev'
		};

		return this.each(function() {
			var $me = $(this),
					$list = $('ul', $me),
					itms = $('li', $list),
					atl = itms.length,
					h = itms.height(),
					w = itms.width(),
					currItem = 0,
					lastItem = atl - 1;

			function transformList() {
				var $container = $list.parent();

				$container.css({
					overflow:'hidden'
				});

				if (settings.slideHorizontal) {
					itms.css({
						float:'left'
					});
					$list.css({
						height:h,
						width:atl*w
					});
					$container.css({
						width:settings.slidePerItems*w
					});
				} else {
					$list.css({
						height:atl * h,
						width:w
					});
					$container.css({
						height:settings.slidePerItems*h
					});
				}
			}

			function resetTimout() {
				timeout = setTimeout(function(){calculateTarget(settings.DIRECTIONS.NEXT, false);}, settings.slidePause);
			}

			function setCurrent(aIndex) {
				i = parseInt(aIndex, 10);
				$('li:eq(' + i + ')', '#' + settings.numericId)
					.addClass('current')
					.siblings('li').removeClass('current');
			}

			function performSlide(aPosition) {
				if (settings.slideHorizontal) {
					$('ul:first', $me).animate({marginLeft:aPosition}, {duration:settings.slideSpeed, easing:settings.slideEasing});		
				} else {
					$('ul:first', $me).animate({marginTop:aPosition}, {duration:settings.slideSpeed, easing:settings.slideEasing});
				}
			}

			function calculateTarget(aDirection, aClick) {
				var oldCurrent = parseInt(currItem, 10),
						distance = settings.slidePerItems,
						newPosition;

				switch (aDirection) {
					case settings.DIRECTIONS.FIRST:
						currItem = 0;
						break;
					case settings.DIRECTIONS.PREV:
						currItem = oldCurrent > 0 ? oldCurrent - distance : lastItem;
						break;
					case settings.DIRECTIONS.NEXT:
						currItem = oldCurrent ==  lastItem ? 0 : oldCurrent + distance;
						break;
					case settings.DIRECTIONS.LAST:
						currItem = lastItem;
						break;
					default:
						currItem = aDirection;
						break;
				}

				if (settings.slideHorizontal) {
					newPosition = (currItem * w * -1);
				} else {
					newPosition = (currItem * h * -1);
				}

				performSlide(newPosition);

				if (settings.numericEnabled) {
					setCurrent(currItem);
				}

				if (aClick) {
					clearTimeout(timeout);

					if (settings.slideContinueAfterClick) {
						resetTimout();
					}
				}

				if (settings.slideAutorun && aDirection == settings.DIRECTIONS.NEXT && !aClick) {
					resetTimout();
				}
			}

			function generateNavigation($aContainer) {
				if (settings.numericEnabled) {
					var $numCtrls = $('<ol/>', {id:settings.numericId});

					for (var i=0; i<atl; i++) {
						$numCtrls.append(
							$('<li/>', {id:settings.numericId + i})
								.append(
									$('<a/>', {
										href:'#',
										onclick:'return false;',
										rel:i,
										text:(i+1)
									})
								)
						);

						$('a', $numCtrls).click(function() {
							var index = $(this).attr('rel');
							setCurrent($(this).attr('rel'));
							calculateTarget($(this).attr('rel'), true);
						});
					}

					$aContainer.after($numCtrls);
					setCurrent(0);
				} else {
					// FIRST
					if (settings.btnFirstShow) {
						$aContainer.after(
							$('<span/>', {
								id:settings.btnFirstId
							}).append(
								$('<a/>', {
									click:function() {
										calculateTarget(settings.DIRECTIONS.FIRST, true);
									},
									html:settings.btnFirstText,
									href:'#',
									onclick:'return false;'
								})
							)
						);
					}
					// PREVIOUS
					if (settings.btnPrevShow) {
						$aContainer.after(
							$('<span/>', {
								id:settings.btnPrevId
							}).append(
								$('<a/>', {
									click:function() {
										calculateTarget(settings.DIRECTIONS.PREV, true);
									},
									html:settings.btnPrevText,
									href:'#',
									onclick:'return false;'
								})
							)
						);
					}
					// NEXT
					if (settings.btnNextShow) {
						$aContainer.after(
							$('<span/>', {
								id:settings.btnNextId
							}).append(
								$('<a/>', {
									click:function() {
										calculateTarget(settings.DIRECTIONS.NEXT, true);
									},
									html:settings.btnNextText,
									href:'#',
									onclick:'return false;'
								})
							)
						);
					}
					// LAST
					if (settings.btnLastShow) {
						$aContainer.after(
							$('<span/>', {
								id:settings.btnLastId
							}).append(
								$('<a/>', {
									click:function() {
										calculateTarget(settings.DIRECTIONS.LAST, true);
									},
									html:settings.btnLastText,
									href:'#',
									onclick:'return false;'
								})
							)
						);
					}
				}
			}

			transformList();

			if (settings.navigationShow) {
				generateNavigation($me);
			}

			if (settings.slideAutorun) {
				resetTimout();
			}
		});
	};

	$.fn.slideaway.defaults = {
		btnFirstId:'btnFirst',
		btnFirstShow:false,
		btnFirstText:'first',
		btnLastId:'btnLast',
		btnLastShow:false,
		btnLastText:'last',
		btnNextId:'btnNext',
		btnNextShow:true,
		btnNextText:'next',
		btnPrevId:'btnPrev',
		btnPrevShow:true,
		btnPrevText:'prev',
		navigationShow:true,
		numericEnabled:false,
		numericId:'numControls',
		slideAutorun:true,
		slideContinueAfterClick:true,
		slideEasing:'swing',
		slideHorizontal:true,
		slidePause:3000,
		slidePerItems:1,
		slideSpeed:'normal'
	};
})(jQuery);

(function($) {
	/*
	 * Form Validator 1.4.0 - jQuery plugin
	 *	written by Nico De Backer
	 *
	 *	Copyright (c) 2009-2010 Nico De Backer (http://iamwebdeveloper.com)
	 *	Dual licensed under the MIT and GPL licenses:
	 *	http://www.opensource.org/licenses/mit-license.php
	 *	http://www.gnu.org/licenses/gpl.html
	 *
	 *	Built for jQuery library (1.4 and higher)
	 *	http://jquery.com
	 *
	 *	Performs basic form validation (required, email, numeric)
	 *
	 *	@name		formvalidate
	 *	@param		messages.email			Error message when email is not valid									'This is an invalid email address'
	 *	@param		messages.numeric		Error message when field is not numeric								'This is not a valid number'
	 *	@param		messages.required		Error message when required field is empty							'This is a required field'
	 *	@param		messages.summary		Error message summary (use {0} to display number of errors)		'Please correct the errors with the following {0} fields:'
	 *	@param		requiredFlag				Token to indicate required field											'*'
	 *	@example	$('form').formvalidate();
	 */
	$.fn.formvalidate = function(options) {
		var settings = $.extend(true, $.fn.formvalidate.defaults, options);

		function handleRequiredLabel($aForm) {
			var requiredKey = $('.required:first', $aForm).prev('label').find('span').text(),
					fieldKeys,
					$instructions = $('<p/>');

			requiredKey = requiredKey.replace(/^\((.+)\)$/,"$1");
			fieldKeys = settings.requiredFlag + ' ' + requiredKey;

			$(':input', $aForm)
				.filter('.required').prev('label').find('span').text(settings.requiredFlag).attr('title', requiredKey).end().end()
				.prev('label').addClass('req-label');
			$instructions.addClass('field-keys').append(fieldKeys);
			$aForm.before($instructions);
		}

		function createInlineErrorMessage($aPlace, aText) {
			$('<span/>', {
				className:'error-message',
				text:aText
			}).appendTo($aPlace);  

			$aPlace.addClass('warning');
		}

		String.format = function() {
		  var s = arguments[0];

		  for (var i = 0; i < arguments.length - 1; i++) {       
		    var reg = new RegExp('\\{' + i + '\\}', 'gm');             
		    s = s.replace(reg, arguments[i + 1]);
		  }

		  return s;
		};

		return this.each(function() {
			var $me = $(this);

			handleRequiredLabel($me);

			$(':input', $me).blur(function() {
				var field = this,
						$collection = $(field).parent(),
						val = $.trim(field.value);

				$collection.removeClass('warning').find('span.error-message').remove();

				if ($(field).is('.required')) {
					if (val == '') {
						createInlineErrorMessage($collection, settings.messages.required);
					}
				}

				if ($(field).is('.email')) {
					if (val != '') {
						var reg = new  RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

						if (reg.test(val) === false) {
							createInlineErrorMessage($collection, settings.messages.email);
						}
					}
				}

				if ($(field).is('.numeric')) {
					if (isNaN(val)) {
						createInlineErrorMessage($collection, settings.messages.numeric);
					}
				}
			});

			$me.submit(function() {
				$('.submit-message', $me).remove();
				$(':input.required').trigger('blur');

				var numWarnings = $('.warning', $me).length,
						errFields = [];

				if (numWarnings > 0) {
					$('.warning label', $me).each(function(){
						var txt = $(this).text();
						errFields.push('<li>' + txt + '</li>');
					});

					var $message = $('<div/>', {className:'submit-message warning', text:String.format(settings.messages.summary, numWarnings)}),
							$lst = $('<ul/>').append(errFields.join(''));
					$message.append($lst);
					$me.prepend($message);

					return false;
				}
			});
		});
	};

	$.fn.formvalidate.defaults = {
		messages: {
			email:'This is an invalid email address',
			numeric:'This is not a valid number',
			required:'This is a required field',
			summary:'Please correct the errors with the following {0} fields:'
		},
		requiredFlag:'*'
	};
})(jQuery);


function showSolution(aId) {
	$('#' + aId)
		.siblings('.solution').hide().end()
		.fadeIn();
	
	$('a', '.pagenav')
		.removeClass('active')
		.each(function() {
			var ref = this.href,
				tar = ref.substring(ref.lastIndexOf('#') + 1);
	
			if (tar === aId) {
				$(this).addClass('active');
			}
		});
}

function handleBlocks() {
	var hash = window.location.hash.substr(1);

	if (hash.length > 0) {
		showSolution(hash);
	}
	else {
		$('.solution', '#content').not(':eq(0)').hide();
		$('a', '.pagenav li:first').addClass('active');
	}
	
	$('a', '.pagenav, .solution').click(function() {
		var ref = this.href,
			tar = ref.substring(ref.lastIndexOf('#') + 1);

		showSolution(tar);

		return false;
	});
}

$(document).ready(function() {
	if ($('#homepage').length > 0) {
		$('#slider').slideaway({btnNextText:'&gt;', btnPrevText:'&lt;', slideEasing:'easeInBack', slidePause:7000, slideSpeed:'slow'});
	}

	if ($('#solutionspage').length > 0) {
		handleBlocks();
	}

	if ($('#contactpage').length > 0) {
		$('#contactForm').formvalidate();
	}
});
