// JavaScript Document

jQuery(document).ready(function($) {
	
	 var imgBgWidth;
	 imgBgWidth = 2200;
	 
	
	 
	//window load
	$(window).load(function () {  
		
		//Resize ONLOAD
		$("#ship_hold_rel").resizeObject();
		
		
		//Animation
		$(".ship").animateShip(".ship", 45000, -75);					 
				
	});
	
	//if Window resize than change Object width
	$(window).resize(function() {
	  $("#ship_hold_rel").resizeObject();
	});

	
	//Animate Ship
	$.fn.animateShip = function (objName, cas, zamikLevo) {
		$(objName).animate({left: + $(window).width() + 'px'}, cas, "linear", function (){																		
			$(this).animate({left: + zamikLevo + 'px'}, 0, $(this).animateShip(objName, cas, zamikLevo));									 																	  								
		});	
				
	}
	
	//Resize Object - window size
	$.fn.resizeObject = function () {
		
		if ($(window).width() >= imgBgWidth) {;
			return $(this).css("width", imgBgWidth + "px");
		}
		else {
			return $(this).css("width", $(window).width() + "px");
		}
			
	}
	

});
