<!--##
<NAME>Maintenance Mode</NAME>
<DESC></DESC>
<SECTION>Pages</SECTION>
##-->
<inp2:m_NoDebug/>

<inp2:m_DefineElement name="add_to_head">
	<meta name="robots" content="noindex, nofollow">
	<meta http-equiv="refresh" content="120; url=<inp2:m_if check='m_Get' name='next_template'><inp2:m_Get name='next_template'/><inp2:m_else/><inp2:m_Link template='index' m_cat_id='0'/></inp2:m_if>">

	<script type="text/javascript">
		var a_parent = window.parent,
			to_close = new Array (),
			$modal_windows = <inp2:m_if check="adm_UsePopups" mode="modal">true<inp2:m_else/>false</inp2:m_if>;

		function getFrame($name) {
			var $main_window = window;

			// 1. cycle through popups to get main window
			try {
				// will be error, when other site is opened in parent window
				var $i = 0;
				var $opener;

				do {
					if ( $i == 10 ) {
						break;
					}

					// get popup opener
					$opener = $main_window.opener;

					if ( !$opener ) {
						// when no opener found, then try parent window
						$opener = $main_window.parent;
					}

					if ( $opener ) {
						$main_window = $opener;
					}

					$i++;
				} while ($opener);
			}
			catch (err) {
				// catch Access/Permission Denied error
				return window;
			}

			var $frameset = $main_window.parent.frames;
			for ($i = 0; $i < $frameset.length; $i++) {
				if ( $frameset[$i].name == $name ) {
					return $frameset[$i];
				}
			}

			return $main_window.parent;
		}

		function getWindowOpener($window) {
			// use this instead of "window.opener"
			if ( !$modal_windows ) {
				return $window.opener;
			}

			if ( $window.name == 'main' || $window.name == 'main_frame' ) {
				return null;
			}

			return getFrame('main').TB.findWindow($window.name, -1);
		}

		function redirect() {
			var $main_frame = getFrame('main');
			a_parent = window;

			try {
				var i = 0;
				while (i < 10) {
					i++;
					var $opener = $main_frame.getWindowOpener(a_parent);

					if ( $opener ) {
						to_close.push(a_parent);
						a_parent = $opener;
						continue;
					}

					if ( a_parent.name == 'main_frame' ) {
						break;
					}

					if ( a_parent.parent && a_parent.parent.name != a_parent.name ) {
						a_parent = a_parent.parent;
						continue;
					}
				}
			}
			catch (err) {
				// another website is opened in parent window
				alert('Error while trying to access window opener: [' + err.message + ']');
				i = 10;
			}

			if ( i < 10 ) {
				setTimeout(close_windows, 100);
			}
		}

		function window_close($close_callback) {
			// use this instead of "window.close();"
			if ( !$modal_windows ) {
				if ( $.isFunction($close_callback) ) {
					// use close callback, because iframe will be removed later in this method
					$close_callback();
				}

				window.close();
				return;
			}

			if ( window.name == 'main' ) {
				return;
			}

			if ( $close_callback !== undefined ) {
				return getFrame('main').TB.remove(null, $close_callback);
			}

			return getFrame('main').TB.remove();
		}

		function close_windows() {
			page = '<inp2:m_Link template="login" js_escape="1" no_amp="1" index_file="admin/index.php" __NO_REWRITE__="1" m_cat_id="0" m_wid=""/>';
			a_parent.location.href = page;

			for (var c = (to_close.length - 1); c >= 0; c--) {
				window_close(to_close[c]);
			}
		}

		if ( window.top.frames.length > 0 ) {
			redirect();
		}
	</script>
</inp2:m_DefineElement>

<!--## DEFINE MAIN CONTENT ELEMENT ##-->
<inp2:m_DefineElement name="content">

	<inp2:m_RenderElement design="content_box">
		<inp2:m_Capture to_var="header">
			<inp2:st_PageInfo type="title"/>
		</inp2:m_Capture>

		<inp2:m_GetConfig name="MaintenanceMessageFront"/>
	</inp2:m_RenderElement>

</inp2:m_DefineElement>
<!--## /DEFINE MAIN CONTENT ELEMENT ##-->

<inp2:m_include template="designs/default_design.des" page_class="inner"/>
