/**
 * aZoomer - Animated image zoomer
 * (C) 2011 Sawanna Team (http://sawanna.org)
 */

$.fn.enlargeLeft=function()
{
	//alert("Left: " + ($.fn.getActPage()-1));

}

$.fn.enlargeRight=function()
{
	//alert("Right: " + $.fn.getActPage());

}

$.fn.azoomer=function(settings)
{
	aZoomer={
		elem: null,
		params: new Array(),
		current: null,
		init: function(elem,settings) {
			this.params.speed=200;
			this.params.width=850;
			this.params.height=1133;
			
			if (typeof(settings) != 'undefined') {
				try {
					for (s in settings) {
						this.params[s]=settings[s];
					}
				} catch(e) {}
			}
			
			this.elem=elem;
			/*$(this.elem).css({
						'cursor': 'pointer'
						});*/
			
			$(this.elem).click(function(){
				aZoomer.zoom($(this));
			});
			
			$('body').append('<img id="aZoom" />');
			$('#aZoom').css({
						'position': 'absolute',
						/*'cursor': 'pointer',*/
						'display': 'none'
						});
			$('#aZoom').click(function(){
				aZoomer.hide();
			});
		},
		zoom: function(i) {
			var s='';
			if (this.current != null) { return; }
			
			this.current=i;
			
			s=$(this.current).attr('rel');

            if (typeof(s) == 'undefined') {
                    s=$(this.current).attr('src');
            }
           
			
			if (typeof(s) != 'undefined'){
                /*$(this.current).css({
                            'cursor': 'wait'
                            });*/
    
                $('#aZoom').get(0).onload=function() {
                    aZoomer.show();
                }
                $('#aZoom').get(0).src=s;
                
            } else {
                aZoomer.hide();
            }
		},
		show: function() {
			/*$(this.current).css({
						'cursor': 'pointer'
						});*/
			$('#aZoom').css({
				'left': $(this.current).offset().left,
				'top': $(this.current).offset().top,
				'width': $(this.current).width(),
				'height': $(this.current).height()+160,
				'display': 'block',
				'z-index': '22',
				'box-shadow': '10px 10px 20px #555'
			});
			$('#aZoom').stop(true,true).animate({
												'width': this.params.width,
												'height': this.params.height,
												'left': ($(window).width()-this.params.width)/2+$(window).scrollLeft(),
												//'top': ($(window).height()-this.params.height)/2+$(window).scrollTop()
												'top': 50
												},this.params.speed);
		},
		hide: function() {
			$('#aZoom').stop(true,true).animate({
												'left': $(this.current).offset().left,
												'top': $(this.current).offset().top,
												'width': $(this.current).width(),
												'height': $(this.current).height()+160
												},this.params.speed,function(){
																			$('#aZoom').css('display','none');
																			aZoomer.current=null;
																			});
		}
	}
	
	aZoomer.init($(this),settings);
}

