var GSFN;
if(GSFN == undefined) {
	GSFN = {};
}

GSFN.tic4_feedback_widget = function() {
	this.feedback_url = 'http://getsatisfaction.com/bluebear/feedback/topics/new?display=overlay&style=idea&product=bluebear_tic4';

	this.overlay_html = '<div id="fdbk_overlay" style="display:none">' +
	'<div id="fdbk_container">' +
	'<a href="#" id="fdbk_close"></a>' +
	'<iframe src="/scripts/feedback/tranpsarent.gif" id="fdbk_iframe" allowTransparency="true" scrolling="no" frameborder="0" class="loading"></iframe>' +
	'</div>' +
	'<div id="fdbk_screen"></div>' +
	'</div>';

	document.write(this.overlay_html);

	var feedback_obj = this;
	$('fdbk_link').addEvent('click', function(e) {
		if (e) e.stop();
		feedback_obj.show();
	});
	$('fdbk_close').addEvent('click', function(e) {
		if (e) e.stop();
		feedback_obj.hide();
	});
	$('fdbk_iframe').setProperty('src', '/scripts/feedback/tranpsarent.gif');
};

GSFN.tic4_feedback_widget.prototype = {
	set_position : function() {
		this.scroll_top = document.documentElement.scrollTop || document.body.scrollTop;
		this.scroll_height = document.documentElement.scrollHeight;
		this.client_height = window.innerHeight || document.documentElement.clientHeight;

		$('fdbk_screen').setStyle('height', this.scroll_height+'px');
		$('fdbk_container').setStyle('top', this.scroll_top+(this.client_height*0.1)+'px');
	},

	show : function() {
		$('fdbk_iframe').setProperty('src', this.feedback_url);
		$('fdbk_iframe').addEvent('load', this.loaded);
		this.set_position();

		$$('html').addClass('feedback_tab_on');
		$('fdbk_overlay').setStyle('display', 'block');
	},

	hide : function() {
		$('fdbk_iframe').removeEvent('load', this.loaded);
		$('fdbk_overlay').setStyle('display', 'none');
		$('fdbk_iframe').setProperty('src', '/scripts/feedback/tranpsarent.gif');
		$('fdbk_iframe').className = 'loading';

		$$('html').removeClass('feedback_tab_on');
	},

	loaded : function() {
		$('fdbk_iframe').className = 'loaded';
	}
}

new GSFN.tic4_feedback_widget();