var Tooltip = Class.create({
	initialize: function(window, url) {
	    this.window = window;
	    this.window.setZIndex(900);
	    this.url = url;
	    this.img = '<img src="' + this.url +  'ajax-loader.gif" alt="" style="vertical-align:top" />';
	    this.loading = false;
	},

	setTitle: function (title) {
		this.window.setTitle(title);
		return this;
	},
	
	setSize: function (width, height) {
		this.window.setSize(width, height);
    	return this;
	},
	
	setContent: function (content) {
		this.window.getContent().update(content);
		return this;
	},

	setById: function (id) {
		this.window.getContent().update($(id).innerHTML);
		return this;
	},

	show: function () {
		this.window.showCenter();
		return this;
	},
	
	sendForm: function (formId, feadbackElemId) {
		if (tooltip.loading) return;
		var contactForm = new VarienForm(formId);
				
		if (contactForm.validator.validate()) {
			$(formId).request({
				onFailure: function(){
					tooltip.loading = false;
					$(feadbackElemId).setStyle({ visibility: 'hidden' });
				},
				onLoading: function() {
					tooltip.loading = true;
					$(feadbackElemId).innerHTML = tooltip.img + ' Trwa wysyłanie ... proszę czekać';
					$(feadbackElemId).setStyle({ visibility: 'visible' });					
				},
	    		onComplete: function(transport){
					tooltip.loading = false;
					var data = eval('(' + transport.responseText + ')');
					
	  		  		$(feadbackElemId).addClassName(data.type);
	  		  		$(feadbackElemId).innerHTML = data.msg;
	  		  	}
	    	})
    	}
	}
})

var tooltip = null;

	function getTooltipObject(a,url)
	{
		if (null == tooltip) {
			var oWindow = new Window({className: "nitrotek", title: '', width:100, height:100, resizable:false, minimizable:false, maximizable:false, destroyOnClose: false, recenterAuto:false, showEffect: Element.show, hideEffect: Element.hide});
			tooltip = new Tooltip(oWindow, url) ;
		}
		return tooltip;	
	}

function showWinCW2(url){
var win = new Window({className: "dialog", title: "Ruby on Rails", 
		      width:530, height:330, resizable: true, zIndex: 100, top: 20,draggable:true, wiredDrag: true, 
		      url: url, showEffectOptions: {duration:1.5}});
win.showCenter();
}

function showWinCW(url)
{
	Dialog.alert({url: url, options: {method: 'get'}}, {className: "dialog", width:540, okLabel: "Zamknij", zIndex:100, top: 100});
}

