$(document).ready(function(){
		
		$("a[href='https://bikesafe.co.uk/booking/index.aspx?forceid=41']").click(function(){
			_gaq.push(['_trackEvent', 'banner', 'click', ' Book-a-course']);
			if($("#bookOverlay").length < 1){
				$("body").append("<div id=\"bookOverlay\" class=\"overlay\" style=\"display:none;\"><p>You are about to leave the BikeSafe-London page and will be directed to the national BikeSafe website who will take your booking and process your payment.</p><p>All transactions will appear on your bank statement as MOTOR CYCLE IND.</p></div>");
			}
		

			$("#bookOverlay").dialog({ 
				title: 'You are about to leave BikeSafe-London',
				buttons: { "Ok": function() { _gaq.push(['_trackEvent', 'Pop-up', 'click', ' Ok']); $(this).dialog("close"); window.location = "https://bikesafe.co.uk/booking/index.aspx?forceid=41"; } },
				draggable: false,
				resizable: false,
				modal: true
			});
			return false;																						
		});
		
		$("a.giftVoucher").click(function(){
			if($("#giftOverlay").length < 1){
				$("body").append("<div id=\"giftOverlay\" class=\"overlay\" style=\"display:none;\"><p><strong>BikeSafe-London and ScooterSafe-London Rider Skills Day voucher is now available for &pound;45 for family and friends.</strong></p><p>Call 0845 375 3001 to order.</p></div>");
			}
			$("#giftOverlay").dialog({ 
				title: 'Gift Voucher',
				draggable: false,
				resizable: false,
				modal: true
			});
			return false;																						
		});
		
		if($(".testimonialWrapper").length > 5){
			var active = 1;
			var numElements = $(".testimonialWrapper").length;
			$(".testimonialWrapper").wrapAll("<div id='testimonialMask'></div>");
			for(i=0; i<numElements; i+=5){
				$(".testimonialWrapper").slice(i, i+5).wrapAll("<div class='testimonialPage'></div>");
				$(".testimonialPage:gt(0)").hide();
				$(".testimonialPage").first().addClass("current");
			}
			var numPages = $(".testimonialPage").length;
			var pagination = $("<ul class='pagination'></ul>");
			pagination.append("<li class='prev disabled'><a href='#contentArea'>&laquo; Previous</a></li>");
			pagination.append("<li class='next'><a href='#contentArea'>Next &raquo;</a></li>");
			$("#testimonialMask").after(pagination);
			$("ul.pagination li a").bind("click", function(event){
				//event.preventDefault();
				var thisLi = $(this).parent("li");
				if(!thisLi.hasClass("disabled") && $("#testimonialMask:animated").length < 1){
					if(thisLi.hasClass("prev")){
						var next = active - 1;
					}else if(thisLi.hasClass("next")){
						var next = active + 1;
					}
					$(".testimonialPage").eq(active-1).hide();
					$(".testimonialPage").eq(next-1).show();
					if(next >= numPages){
						$("ul.pagination li.next").addClass("disabled");
					}else{
						$("ul.pagination li.next").removeClass("disabled");
					}
					if(next == 1){
						$("ul.pagination li.prev").addClass("disabled");
					}else{
						$("ul.pagination li.prev").removeClass("disabled");
					}
					active = next;					
					/**
					$("#testimonialMask").height($("#testimonialMask").height());
					var newHeight = $(".testimonialPage").eq(next-1).outerHeight();
					$(".testimonialPage").eq(active-1).fadeOut(500, function(){
						$(".testimonialPage").eq(next-1).fadeIn(500);
						$("#testimonialMask").animate({"height" : newHeight}, 500);
					});
					**/
				}else{
					event.preventDefault();
				}
			});
		}
		
});
