(function($) {

	window.app = {
	
		init: function() {
			this.is_ipad = navigator.userAgent.indexOf('iPad') > -1;
			return true;
		},
		
		spritely: {
			
			init: function() {
				
				$('#landscape').pan({fps: 30, speed: 3, dir: 'left', depth: 70});
				$('#landscape').spRelSpeed(-2);
				
				$('#sheep').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 230,
						'top': 100,
						'bg_img_width': 2280
					});
						  
						  $('#chicken').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 370,
						'top': 200,
						'bg_img_width': 2280
					});
						  
						   $('#cow').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 1020,
						'top': 80,
						'bg_img_width': 2280
					});
						  
						   $('#pig').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 1240,
						'top': 110,
						'bg_img_width': 2280
					});
						  
						  
						   $('#dog').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 1820,
						'top': 200,
						'bg_img_width': 2280
					});
						  
						   $('#horse').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 2020,
						'top': 80,
						'bg_img_width': 2280
					});
						  
						   $('#kangaroo').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 730,
						'top': 200,
						'bg_img_width': 2280
					});
						  
						   $('#kookaburra').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 435,
						'top': 140,
						'bg_img_width': 2280
					});
						  
						   $('#emu').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 620,
						'top': 60,
						'bg_img_width': 2280
					});
						  
						   $('#oldmac').sprite({fps: 25, no_of_frames: 1})
				          .lockTo('#landscape', {
						'left': 1540,
						'top': 100,
						'bg_img_width': 2280
					});
	
				
                                if (window.app.is_ipad) {
                                    $('#dragMe, .ui-slider-handle').hide();
                                  
                                    $('#container, .stage').css({
                                       'min-width': '768px'
                                    });
                                } else {
                                    $('#container, .stage').css({
                                       'min-width': '900px'
                                    });
                                    $('#slider')
                                        .show()
					.slider({
						value: 8,
						min: -60,
						max: 60,
						slide: function() {
							window.app.spritely.sliderChange($(this).slider('value'));
						},
						change: function() {
							window.app.spritely.sliderChange($(this).slider('value'));
						}
					});
                                }
	        },
	        
			sliderChange: function(val) {
	      		if ($('#dragMe').css('display') == 'block') {
	      			if (!$.browser.msie) {
	      				$('#dragMe').fadeOut('slow');
	      			} else {
	      				$('#dragMe').hide();
	      			}
	      		}
	      		var sliderSpeed = val;
                if (sliderSpeed < 0) {
                    var sliderSpeed = String(sliderSpeed).split('-')[1];
                   
                    $('#landscape').spChangeDir('right');
                } else {
                    
                    $('#landscape').spChangeDir('left');
                }
                $('#landscape').spRelSpeed(sliderSpeed);
                
                
	      		
	        }
			
		}
		
		
	        
			
	
	};
	
	
	$(document).ready(function() {

		window.app.init();
		window.app.spritely.init();
	});
	

})(jQuery);





