var last_scroll = 0;
var CBox  =  function() {
		BOX = this;
		this.width 	= 300;
		this.height =  100;
		
		this.create = function(width) {
			if(width)
				this.width = width;	
			if($('.rc').length == 0) {
				$('body').append($('<div class="rc rc-shape rc_shadow_1"></div>').css({width: this.width, display: 'none', margin:'0 0 0 -'+ Math.ceil(this.width/2) + 'px'})
										.append($('<div id="box_content" class="c"></div>'))
										.append($('<i class="b br"></i>'))
										.append($('<i class="b bl"></i>'))
										.append($('<i class="t tr"></i>'))
										.append($('<i class="t tl"></i>'))
										.append($('<div class="close_btn"></div>'))
										);
				$('.close_btn').click(function(){
					BOX.close();
				});
				$('.close_btn').mouseenter(function(){
					$('.close_btn').toggleClass('out');
				});
				$('.close_btn').mouseleave(function(){
					$('.close_btn').toggleClass('out');
				});
			
				$(window).scroll(function() {
					var shift = Math.ceil($(window).height()*10/100);
				    $('.rc').animate({top: ($(this).scrollTop() + shift) + "px"}, 100);
				});
			}

		}
		
		this.insert = function(text) {
			$('#box_content').html(text);
		}
		
		this.append = function(teg, text) {
			$('#box_content').append($(teg).html(text));
		}
		
		this.show = function() {
			$('.rc').fadeIn('slow');
		}
		
		this.close = function() {			
			$('.rc').fadeOut( 500, function() {
				BOX.clear();
			});
		}
		
		this.clear = function() {
			$('#box_content').text('');
		}
		
		this.remove = function() {
			$('.rc').remove();
		}
};

Box = new CBox();