(function($){
 $.facebox=function(a){
 $.facebox.init();
 $.facebox.loading();
 ($.isFunction(a)?a.call($):$.facebox.reveal(a))
 };
 $.facebox.click=function(b){
 $.facebox.init();
 $.facebox.loading();
 $('#facebox .title').html(b.title);
 if(b.rel.match(/#/)){
 var c=b.rel.split('#')[0];
 var d=b.rel.replace(c,'');
 $.facebox.reveal($(d).clone().show())
 }else{
 $.get(b.rel,function(a){
	 $.facebox.reveal(a)
	 })
 }
 };
 $.facebox.popup=function(b,e){
	 $.facebox.init();
	 $.facebox.loading();
	 $('#facebox .title').html(b);
	 if(e.match(/#/)){
		 var c=e.split('#')[0];
		 var d=e.replace(c,'');
		 $.facebox.reveal($(d).clone().show())
	 }else{
		 $.get(e,function(a){
				 $.facebox.reveal(a)
				 })
	 }
 };
 $.facebox.settings={
image_types:['png','jpg','jpeg','gif'],facebox_html:' <div id="facebox" style="display:none;"> <table class="popup" align="center" border="0" border="0" cellpadding="0" cellspacing="0"><tr><td> <div class="body"> <div class="header"> <div class="close"><a href="#">x</a></div> <div class="title"></div> </div> <div class="content"></div> </div> </td></tr></table> </div>'
 };
 $.facebox.loading=function(){
	 if($('#facebox .loading').length==1)return true;
	 $('#facebox .content').empty();
	 $('#facebox .body').children().hide().end().append('<div class="loading">loading...</div>');
	 var a=$.facebox.getPageScroll();
	 $('#facebox').css({top:a[1]+($.facebox.getPageHeight()/10),left:a[0]+document.body.clientWidth/2-$('#facebox').width()/2}).show();
$(document).bind('keydown.facebox',function(e){
		if(e.keyCode==27){
		$.facebox.close()
		}
		})
};
$.facebox.reveal=function(a){
	$('#facebox .content').append(a);
	$('#facebox .loading').remove();
	$('#facebox .body').children().fadeIn('fast')
};
$.facebox.close=function(){
	$(document).trigger('close.facebox');
	return false
};
$(document).bind('close.facebox',function(){
		$(document).unbind('keydown.facebox');
		$('#facebox').fadeOut(function(){
			$('#facebox .content').removeClass().addClass('content')
			})
		});
$.fn.facebox=function(d){
	$.facebox.init(d);
	var e=$.facebox.settings.image_types.join('|');
	e=new RegExp('\.'+e+'$','i');
	function click_handler(){
		$.facebox.loading(true);
		$('#facebox .title').html(this.title);
		if(this.href.match(/#/)){
			var b=window.location.href.split('#')[0];
			var c=this.href.replace(b,'');
			$.facebox.reveal($(c).clone().show())
		}else if(this.href.match(e)){
			$.facebox.reveal('<div class="image" align="center"><img src="'+this.href+'" /></div>')
		}else{
			$.get(this.href,function(a){
					$.facebox.reveal(a)
					})
		};
		return false
	};
	this.click(click_handler);
	return this
};
$.facebox.init=function(a){
	if($.facebox.settings.inited){
		return true
	}else{
		$.facebox.settings.inited=true
	}if(a)
	$.extend($.facebox.settings,a);
	$('body').append($.facebox.settings.facebox_html);
	$('#facebox .close').click($.facebox.close);
	$('#facebox .fb-no').click($.facebox.close)
};
$.facebox.getPageScroll=function(){
	var a,yScroll;
	if(self.pageYOffset){
		yScroll=self.pageYOffset;
		a=self.pageXOffset
	}else if(document.documentElement&&document.documentElement.scrollTop){
		yScroll=document.documentElement.scrollTop;
		a=document.documentElement.scrollLeft
	}else if(document.body){
		yScroll=document.body.scrollTop;
		a=document.body.scrollLeft
	}return new Array(a,yScroll)
};
$.facebox.getPageHeight=function(){
	var a;
	if(self.innerHeight){
		a=self.innerHeight
	}else if(document.documentElement&&document.documentElement.clientHeight){
		a=document.documentElement.clientHeight
	}else if(document.body){
		a=document.body.clientHeight
	}return a
}
})
(jQuery);
jQuery(document).ready(function($){
		$('a[rel*=facebox]').facebox();
		});

