/*
 * jQuery Impromptu Extension
 * By: John Dobiatowski [http://dobiatowski.blogspot.com]
 * Version 0.9.3 for jQuery Impromptu 3.1+
 * Last Modified: 2/4/2011
 *
 * Download at: http://dobiatowski.blogspot.com/p/impromptu-extension.html
 *
 * Copyright 2010 John Dobiatowski
 * Attribution-ShareAlike 3.0 Unported
 * http://creativecommons.org/licenses/by-sa/3.0/
 *
 * Improvements:
 *
 *	[feature] submiting forms on enter event inside prompt
 *		it support several forms in prompt, they are detected by form name
 *		for example: login form and register form opened in one prompt
 *
 *	[fix] performance problem in zoom mode fixed
 *		when zoom in IE8 is set, all animations of prompt slow down dramaticly and event stuck
 *		(tested on 2,8GHz CPU, 2GB RAM, WinXP)
 *		patch detect zoom and turn off animations
 *
 *	[fix] prompt reopen problem - if there is already prompt with the same ID, it close it and open new one
 *		it prevents situations when you could open serveral the same prompts, one overlapping other
 *
 * Usage:
 *
 *	This is extension of jQuery Impromptu, so you need both files:
 *		- jQuery Impromptu Version 3.1+
 *		  download: http://trentrichardson.com/Impromptu/index.php
 *		- jQuery Impromptu Extension Version 0.9.3 for jQuery Impromptu 3.1+
 *		  download: http://dobiatowski.blogspot.com/
 *
 */
(function(a){a.prompt.submit=function(b){var c=a.prompt.getCurrentState();var d=c.children("."+a.prompt.tempOptions.prefix+"message");var e={};var f=a("#"+a.prompt.currentPrefix);a.each(f.find("#"+a.prompt.tempOptions.prefix+"states :input").serializeArray(),function(a,b){if(e[b.name]===undefined){e[b.name]=b.value}else if(typeof e[b.name]==Array||typeof e[b.name]=="object"){e[b.name].push(b.value)}else{e[b.name]=[e[b.name],b.value]}});var g=a.prompt.tempOptions.submit(b,d,e);if(g===undefined||g){a.prompt.close()}};a.prompt.tempOptions;a.promptExt=function(b,c){var d=window.screen.deviceXDPI;if(typeof d!="undefined"&&d!=96){c.overlayspeed=0;c.promptspeed=0;c.show="show"}a.prompt.tempOptions=a.extend({},a.prompt.defaults,c);if(a("#"+a.prompt.tempOptions.prefix).length!=0){a.prompt.close();setTimeout(function(){a.promptExt(b,c)},250);return}a.prompt(b,c);var e;var f=function(b){if(b.keyCode==13)setTimeout(function(){g(b)},0);else a.promptExt.oldInputValue=b.currentTarget.value};var g=function(b){if(a.promptExt.oldInputValue==b.currentTarget.value)a.prompt.submit(b.currentTarget.form.name);else a.promptExt.oldInputValue=b.currentTarget.value};a("#"+a.prompt.tempOptions.prefix+"states form").submit(function(){return false});a("#"+a.prompt.tempOptions.prefix+"states ."+a.prompt.tempOptions.prefix+"message :input").bind("keyup focus",f)}})(jQuery)
