jQuery(document).ready(function($) {
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	{
		$("#foot").css("position", "static");
		$("body.homepage #foot").css("position", "fixed");
		$("body.homepage #foot").css("bottom", "0");
		$("body.homepage #head").css("position", "fixed");
		$(".slide").css("max-width", "100%");
		$(".slide").css("height", "100%");
		$(".slide").css("min-height", "100%");
		$(".slide").css("max-height", "100%");
		$(".slide").css("-webkit-background-size", "110%");
		$(".slide").css("background-size", "110%");
		$("#num2").css("display", "none");
		$("#num3").css("display", "none");
		$(".scrollarrow").css("display", "none");
		
	};

	if(navigator.platform == 'iPhone' || navigator.platform == 'iPod')
	{
		$("html").css("background", "#000 url(/images/bg-home/bg-home1.jpg) no-repeat center center fixed");
		$("html").css("-webkit-background-size", "cover");
		$("html").css("background-size", "cover");
		$("body.homepage #foot").css("position", "relative");
		$("body.homepage #head").css("position", "relative");
		$("section#num1").css("padding", "1em 0");
		$("section#num1").css("background", "none");
	};

	});


$(function(){
        $('section.slide').css({'height':(($(window).height())-361)+'px'});
/*         $('.scroll-pane').jScrollPane({scrollbarWidth:15, scrollbarMargin:15}); */

        $(window).resize(function(){
              $('section.slide').css({'height':(($(window).height())-361)+'px'});
        });
});



// Cache the Window object
$window = $(window);

// Cache the Y offset and the speed of each sprite
$('[data-type]').each(function() {
  $(this).data('offsetY', parseInt($(this).attr('data-offsetY')));
  $(this).data('speed', $(this).attr('data-speed'));
});

// For each element that has a data-type attribute
$('section[data-type="background"]').each(function(){

// Store some variables based on where we are
var $self = $(this),
    offsetCoords = $self.offset(),
    topOffset = offsetCoords.top;

$(window).scroll(function(){

// If this section is in view
if ( ($window.scrollTop() + $window.height()) > (topOffset) &&
( (topOffset + $self.height()) > $window.scrollTop() ) ) {

  // Scroll the background at var speed
  // the yPos is a negative value because we're scrolling it UP!
  var yPos = -($window.scrollTop() / $self.data('speed'));

  // If this element has a Y offset then add it on
  if ($self.data('offsetY')) {
    yPos += $self.data('offsetY');
  }

  // Put together our final background position
  var coords = '50% '+ yPos + 'px';

  // Move the background
  $self.css({ backgroundPosition: coords });

  }; // in view

}); // window scroll

});	// each data-type



// Check for other sprites in this section
$('[data-type="sprite"]', $self).each(function() {

  // Cache the sprite
  $sprite = $(this);

  // Use the same calculation to work out how far to scroll the sprite
  var yPos = -($.Window.scrollTop() / $sprite.data('speed'));
  var coords = $sprite.data('Xposition') + ' ' + (yPos + $sprite.data('offsetY')) + 'px';
  $sprite.css({ backgroundPosition: coords });
}); // sprites
