/**
 * @package:     Facebook Skin Dialog Window
 * @sub-package: jQuery Plugin [Original]
 * @author:      Ashley Meadows <takingsides at gmail dot com>
 * @version:     2.7.4 (original)
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 * fb-dialog is a free jQuery plug-in, which has taken the facebook
 * dialog box look & feel, and allows the user to parse a click
 * handler which will trigger the dialog. In addition we also have
 * requested a URL to be parsed which will collect synchronous data
 * to a serverside script, including any paramers under the vars
 * option of the fbdialog settings. fb-dialog will execute a single
 * dialog window at any one time, and is very very flexible. You can
 * stick iframes inside the ajax requested file, if you want to do
 * image uploading or form submitting without moving from where you
 * are.
 *
 * Fb-dialog uses the jQuery $.post() feature, however depending
 * on what you want you can modify this to use any other jQuery
 * embedded ajax calling features for whatever purpose you need this
 * little window for.
 *
 * Please note i have released this intending its use for good useful
 * purposes and will not take any responsibility for any problems it
 * may cause. I hope you have fun playing with it, and find a great
 * use for it ;D.. I have!
 */

var $fbdialog = {'current': null,'wid': 0,'hei': 0,'static': {},'setPosition': function() {var _innerWidth = 0, _innerHeight = 0;try {if ((typeof(this.static.top)) == 'string' && (this.static.top == 'auto')) {var _m = parseInt((($(window).height() - $('.fbdialog-content-inner').height()) / 2));_innerHeight = ((this.resizable) && (isNaN(_m) || _m < 0)) ? 0 : (($(window).height() - $('.fbdialog-l').height()) / 2);} else {_innerHeight = isNaN(parseInt(this.static.top)) ? 0 : this.static.top;};if ((typeof(this.static.left)) == 'string' && (this.static.left == 'auto')) {_innerWidth = (($(window).width() - $('#' + this.current).width()) / 2);} else {_innerWidth = isNaN(parseInt(this.static.left)) ? 0 : this.static.left;};} catch (Exception) {_innerWidth = (($(window).width() - $('#' + this.current).width()) / 2);if (isNaN((($(window).height() - $('.fbdialog-content-inner').height()) / 2))) {_innerHeight = (($(window).height() - $('#' + this.current).height()) / 2);} else {_innerHeight = (($(window).height() - $('.fbdialog-l').height()) / 2);};};if (this.static.top == 'auto') {_innerHeight += ($(window).scrollTop() / 2);};return { 'x': _innerWidth, 'y': _innerHeight };},'updateBorders': function() {$('.fbdialog-l,.fbdialog-r').css('height', $('.fbdialog-content').height());},'resetConf': function() {this.current = null;this.wid = 0;this.hei = 0;this.static = {};}}; (function($) { $(window).resize(function() { if ($fbdialog.current == null) { return; }; var o = $fbdialog.setPosition(); $('#' + $fbdialog.current).css({ 'top': o.y, 'left': o.x }); }).scroll(function() { if ($fbdialog.current == null) { return; }; var o = $fbdialog.setPosition(); $('#' + $fbdialog.current).css({ 'top': o.y, 'left': o.x }); }); $.fn.fbdialog = function(url, settings) { if (url == 'close') { $('#' + $fbdialog.current).hide().remove(); $fbdialog.resetConf(); return this; }; this.live('click', function() { options = $.extend({ 'width': 500, 'height': 150, 'padding': 5, 'resizable': false, 'scrollbar': false, 'background': '#fff', 'close': null, 'static': { 'top': 'auto', 'left': 'auto' }, 'vars': {}, 'sendElement': false }, settings); if ((options.static.left == null) || (options.static.left == 'undefined')) { options.static.left = 'auto'; }; if ((options.static.top == null) || (options.static.top == 'undefined')) { options.static.top = 'auto'; }; if ($fbdialog.current != null) { return this; }; $fbdialog.current = 'fbdialog_' + (new Date()).getTime(); $fbdialog.wid = (($(window).width() - (options.width + 20)) / 2); $fbdialog.hei = (($(window).height() - (options.height + 20)) / 2); $fbdialog.static = options.static; $('<div>').addClass('fbdialog-child').appendTo('body').attr('id', $fbdialog.current).css({ 'width': (options.width + 20), 'height': (options.height + 20) }); if ((options.sendElement != null) && (options.sendElement)) { options.vars.element = $(this).attr('id'); }; options.vars.timestamp = (new Date()).getTime();  if (typeof(url) == 'function') { try { eval('var $return_url = (' + url + ')();'); if ($return_url.length > 0) { url = $return_url; }; } catch(Exception) {}; }; if (url.toString() == 'close') { $('#' + $fbdialog.current).hide().remove(); $fbdialog.resetConf(); return this; }; $.post(url.toString(), options.vars, function(_sync) { var _css = { 'width': options.width, 'background': options.background }; if (options.resizable) { _css.minHeight = options.height; } else { _css.height = options.height; _css.overflow = options.scrollbar ? 'auto' : 'hidden'; }; $('<div>').addClass('fbdialog-tl').appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-t').css('width', options.width).appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-tr').appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-next').appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-l').css('height', options.height).appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-content').css(_css).appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-content-inner').css('margin', options.padding).html(_sync).appendTo($('.fbdialog-content')); $('<div>').addClass('fbdialog-r').css('height', options.height).appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-next').appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-bl').appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-b').css('width', options.width).appendTo($('#' + $fbdialog.current)); $('<div>').addClass('fbdialog-br').appendTo($('#' + $fbdialog.current)); if (typeof(options.close) == 'string') { try { $(options.close).live('click', function() { $('#' + $fbdialog.current).fbdialog('close'); }); } catch(Exception) {}; }; $('#' + $fbdialog.current).show(); $('.fbdialog-l,.fbdialog-r').css('height', $('.fbdialog-content').height()); var o = $fbdialog.setPosition();$('#' + $fbdialog.current).css({'top': o.y,'left': o.x});});}); return this;};})(jQuery);
