var Pattern = PatternInit('/src/maplos.js.html', function(){
	//fake classes
	Map = {
		zoom: 12
	}
	Env.set({
		mode: 'other'
	})
	Status = {
		set: function(){
		}
	}
	var FlashScreen = (function(){
		var initFlashScreen = function(holder){
			var self 				= this;
			self.holder 		= holder;
			var keyPattern 	= /flash\-screen\-([^\.]{1,})\.png/gi;
			var backgroundImage = holder.css('background-image');
			if (backgroundImage.match(keyPattern)){
				keyPattern.lastIndex 	= 0;
				self.key 							= keyPattern.exec(backgroundImage)[1];
				self.bindClick();
			}else{
				alert('FlashScreen: cant detect key');
			}
		}
		initFlashScreen.prototype = {
			flash: false,
			bindClick: function(){
				var self = this;
				self.holder.one('click', function(){
					self.loadFlash();
				})
			},
			loadFlash: function(){
				var self = this;
				self.flash = jQuery(Pattern('flashScreen.object', {
					key: self.key
				}));
				self.holder.html('');
				self.holder.append(self.flash);
				Event.bind('popup.show', function(){
					if (self.flash){
						self.flash.remove();
						self.flash = false;
						self.bindClick();
					}
				});
			}
		}
		return {
			init: function(elements){
				elements.each(function(){
					new initFlashScreen(jQuery(this));
				})
			}
		}
	})();
	jQuery(function(){
		Event.notify('load.formCore');
		FlashScreen.init(jQuery('.flash-screen'));
	});
});
