// <![CDATA[
/* jquery.livebar - PeexMe common JavaScript
 * Copyright (C) 2009 MEETIC
 * 
 * date: 20090922
 * version 0.1
 * 
 * required JS library:
 * JQuery library : /javascript/inc/jquery.js
 * 
 */

(function($){
	$.fn.livebar = function(p){
	
		var p = $.extend({
			enabled							:true,
			liveframe						:document,
			livealert						:$(".rf_tweexlive_content"),
			livealert_enabled		:false
		},p);
		
		var _this				= $(this);
		var _error			= false;
		var _connected	= (typeof peexCom != "undefined");

		function pos(){
			if($.browser.msie) {
				var ifr = document.createElement("iframe");
				$(p.livealert).append(ifr); //IE focus hack
			}
		}
		
		function footer_pos(){
			$(_this).css({
					"position":"fixed",
					"z-index":"1000",
					"top":$(window).height() - $(_this).height() + "px"
				});
		}
		
		/* return */
		return this.each(function(){
			if(!p.enabled){
				_this.hide();
				return false;
			}
			else{
				$("body").height($("body").height());
				_this.show();
				if(p.livealert_enabled && _connected)
					$(p.livealert).show();
				else
					$(p.livealert).hide();
			}
			footer_pos();
			$(window).resize(function(){
					footer_pos();
				});
		});
	}
})(jQuery);

$(document).ready(function(){
	$(".rf_footer").livebar({
		enabled							:true,
		livealert						:$(".rf_tweexlive_content"),
		livealert_enabled		:false
	});
});

/* EOF */
// ]]>
