(function($)
{
    $.outerDiv = "$.vari";
    $.fn.vari = "$.fn.vari";
    var ww = 0;
    

    
    
    // $.fn is the object we add our custom functions to
//    $.fn.sideScroller = function(options){
vScroller = {
		/*
    	containerWidth: = $(this).width();
    	var container = this;
    	var w = 0; //width of 1 li
    	var c = 0; //number of li's
    	var maxWidth = 0;
    	var currentPosition = 0;
    	*/
    	defaults: { 
		    up:      false,
		    down: false,
		    scrollCount:     1,
		    scrollFullPage: false,
		    speed: 200
		  },
		containerWidth:0,
		h: 0,
		c: 0,
		maxHeight: 0,
		currentPosition: 0,
		options: {},
		container: false,
		  
		
    	move: function(e){
			var mt = parseInt($('> ul',this.container).css('marginTop'));
			if (e.pageY < ($(this.containter).height()/100)){
				var np = 5;
			}else if (e.pageY < ($(this.containter).height()/6)){
				var np = mt + 20;
			}else if (e.pageY < ($(this.containter).height()/2)){
					var np = mt + 2;
			}else if (e.pageY > ($(this.containter).height()/100*99)){
				var np = (($('> ul',this.container).height() - $(this.container).height()) * -1) - 5;
			}else if (e.pageY > ($(this.containter).height()/6*5)){
				var np = mt - 20;
			}else if (e.pageY > ($(this.containter).height()/2)){
				var np = mt - 2;
			}
			//if (np < 0 && np > (($('> ul',this.container).height() - $(this.container).height()) * -1)){
			if (np > 5){
				np = 5
			}else if (np < ((($('> ul',this.container).height() - $(this.container).height()) * -1) - 5)){
				np = (($('> ul',this.container).height() - $(this.container).height()) * -1) - 5;
			}
			$('> ul',this.container).css('marginTop',np+'px');
			//}
			/*
			var np = (e.pageY - mt) * ($('> ul',this.container).height() - $(this.container).height()) / $(this.container).height();
			//alert(($('> ul',this.container).height() - $(this.container).height()));
			//alert($(this.container).height());
			var np = (e.pageY / $(this.container).height()) * ($('> ul',this.container).height() - $(this.container).height()) * -1;
			//var np = ($('> ul',this.container).height() - $(this.container).height()) * -1;
			if (np < 0 && np > (($('> ul',this.container).height() - $(this.container).height()) * -1)){
				$('> ul',this.container).css('marginTop',np+'px');
				//$('> ul',this.container).animate({'marginTop':np+'px'},200);
			}
			*/
			
		},
		
		
    	_init: function(element, options){	
		 // Overwrite default options 
		  // with user provided ones 
		  // and merge them into "options". 
		  this.options = $.extend({}, this.defaults, options);	
		  this.container = element;
		  this.containerWidth = $(element).width();
		  
		  var instance = this;
		  
	    	return $(element).each(function(){
	        	$(this).mousemove(function(e){
	    			instance.move(e);
	    		})
	    		
				$(this).css('overflow', 'hidden');
	    		
				$(this).css('height',$(window).height() + 'px');
	    		
	    	});
		}
    };

$.vScroller = function(element, options){
	this._init(element, options);
}
$.vScroller.prototype = vScroller;


$.fn.vScroller = function(options){
	if ($(this).length == 0) return false;
	var name = 'sideScroller';
	var isMethodCall = (typeof options == 'string'),
		args = Array.prototype.slice.call(arguments, 1);
	
	// prevent calls to internal methods
	if (isMethodCall && options.substring(0, 1) == '_') {
		return this;
	}
	
	// handle initialization and non-getter methods
	return this.each(function() {
		var instance = $(this).data(name);

		
		
		// constructor
		(!instance && !isMethodCall &&
			$(this).data(name, new $.vScroller(this, options)));

		// method call
		
		(instance && isMethodCall && $.isFunction(instance[options]) &&
			instance[options].apply(instance, args));
	});
	
};


})(jQuery);

$(document).ready(function(){
	

	//$('#site-gallery').append('<div class="up"></div><div class="down"></div>')
	$('#site-gallery').vScroller({up:'.up',down:'.down'});
	
	
	
	
});
