initializeWindows = function () {

	StrixPopup = new Class({
		Implements: Options,
		options: {
			width: 700,
			height: 400,
			method: 'xhr',
			type: 'modal',
			reload: false
		},
		
		initialize: function(el){
		
			if (el.getProperty('rel')) {
				this.setOptions(JSON.decode(el.getProperty('rel')));
			}

			reload=this.options.reload;

			var size = document.getSize(), scroll = document.window.getScroll();

			//smanji popup ukoliko ne stane na ekran, da ne dobijemo horiz scrollbar
			if (this.options.width>=size.x) this.options.width=size.x-50;
			if (this.options.height>=size.y) this.options.height=size.y-70;

			new MUI.Modal({
				id: 'strix-popup',
				title: el.getProperty('title'),
				loadMethod: this.options.method,
				contentURL: el.getProperty('href'),
				width: this.options.width,
				height: this.options.height,
				type: this.options.type,
				modalOverlayClose: false,
				onContentLoaded: function(){
					if ($$('.mocha-close')) {
						$$('.mocha-close').each(function(el){
							el.addEvent('click', function(e){	
								new Event(e).stop();
								MUI.closeWindow($('strix-popup'));
							});
						});
					}
				}, //end onContentLoaded
				onCloseComplete: function () {
					if (reload) {
						document.location.reload();
					}
				}
			});
		} //initialize
	});

	if ($$('a.strix-popup')) {
		$$('a.strix-popup').each(function(el){
			el.addEvent('click', function(e){	
				new Event(e).stop();
				new StrixPopup(el);				
			});
		});
	}
}

window.addEvent('domready', function(){

	initializeWindows();

});
