AddEvent( window, 'load', initNoticeWindow, false );
//
/*
Script: PBBAcpBox.js
	Contains <PBBAcpBox>
 
Author:
	Pokemon_JOJO, <http://www.mibhouse.org/pokemon_jojo>
 
License:
	MIT-style license.
 
*/
 
/*
Class: PBBAcpBox
	Clone class of original javascript function : 'alert', 'confirm' and 'prompt'
 
Arguments:
	options - see Options below
 
Options:
	name - name of the box for use different style
	zIndex - integer, zindex of the box
	onReturn - return value when box is closed. defaults to false
	onReturnFunction - a function to fire when return box value
	BoxStyles - stylesheets of the box
	OverlayStyles - stylesheets of overlay
	showDuration - duration of the box transition when showing (defaults to 200 ms)
	showEffect - transitions, to be used when showing
	closeDuration - Duration of the box transition when closing (defaults to 100 ms)
	closeEffect - transitions, to be used when closing
	onShowStart - a function to fire when box start to showing
	onCloseStart - a function to fire when box start to closing
	onShowComplete - a function to fire when box done showing
	onCloseComplete - a function to fire when box done closing
*/
var PBBAcpBox = new Class({
 
	getOptions: function(){
		return {
			name: 'PBBAcp',
			zIndex: 65555,
			onReturn: false,
			onReturnFunction : Class.empty,
			BoxStyles: {
				'width': 500
			},
			OverlayStyles: {
				'background-color': '#000',
				'opacity': 0.7
			},
			showDuration: 200,
			showEffect: Fx.Transitions.linear,
			closeDuration: 100,
			closeEffect: Fx.Transitions.linear,
			moveDuration: 500,
			moveEffect: Fx.Transitions.backOut,
			moveOnScroll : true,
			dontCloseOnClick : false,
			LCMode : false,
			onShowStart : Class.empty,
			onShowComplete : Class.empty,
			onCloseStart : Class.empty,
			onCloseComplete : function(properties) {
				if ( !this.options.dontCloseOnClick )
					this.options.onReturnFunction(this.options.onReturn);
			}.bind(this)
		};
	},
 
	initialize: function(options){
		this.setOptions(this.getOptions(), options);
 
		// création de l'overlay
		this.Overlay = new Element('div', {
			'id': 'BoxOverlay',
			'styles': {
				'display': 'none',
				'z-index': this.options.zIndex,
				'position': 'absolute',
				'top': '0',
				'left': '0',
				'background-color': this.options.OverlayStyles['background-color'],
				'opacity': 0,
				'height': window.getScrollHeight() + 'px',
				'width': window.getScrollWidth() + 'px'
			}
		});
 
		this.Content = new Element('div', {
			'id': this.options.name + '-BoxContent'
		});
 
		this.InBox = new Element('div', {
			'id': this.options.name + '-InBox'
		}).adopt(this.Content);;
 
		this.Box = new Element('div', {
			'id': this.options.name + '-Box',
			'styles': {
				'display': 'none',
				'z-index': this.options.zIndex + 2,
				'position': 'absolute',
				'top': '0',
				'left': '0',
				'width': this.options.BoxStyles['width'] + 'px'
			}
		}).adopt(this.InBox);
 
		this.Overlay.injectInside(document.body);
		this.Box.injectInside(document.body);
 
		// Si le navigateur est redimentionné
	
		window.addEvent('resize', function() {
			if(this.options.display == 1) {
				this.Overlay.setStyles({
					'height': window.getScrollHeight() + 'px',
					'width': window.getScrollWidth() + 'px'
				});
				this.replaceBox();
			}
		}.bind(this));
 
		window.addEvent('scroll', this.replaceBox.bind(this));
	},
 
	/*
	Property: display
		Show or close box
 
	Argument:
		option - integer, 1 to Show box and 0 to close box (with a transition).
	*/	
	display: function(option){
		// Stop la transition en action si elle existe	
		if(this.Transition)
			this.Transition.stop();				
 
		// Show Box	
		if(this.options.display == 0 && option != 0 || option == 1) {
			this.Overlay.setStyle('display', 'block');
			this.options.display = 1;
			if ( this.options.ajax )
			{
				this.options.OverlayStyles = {
					'background-color' : "#000",
					'opacity' : 0.01
				};
			}
			if ( this.options.progress )
			{
				this.options.OverlayStyles = {
					'background-color' : "#000",
					'opacity' : 0.4
				};
			}
		
			
			if ( this.Overlay.getStyle( 'height' ) != (window.getScrollHeight()+'px'))
			{
				this.Overlay.setStyles({
						'height': window.getScrollHeight() + 'px',
						'width': window.getScrollWidth() + 'px'
					});
			}
				
 				
			
//			'height': window.getScrollHeight() + 'px',
//				'width': window.getScrollWidth() + 'px'


			//console.log(this.options);
			this.fireEvent('onShowStart', [this.Overlay]);
 			// Nouvelle transition		
			this.Transition = this.Overlay.effect(
				'opacity', 
				{
					duration: this.options.showDuration,
					transition: this.options.showEffect,
					onComplete: function() {
						try{var a=this.options.ajax;}catch(z){var ajax=false;}
						if ( !this.options.ajax )
						{
							if ( bd.browser=="Explorer")
							{
								var elements = document.getElementsByTagName ( 'SELECT' );
								for ( var i = 0; i < elements.length; i++ )
								{
									try{elements[i].style.display='none';}catch(z){}
								}
							}				
							sizes = window.getSize();
							this.Box.setStyles({
								'display': 'block',
								'left': (sizes.scroll.x + (sizes.size.x - this.options.BoxStyles['width']) / 2).toInt()
							});
							this.replaceBox();
						}	
						this.fireEvent('onShowComplete', [this.Overlay]);
					}.bind(this)
				}
			).start(this.options.OverlayStyles['opacity']);
		}
		// Close Box
		else {
			this.Box.setStyles({
				'display': 'none',
				'top': 0
			});
			this.Content.empty();
			this.options.display = 0;
 
			this.fireEvent('onCloseStart', [this.Overlay]);
 
			// Nouvelle transition		
			this.Transition = this.Overlay.effect(
				'opacity',
				{
					duration: this.options.closeDuration,
					transition: this.options.closeEffect,
					onComplete: function() {
					
						if ( bd.browser=="Explorer")
						{
							var elements = document.getElementsByTagName ( 'SELECT' );
							for ( var i = 0; i < elements.length; i++ )
							{
								try{elements[i].style.display='';}catch(z){}
							}
						}
					
						if ( !this.options.dontShowOnClick )
							this.fireEvent('onCloseComplete', [this.Overlay]);
					}.bind(this)
				}
			).start(0);
		}			
	},
 
	/*
	Property: replaceBox
		Move Box in screen center when brower is resize or scroll
	*/
	replaceBox: function() {
		if(this.options.display == 1 && this.options.moveOnScroll ) {
			sizes = window.getSize();
 
			if(this.MoveBox)
				this.MoveBox.stop();
 
			this.MoveBox = this.Box.effects({
				duration: this.options.moveDuration,
				transition: this.options.moveEffect
			}).start({
				'left': (sizes.scroll.x + (sizes.size.x - this.options.BoxStyles['width']) / 2).toInt(),
				'top': (sizes.scroll.y + (sizes.size.y - this.Box.offsetHeight) / 2).toInt()
			});
		}
	},
 
	/*
	Property: messageBox
		Core system for show all type of box
 
	Argument:
		type - string, 'alert' or 'confirm' or 'prompt'
		message - text to show in the box
		properties - see Options below
		input - text value of default 'input' when prompt
 
	Options:
		textBoxBtnOk - text value of 'Ok' button
		textBoxBtnCancel - text value of 'Cancel' button
		onComplete - a function to fire when return box value
	*/	
	messageBox: function(type, message, properties, input, options_save) {
		properties = Object.extend({
			'textBoxBtnOk': 'OK',
			'textBoxBtnCancel': 'Cancel',
			'textBoxInputPrompt': null,
			'onComplete': Class.empty
		}, properties || {});
 
		this.options.onReturnFunction = properties.onComplete;
 
		if(type == 'alert' )
		{
			this.AlertBtnOk = new Element('input', {
				'id': 'BoxAlertBtnOk',
				'type': 'submit',
				'value': properties.textBoxBtnOk,
				'styles': properties.btnWidth ? {'width':properties.btnWidth} : {
					'width': '70px'
				}
			});
 
			this.AlertBtnOk.addEvent('click', function() {
				this.options.onReturn = true;
				this.display(0);
			}.bind(this));
 
			this.Content.setProperty('class','BoxAlert').setHTML(message + '<br />');
			
			try { var nobutt = properties.nobutton; } catch(z){var nobutt=false;}
			if ( !nobutt )
				this.AlertBtnOk.injectInside(this.Content);
			
			this.display(1);
		}
		else if(type == 'confirm') {
			this.ConfirmBtnOk = new Element('input', {
				'id': 'BoxConfirmBtnOk',
				'type': 'submit',
				'value': properties.textBoxBtnOk,
				'styles': {
					'width': '70px'
				}
			});
 
			this.ConfirmBtnCancel = new Element('input', {
				'id': 'BoxConfirmBtnCancel',
				'type': 'submit',
				'value': properties.textBoxBtnCancel,
				'styles': {
					'width': '70px'
				}
			});
 
			this.ConfirmBtnOk.addEvent('click', function() {
				this.options.onReturn = true;
				if ( !this.options.dontCloseOnClick )
				{
					this.display(0);
				}
				else
				{
					//
					this.options.options_save.ok();
					//
				}
			}.bind(this));
 
			this.ConfirmBtnCancel.addEvent('click', function() {
				this.options.onReturn = false;
				this.display(0);
			}.bind(this));		
 
			this.Content.setProperty('class','BoxAlert').setHTML(message + '<br />');
			this.ConfirmBtnOk.injectInside(this.Content);
			this.ConfirmBtnCancel.injectInside(this.Content);
			this.display(1);
		}
		else if(type == 'prompt') {
			this.PromptBtnOk = new Element('input', {
				'id': 'BoxPromptBtnOk',
				'type': 'submit',
				'value': properties.textBoxBtnOk,
				'styles': {
					'width': '70px'
				}
			});
 
			this.PromptBtnCancel = new Element('input', {
				'id': 'BoxPromptBtnCancel',
				'type': 'submit',
				'value': properties.textBoxBtnCancel,
				'styles': {
					'width': '70px'
				}
			});			
 
			this.PromptInput = new Element('input', {
				'id': 'BoxPromptInput',
				'type': 'text',
				'value': input,
				'styles': {
					'width': '250px'
				}
			});
 
			this.PromptBtnOk.addEvent('click', function() {
				this.options.onReturn = this.PromptInput.value;
				if ( !this.options.dontCloseOnClick )
				{
					this.display(0);
				}
			}.bind(this));
 
			this.PromptBtnCancel.addEvent('click', function() {
				this.options.onReturn = false;
				this.display(0);
			}.bind(this));
 
			this.Content.setProperty('class','BoxPrompt').setHTML(message + '<br />');
			this.PromptInput.injectInside(this.Content);
			new Element('br').injectInside(this.Content);
			this.PromptBtnOk.injectInside(this.Content);
			this.PromptBtnCancel.injectInside(this.Content);
			this.display(1);
		}
		else {
			this.options.onReturn = false;
			this.display(0);		
		}
	},
 
	/*
	Property: alert
		Shortcut for alert
 
	Argument:
		properties - see Options in messageBox
	*/		
	alert: function(message, properties){
		this.messageBox('alert', message, properties);
	},
 
	/*
	Property: confirm
		Shortcut for confirm
 
	Argument:
		properties - see Options in messageBox
	*/
	confirm: function(message, properties){
		this.messageBox('confirm', message, properties);
	},
 
	/*
	Property: prompt
		Shortcut for prompt
 
	Argument:
		properties - see Options in messageBox
	*/	
	prompt: function(message, input, properties){
		this.messageBox('prompt', message, properties, input);
	},


	/*
		NOTICE WINDOW IMPLEMENT
			
	Options:
		name - name of the box for use different style
		zIndex - integer, zindex of the box
		onReturn - return value when box is closed. defaults to false
		onReturnFunction - a function to fire when return box value
		BoxStyles - stylesheets of the box
		OverlayStyles - stylesheets of overlay
		showDuration - duration of the box transition when showing (defaults to 200 ms)
		showEffect - transitions, to be used when showing
		closeDuration - Duration of the box transition when closing (defaults to 100 ms)
		closeEffect - transitions, to be used when closing
		onShowStart - a function to fire when box start to showing
		onCloseStart - a function to fire when box start to closing
		onShowComplete - a function to fire when box done showing
		onCloseComplete - a function to fire when box done closing

	Property: messageBox
		Core system for show all type of box
 
	Argument:
		type - string, 'alert' or 'confirm' or 'prompt'
		message - text to show in the box
		properties - see Options below
		input - text value of default 'input' when prompt
 
	Options:
		textBoxBtnOk - text value of 'Ok' button
		textBoxBtnCancel - text value of 'Cancel' button
		onComplete - a function to fire when return box value
	*/
	open: function( options )
	{
		//
		var type = ( options.notext=="" ) ? 'alert' : 'confirm';
		this.options.options_save = options;
		this.options.ajax = false;
		// 
		if ( bd.browser=="Explorer")
		{
			var elements = document.getElementsByTagName ( 'SELECT' );
			for ( var i = 0; i < elements.length; i++ )
			{
				try{elements[i].style.display='none';}catch(z){}
			}
		}
		//
		try{var a=options.btnWidth;}catch(z){options.btnWidth=0;}	
		try{var a=options.nobutton;}catch(z){options.nobutton=false;}	
		this.messageBox( type, options.content,
			{
				textBoxBtnOk: options.oktext,		
				textBoxBtnCancel: options.notext,
				btnWidth: options.btnWidth ? options.btnWidth : 0,
				nobutton: options.nobutton,
				onComplete: function( returnvalue )
				{
					if ( returnvalue )
					{
						try{
						this.options_save.ok(this.options_save.options);
						}catch(z){}
					}
					else
					{
						try{
						this.options_save.no(this.options_save.options);
						}catch(z){}
					}
					return returnvalue;
				}
			},
			options // options to save
		);
	},
	// AJAX EXTENSION
	showOverlay: function( )
	{
		this.options.ajax = true;
		this.display(1);
	},
	close: function( )
	{
		this.display(0);
	},

	showProgress: function( text, buttonText, onCancel )
	{
		//
		params = {};
		this.options.progress=true;
		params.oktext = buttonText;
		params.btnWidth=100;
		if ( buttonText == undefined ) buttonText = "";
		params.nobutton = ( buttonText=="" ) ? true : false;
		params.ok=onCancel;
		params.notext = '';
		params.content = "<div class='loader' id='ajaxloader'>&nbsp;</div><div class='h10'></div><div class='w100'>"+text+"</div>";
		this.open( params );
		//
	},
	
	loadcontent: function( url, params )
	{
		//
//		this.options.LCMode = true;
		//
		//
//		this.Content.id = this.options.name + '-BoxContent760';
//		this.InBox.id = this.options.name + '-InBox760';
//		this.Box.id = this.options.name + '-Box760';
		//
//		console.log(this.Content.id);
//		this.options.BoxStyles.width = '760';
		//
		this.options.dontCloseOnClick = true;
		if ( !params ) params = { };
		params.root = this;
		var xhc = new XHConn( );
		if ( !xhc) { this.open( {content: 'no content' } ); return false; }
		//
		if ( !xhc.connect( url, "GET", "", this.load_complete, params) )
			{ this.open( {content: 'no content' } ); return false; }
	},
	load_complete: function( OXML, params )
	{
		params.root.options.moveOnScroll = false;
		params.content = OXML.responseText;
		params.root.open( params );
		if ( params.onContentLoaded ) params.onContentLoaded( );
		//
		params.root.options.tim = setInterval( 'noticeWindow_content.fixoverlay();', 500 );
		//
	},
	fixoverlay: function()
	{
		clearInterval( this.options.tim );
		this.display(1);		
	}
});
 
PBBAcpBox.implement(new Events, new Options);

var noticeWindow = false;
var noticeWindow_content = false;
var noticeWindow_ajax = false;
function initNoticeWindow( )
{
	noticeWindow = new PBBAcpBox({
		BoxStyles: { 'width': 494 }
	});
	noticeWindow_big = new PBBAcpBox({ name: 'PBBAcp760',
		BoxStyles: { 'width': 760 }
	});
	noticeWindow_content = new PBBAcpBox({ name: 'PBBAcp760',
		BoxStyles: { 'width': 760 }
	});
	noticeWindow_ajax = new PBBAcpBox({
		BoxStyles: { 'width': 494 },
		ajax: true
	});
}

/*



var _RESIZE_DURATION 		= 0; 		// Duration of height and width resizing (ms)
var _INITIAL_WIDTH			= 300;		// Initial width of the box (px)
var _INITIAL_HEIGHT			= 300;		// Initial height of the box (px)
var _CONTENTS_WIDTH 		= 300;		// Actual width of the box (px)
var _CONTENTS_HEIGHT		= 100;		// Actual height of the box (px)
var _DEF_CONTENTS_WIDTH		= 300;		// Default width of the box (px) - used for resetting when a different setting was used
var _DEF_CONTENTS_HEIGHT	= 100;		// Default height of the box (px) - used for resetting when a different setting was used
var _ANIMATE_CAPTION		= false;		// Enable/Disable caption animation
var _EVAL_SCRIPTS			= false;	// Option to evaluate scripts in the response text
var _EVAL_RESPONSE			= false;	// Option to evaluate the whole response text

// The MOOdalBox object in its beauty
var minZindex = 500000;
var ajaxLayer = false;
//
function nw()
{
return {
	
	// init the MOOdalBox
	init: function (options ) {
		
		// init default options
		this.options = Object.extend({
			resizeDuration: 	_RESIZE_DURATION,
			initialWidth: 		_INITIAL_WIDTH,	
			initialHeight: 		_INITIAL_HEIGHT,
			contentsWidth: 		_CONTENTS_WIDTH,
			contentsHeight: 	_CONTENTS_HEIGHT,
			defContentsWidth: 	_DEF_CONTENTS_WIDTH,
			defContentsHeight: 	_DEF_CONTENTS_HEIGHT,
			animateCaption: 	_ANIMATE_CAPTION,
			evalScripts: 		_EVAL_SCRIPTS,
			evalResponse: 		_EVAL_RESPONSE
		}, options || {});
		
		this.oktext = "ok";
		this.notext = "";
		this.ajax = options[ 'ajax' ];
		this.paramOptions = { };
		this.functionOK = false;
		this.functionNO = false;
		this.errorWindow = false;
		try{ this.root = this.options.root; } catch(z){}
		
		// add event listeners
		this.eventPosition = this.position.bind(this);
		this.specID = Math.floor(Math.random()*100000);
		
		// init the HTML elements
		// the overlay (clickable to close)
		this.overlay = new Element('div').setProperty('id', 'mb_overlay'+this.specID).setStyles({zIndex: minZindex++}).injectInside(document.body);
		if ( this.ajax ) this.overlay.className += "mb_overlay_ajax";
		else this.overlay.className += "mb_overlay";
		// the center element		
		this.center = new Element('div').setProperty('id', 'mb_center'+this.specID).setStyles({width: this.options.initialWidth+'px', height: this.options.initialHeight+'px', marginLeft: '-'+(this.options.initialWidth/2)+'px', display: 'none', zIndex: minZindex++ }).injectInside(document.body);
		this.center.className += "mb_center";

		// the actual page contents
		this.contents = new Element('div').setProperty('id', 'mb_contents'+this.specID).injectInside(this.center);
		this.contents.className += "mb_contents";
		this.contents.style.paddingTop = '10px';

		this.caption = new Element('div').setProperty('id', 'mb_caption'+this.specID).setStyles({display:'none', zIndex: minZindex++ }).injectInside(document.body);
		this.caption.className += "mb_caption";
		
		// the bottom part (caption / close)
		this.bottom = new Element('div').setProperty('id', 'mb_bottom'+this.specID).setStyles({display:'none', zIndex: minZindex++ }).injectInside(document.body);
		this.bottom.className += "mb_bottom";

		this.closelink = new Element('a').setProperties({id: 'mb_close_link'+this.specID, href: '#'}).injectInside(this.bottom);
		this.closelink.className += "mb_close_link";
	
		this.buttons = new Element('div').setProperty('id', 'mb_buttons'+this.specID).injectInside(this.bottom);
		this.buttons.className += "mb_buttons";
		new Element('div').setStyle('clear', 'both').injectInside(this.bottom);
		
		this.error = new Element('div').setProperty('id', 'mb_error'+this.specID).injectInside(this.center);
		this.error.className += "mb_error";
		
		// attach the close event to the close button / the overlay
		this.closelink.onclick = this.overlay.onclick = this.close.bind(this);
		
		// init the effects
		var nextEffect = this.nextEffect.bind(this);
		this.fx = {
			overlay: 	this.overlay.effect('opacity', { duration: 0 }).hide(),
			resize: 	this.center.effects({ duration: this.options.resizeDuration, onComplete: nextEffect }),
			contents: 	this.contents.effect('opacity', { duration: 0, onComplete: nextEffect }),
			bottom: 	this.bottom.effects({ duration: 0, onComplete: nextEffect }),
			caption: 	this.caption.effects({ duration: 0, onComplete: nextEffect })
		};
	},
		
	click: function(link) {
		return this.open (link.href, link.title, link.rel);
	},

	position : function() { },
	

	setTexts : function( okText, noText )
	{
		this.oktext = okText;
		this.noText  = noText;
	},

	showOverlay : function ()
	{
		//
//		alert('s-');
		this.position();
		//alert('s0');
		this.setup(true);
		//alert('s1');
		this.top = Window.getScrollTop() + (Window.getHeight() / 15);
		
		this.center.setStyles({top: this.top+'px', display: ''});
		//alert('s2:'+this.ajax+"-"+this.fx);
		//var num = this.ajax ? 0.0 : 0.2;
		num = 0.8;
		this.fx.overlay.custom(num);
		this.center.style.display='none';
		//alert('s3');
		//
		this.overlay.onclick = function( ) { };
		//alert('overlay ok');
	},

	open: function( op )
	{
		this.title = op.title;
		this.paramOptions = op.options;

		if ( op.ok ) this.functionOK = op.ok;
		else this.functionOK = function() { };
		if ( op.no ) this.functionNO = op.no;
		else this.functionNO = function() { };
		//
		var ok = op.oktext ? op.oktext : this.oktext;
		var no = op.notext ? op.notext : this.notext;
		//
		table = "<table class='w100 noborder'><tr><td width='" + ( no == "" ? "w100" : "w50" ) + "' align='center'><input type='button' id='notice_OK"+this.specID+"' value='"+op.oktext+"'>";
		if ( no != "" ) table += "</td><td class='w50' align='center'><input type='button' id='notice_NO"+this.specID+"' value='"+op.notext+"'>";		
		table += "</td></tr></table>";
		
		this.buttons.innerHTML = ( op.nobuttons == 'true' ? "" : table );
		
		$( 'notice_OK'+this.specID ).root = this;
		$( 'notice_OK'+this.specID ).onclick = function ( ) { this.root.functionOK( this.root.paramOptions ); }
		if ( no != "" )
		{
			$( 'notice_NO'+this.specID ).root = this;
			$( 'notice_NO'+this.specID ).onclick = function ( ) { this.root.functionNO( this.root.paramOptions ); }
		}
		
		if ( !op.type ) op.type = "simple";
		this.contents.setHTML( op.content );
		
		this.caption.innerHTML = "wercw34wer";
		
//		if ( op.type == "simple" || op.type == "confirm" || op.type == "waiting" ) this.contents.setHTML( op.content );
		if ( op.type == "error" ) this.contents.className = "mb_error";	else this.contents.className="mb_contents";

		this.showOverlay();
		this.center.style.display='';
		
		if(this.step) return false;
		this.step = 1;

		this.options.contentsWidth = op.width ? op.width : this.options.defContentsWidth;
		this.options.contentsHeight = op.height ? op.height : this.options.defContentsHeight;
		this.contents.scrollTop = 0;
						
//		this.bottom.setStyles({opacity: '0', height: '0px', display: 'none'});

//		this.center.className = 'mb_loading';

		if ( bd.browser=="Explorer")
		{
			var elements = document.getElementsByTagName ( 'SELECT' );
			for ( var i = 0; i < elements.length; i++ )
				try{elements.style.display='none';}catch(z){}
		}

		this.fx.contents.hide();
		var nextEffect = this.nextEffect.bind(this);
		nextEffect( );
		
		if ( !op.dontclose )
		{
			this.center.setStyle('cursor', 'pointer');
			this.bottom.setStyle('cursor', 'pointer');
			this.caption.setStyle('cursor', 'pointer');
		}

		if ( !op.dontclose ) this.center.onclick = this.bottom.onclick = this.close.bind(this);		
		if ( op.dontclose ) this.closelink.onclick = this.overlay.onclick = this.center.onclick = this.bottom.onclick = function( ) { };
		
	},

	loadcontent: function( url, params )
	{
		//
		if ( !params ) params = { };
		params.root = this;
		var xhc = new XHConn( );
		if ( !xhc) { this.open( {content: 'valami' } ); return false; }
		//
		if ( !xhc.connect( url, "GET", "", this.load_complete, params) )
			{ this.open( {content: 'valami' } ); return false; }
	},
	
	load_complete: function( OXML, params )
	{
		params.content = OXML.responseText;
		params.root.open( params );
		if ( params.onContentLoaded ) params.onContentLoaded( );
	},
	getcontent : function ( )
	{
		return this.contents.innerHTML;
	},

	position: function() {
		//this.overlay.setStyles({top: '0px', height: Window.getScrollHeight()+'px'});
//		var a = Window.getScrollHeight()+'px';
alert(Window.getScrollHeight()+'px');
alert('1');
		this.overlay.style.top = '0px';
		this.overlay.style.height = Window.getScrollHeight()+'px';
	},

	setup: function(open) {
		var elements = $A($$('object'));
		elements.extend($$(window.ActiveXObject ? 'select' : 'embed'));
		elements.each(function(el){ el.style.visibility = open ? 'hidden' : ''; });
//		var fn = open ? 'addEvent' : 'removeEvent';
//		window[fn]('scroll', this.eventPosition);
//		window[fn]('resize', this.eventPosition);
		//AddEvent( window, 'scroll', this.eventPosition, false );
		//AddEvent( window, 'resize', this.eventPosition, false );
		this.step = 0;
		return;
	},
	
	nextEffect: function() {
		switch(this.step++) {
		case 1:
			// remove previous styling from the elements
			// (e.g. styling applied in case of an error)
//			this.center.className = '';
			this.center.setStyle('cursor', 'default');
			this.bottom.setStyle('cursor', 'default');
			this.caption.setStyle('cursor', 'default');
			this.center.onclick = this.bottom.onclick = '';
			
			this.contents.setStyles ({width: this.options.contentsWidth + "px", height: this.options.contentsHeight + "px"});

			if(this.center.clientHeight != this.contents.offsetHeight) {
				this.fx.resize.custom({height: [this.center.clientHeight, this.contents.offsetHeight]});
				break;
			}
			this.step++;
					
		case 2:
			if(this.center.clientWidth != this.contents.offsetWidth) {
				this.fx.resize.custom({width: [this.center.clientWidth, this.contents.offsetWidth], marginLeft: [-this.center.clientWidth/2, -this.contents.offsetWidth/2]});
				break;
			}
			this.step++;
		
		case 3:
			this.bottom.setStyles({top: (this.top + this.center.clientHeight)-30+'px', width: this.options.contentsWidth + 'px', marginLeft: this.center.style.marginLeft, display: ''});
//			this.caption.setStyles({top: '20px', width: this.options.contentsWidth + 10 + 'px', marginLeft: this.center.style.marginLeft, display: ''});
			this.fx.contents.custom(0,1);
			break;
		
		case 4:
			this.bottom.setStyles({opacity: '1', height: this.bottom.scrollHeight+'px'});
			this.caption.setStyles({opacity: '1', height: '10px'});

		case 5:
			this.step = 0;
		}
	},
	
	close: function() {
		//alert('c1');
		if ( !this.ajax )
		{
			if(this.step < 0) return;
			this.step = -1;
			for(var f in this.fx) this.fx[f].clearTimer();
		}
		//alert('c2');
		
		this.center.style.display = this.bottom.style.display = this.caption.style.display = 'none';
//		this.center.className = 'mb_loading';
		this.fx.overlay.chain(this.setup.pass(false, this)).custom(0);
		//alert('c3');
		if ( bd.browser=="Explorer")
		{
			var elements = document.getElementsByTagName ( 'SELECT' );
			for ( var i = 0; i < elements.length; i++ )
				try{elements.style.display='';}catch(z){}
		}

		//
		try
		{
		if ( this.options.errorWindow == true ) this.options.root.ajaxLayer.close();
		}
		catch(z)
		{
		}
		return false;
	}
		
};
}
//
var noticeWindow = nw( );
var noticeWindow_content = nw( );
var noticeWindow_ical = nw( );
var noticeWindow_ajax = nw( );
//
/*
var noticeWindow_ajax = {
open:function(){},
showOverlay:function(){},
close:function(){}
};

//ajaxLayer = noticeWindow_ajax;
//
function initNoticeWindow( )
{
	noticeWindow_content.init({root:this});
	noticeWindow_ical.init({root:this});
	noticeWindow_ajax.init({root:this,ajax:true});
	noticeWindow.init({root:this,errorWindow:true});
}
*/
//