
// ======================================================================
//
//	On document ready functions
//
// ======================================================================

jQuery(document).ready(function() {
	
	
	// 3D ribbon scroll triggers
	// -------------------------------------------------------------------
	// trigger when scrolling occurs
	jQuery(window).scroll(function () {
		ribbonPosition();
	});
	// run once on load
	ribbonPosition();	

	
});

// Ribbon scrolling effects 
// -------------------------------------------------------------------

function ribbonPosition() {
	var	t = jQuery(window).scrollTop();
	var	h = jQuery(window).height();
	
	// offset - increase or decrease size of middle (set to zero to disable)
	var	offset = jQuery(window).height() / 25;	
	
	var	zoneSize = jQuery(window).height() / 3;
	var	zoneOne = t + zoneSize + offset;
	var	zoneTwo = t + zoneSize * 2 - offset;
		
	jQuery(".ribbon .wrapAround").each( function() {
		var obj = jQuery(this);
		var objH = obj.height();
		var offset = obj.offset();
		if (offset.top + objH <= zoneOne) {
			jQuery(this).css('background-position','0 0');
		} else if (offset.top >= zoneTwo) {
			jQuery(this).css('background-position','0 -104px');
		} else {
			jQuery(this).css('background-position','0 -52px');
		}
	});	
}

