


window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments))}};


// remap jQuery to $
(function($){
	/*
	windowWidth= $(window).width();
    $("#content-scroll").width(windowWidth);
	$(window).resize(function() {
	windowWidth= $(window).width();
    $("#content-scroll").width(windowWidth);
	});
	*/
// get news feature news content size
var featureCount = $('.content-item').size();
var contentscrollerWidth = featureCount * 260;

var showSlider = false;
if (contentscrollerWidth > 840){
		showSlider = true;
}

$('#content-holder').width(contentscrollerWidth);





//show news slider
$("#back-slider-panel").show();

	
	$('#slider-handle-btn').live('click', function(e) {
		// first stop background animation to prevent flicker
		//$(document).bgStretcher.pause()
		e.preventDefault();
		if($('#back-slider-panel').hasClass('open')){
			$('#content-slider').fadeOut('slow');
			$('#back-slider-panel').animate({ bottom: -123}, 600).removeClass('open').addClass('closed');
			$('#slider-handle-btn').html('view news & updates');	
				
		} else {
			
			$('#back-slider-panel').animate({ bottom: 62}, 600).removeClass('closed').addClass('open');
			if(showSlider){
				log('got here');
				$('#content-slider').fadeIn('slow');
				}	
			$('#slider-handle-btn').html('hide news & updates');
		}
	});
	
	
	
$("#content-slider").slider({
    animate: true,
    change: handleSliderChange,
    slide: handleSliderSlide
  });

/*
if($('body').hasClass('class-HomePage')){
	setTimeout(function() {		
	   $('#slider-handle').trigger('click');
	},600);
	}
*/	
	
	
	
	// prevent clicking on test links
	$("a.nolink").click(function(e){
		e.preventDefault();
	});
	
	
	
	
	//footer ipad hack
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
{
     $("#pageFooter").css("position", "static");
};



//   subnav animation
$("#subnav li a").not('.current').hover(function () {
		$(this).stop().animate( { paddingLeft:"5px"} , 100, "easeOutQuad" );
		$(this).parent('li').addClass('subhover');
	},function () {
		$(this).stop().animate( { paddingLeft:"0px"} , 100, "easeOutQuad" );
		$(this).parent('li').removeClass('subhover');
	}); 
	
	
	

            jQuery("#Form_ApplyForm").validate({
                rules: {
                    FirstName: "required",
					Surname: "required",
                    Email: {
                        required: true,
                        email: true
                    }
                },
                messages: {
                    FirstName: "first name is required",
					Surname: "last name is required",
                    Email: "email address is required"
                }
            });
 
  
  
 })(window.jQuery); 
 
 
 
 
 
 function handleSliderChange(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
}

function handleSliderSlide(e, ui)
{
  var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
  $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
 
}


