/**
 * 
 * @param {Object} local_conf
 */
jQuery.fn.setFloatbox = function(local_conf) {
	//
	var conf = {};

	conf.ajaxUrl = null;
	conf.contentHtml = null;

	conf.boxConfig = {};
	conf.bgConfig = {}

	conf.fade = true;

	conf.preHtml = '<div class="floatbox-wrapper"><div class="floatbox-pre"></div><div class="floatbox-content">';
	conf.postHtml = '</div><div class="floatbox-post"></div></div>';
	conf.closeButtonHtml = '<div class="close-floatbox">x</div>';

	conf.wrapperClass = '';

	conf.before = function() {};
	conf.after = function() {};

	//
	var thisJQ = this;

	/**
	 * 
	 */
	var init = function (local_conf) {
		conf = jQuery.extend(conf, local_conf);

		//
		if(typeof(conf.boxConfig['width']) !== 'unknown') {
			conf.boxConfig['marginLeft'] = '-' + parseInt(parseInt(conf.boxConfig['width']) / 2) + 'px';
		}
		
		//
		conf.bgConfig['position'] = (jQuery.browser.msie && parseFloat(jQuery.browser.version) <= 6) ? 'absolute' : 'fixed';

		//	
		thisJQ.click(function(){
			if(conf.ajaxUrl !== null) {
				jQuery.ajax({
					type: 'GET',
					url: conf.ajaxUrl,
					data: {inpl_network_request: 1},
					dataType: 'html',
					success: function (html, textStatus) {
						htmlJQ = jQuery(conf.preHtml + html + conf.postHtml);
						htmlJQ.addClass(conf.wrapperClass);
	
						conf.before(htmlJQ);					
						
						jQuery.floatbox({
							content: htmlJQ,
							boxConfig: conf.boxConfig,
							bgConfig: conf.bgConfig,
							fade: conf.fade,
							button: conf.closeButtonHtml});
	
						conf.after(htmlJQ);
					},
					error: function (XMLHttpRequest, textStatus, errorThrown) {
					}
				});
			}
			else if(conf.contentHtml !== null) {
				htmlJQ = jQuery(conf.preHtml + conf.contentHtml + conf.postHtml);
				htmlJQ.addClass(conf.wrapperClass);

				conf.before(htmlJQ);					

				jQuery.floatbox({
					content: htmlJQ,
					boxConfig: conf.boxConfig,
					bgConfig: conf.bgConfig,
					fade: conf.fade,
					button: conf.closeButtonHtml});

				conf.after(htmlJQ);					
			}
			
			return false;
		});
	}

	//
	jQuery(document).ready(
		function () {
			init(local_conf);
		}
	);			
}
