
var WindowsHelper = {
	templatesCache : [],

	getTemplateHtml : function(templateName)
	{
		var html = '';
		
		if (!StickyWindowsFactory.isCreated(templateName))
		{
			var template = $(templateName);
			
			//save Html
			html = template.innerHTML;
			this.templatesCache[templateName] = html;
			
			//remove template from page
			template.parentNode.removeChild(template);
		}
		else
		{
			html = this.templatesCache[templateName];
		}
		
		return html;
	},

	showWindowFromTemplate :function (templateName, element, offsetX, offsetY, divContainer)
	{
		if (!divContainer)
			divContainer = $('windows-container');
			
		var html = this.getTemplateHtml(templateName);
		var win = StickyWindowsFactory.getInstance(templateName);
		
		win.showAtElementPosition(
			element.id,
			html,
			{
				x:offsetX, 
				y:offsetY, 
				bWidth:14, 
				bHeight:5, 
				draggable:false,
				container : divContainer,
				onClose:function(){}
			});	
	},
	
	getControl : function (templateName, controlId)
	{
		return $(templateName).getElementById(controlId);
	}
};

