	(function($) {
	$.fn.dragdrop = function(options) {
	
		var defaults = {
			dragcontainer:		'.drag_content',
			max_w_h:			'2000'
			};
		var o = $.extend(defaults, options);
		
		return this.each(function(){
			
			var x = -688;			//współrzędna x elementu
			var y = -688;			//współrzędna y elementu
			var xIndex;		//z-index elementu
			var clickY;		//punkt kliknięcia w element
			
			//$(o.imgcontainer, this).css('width', o.imgcontainer_w);
			//$(o.imgcontainer, this).css('height', o.imgcontainer_h);
			
			var w = 624;
			var h = 624;
			var new_x = x;
			var new_y = y;
			
			/*leftstr = $(o.dragcontainer, this).css('left');
			left = leftstr.replace("px", "");*/
			
			
			
			$(o.dragcontainer, this).mousedown(function(event){
				
				x = 0;
				y = 0;
				
				clickY = event.clientY -  $(this).offset().top;
				clickX = event.clientX -  $(this).offset().left;
				
				$(this)
				.data('down', true)
				.data('x', event.clientX)
				.data('y', event.clientY);
				
				$(o.dragcontainer).css('z-index', 1);
				$(this).css('z-index', 100);
				
				return false;
			
			}).mouseup(function(event){
				
				$(this).data('down', false);
				
			}).mousemove(function(event){
				
				if($(this).data('down') == true){
					
					
					x = event.clientX - $(this).parent().offset().left - clickX;
					y = event.clientY - $(this).parent().offset().top - clickY;
					
					new_x = x;
					new_y = y;
					
					if( (x < 0 && x > -1370) && (y < 0 && y > -1370) ){
					$(this).css('left', x);
					$(this).css('top', y);
					}
				}
				
			}).mouseout(function(){
				
				$(this).data('down', false);
					
			});
			
			
			//zoom
			
			$('#zoomin').click(function(){
				if(w < o.max_w_h){
					zoom(true);
					update_elem();
				}
			});
			
			$('#zoomout').click(function(){
				if(w > 624){
					zoom(false);
					update_elem();
				}
			});
			
			function zoom(zoomin){
				if(zoomin){
					w = w + 300;
					h = h + 300;
				}else{
					w = w - 300;
					h = h - 300;
				}
				new_x = (o.max_w_h - w) / 2;
				new_y = (o.max_w_h - h) / 2;
			}//zoomout
			
			function update_elem(){
				$(".img_container").animate({ 
   					width: w,
   					height: h,
   					left: new_x,
   					top: new_y
  				}, 300 );
			}
			
			$('#actual').click(function(){
				w = 624;
				h = 624;
				x, new_x = 688;
				y, new_y = 688;
				$(o.dragcontainer).css('left', '-688px');
				$(o.dragcontainer).css('top', '-688px');
				update_elem();
			});
			
			var viewmode = false;
			$('#viewmode').click(function(){
				if(!viewmode){
					viewmode = true;
					$('.img_container img:eq(1)').css('display', 'none');
					$(this).addClass('active');
				}else{
					viewmode = false;
					$('.img_container img:eq(1)').css('display', 'block');
					$(this).removeClass('active');
				}
			});
			
		});
	
	};//dragdrop
})(jQuery);
