if(jQuery)(
	function(jQuery){
		jQuery.extend(jQuery.fn,{
			photoslider:function(options) {
				jQuery(this).each(function(){
					var settings = jQuery.extend({
					   't_width' : 0,
                       't_height' : 0
					}, options);
                    var scroll = {
                        'left' : 0
                    }
                    $(this).data('settings',settings);
                    $(this).append('<div class="arrow_left"></div><div class="arrow_right"></div>');
                    var photos = $(this).children('.scrollarea').children('a');
                    $(this).find('.scrollarea').css({
                       'width' : (settings.t_width*photos.length)+'px'
                    });
                    /* Slide left action */
                    $(this).find('.arrow_left').click(function(){
                        if(scroll.left < 0){
                            scroll.left = scroll.left + settings.t_width;
                            $(this).parent('div').children('.scrollarea').animate({
                                'left' : scroll.left+'px'
                            }, 500);
                        }
                        if(scroll.left >= 0){
                            $(this).hide();
                            $(this).parent('div').children('.arrow_right').show();
                        }
                    });
                    /* Slide right action */
                    $(this).find('.arrow_right').click(function(){
                        maxscroll = ($(this).parent('div').children('.scrollarea').width()-$(this).parent('div').width());
                        maxscroll = maxscroll - (maxscroll*2);
                        if(scroll.left > maxscroll){
                            scroll.left = scroll.left - settings.t_width;
                            $(this).parent('div').children('.scrollarea').animate({
                                'left' : scroll.left+'px'
                            },500);
                        }
                        if(scroll.left <= maxscroll){
                            $(this).hide();
                            $(this).parent('div').children('.arrow_left').show();
                        }
                    });
                    /*$(this).find('.arrow_right, .arrow_left').hover(function(){
                        $(this).animate({
                            borderWidth: 1
                        },300);    
                    }, function(){
                        $(this).animate({
                            borderWidth: 0
                        },300); 
                    });*/
                });
            }
        })
    }
)(jQuery);
