<inp2:m_NoDebug/>
<inp2:m_Set skip_last_template="1"/>
<inp2:lang.current_Field name="Charset" result_to_var="charset"/>
<inp2:m_Header data="Content-type: text/html; charset=$charset"/>
<html>
	<head>
		<title></title>
		<script type="text/javascript">
			var $is_debug = <inp2:m_if check="m_ConstOn" name="DBG_REDIRECT">true<inp2:m_else/>false</inp2:m_if>;
			var $use_popups = <inp2:m_if check="adm_UsePopups">true<inp2:m_else/>false</inp2:m_if>;
			var $redirect_url = '<inp2:m_t t="dummy" opener="u" m_opener="u" escape="escape"/>';
			var $modal_windows = <inp2:m_if check="adm_UsePopups" mode="modal">true<inp2:m_else/>false</inp2:m_if>;

			if ($is_debug) {
				document.write('<a href="#" onclick="proceed_redirect()">' + $redirect_url.replace('%5C', '\\') + '</a>');
			}
			else {
				proceed_redirect();
			}

			function isset(variable)
			{
				if(variable == null) return false;
				return (typeof(variable) == 'undefined') ? false : true;
			}

			function proceed_redirect() {
				var $opener = getFrame('main').getWindowOpener(window);

				if ($opener) {
					// using popups & close_popup called (from anywhere)
					try {
						window_close(
							function() {
								$opener.onAfterWindowClose($redirect_url, <inp2:m_if check="adm_OpenNewWindow" diff="1">true<inp2:m_else/>false</inp2:m_if>, <inp2:m_if check="m_Get" name="skip_refresh">true<inp2:m_else/>false</inp2:m_if>);
							}
						);
					}
					catch (err) {
						// another website is opened in parent window
						alert('Error while trying to process redirect in window opener, you should probably close this window.' + "\n" + 'Error message: [' + err.message + ']');
					}
				}
				else if (!$use_popups) {
					// not using popups (for editing), but close_popup called (e.g. from selector)
					window.location.href = $redirect_url.replace('%5C', '\\');
				}
			}

			// copied from "js/script.js" because it's not included here due performance reasons
			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;
					while ($main_window.opener) {
						if ($i == 10) {
							break;
						}

						$main_window = $main_window.opener;
						$i++;
					}
				}
				catch (err) {
					// catch Access/Permission Denied error
			//			alert('getFrame.Error: [' + err.description + ']');
					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;
			}

			// copied locally, because won't work, when called via getFrame('main').window_close(...);
			function window_close($close_callback) {
				// use this instead of "window.close();"
				if (!$modal_windows) {
					// don't use other (e.g. parent) window methods to detect type of
					// variables from given window, because it won't work in IE

					if (Object.prototype.toString.call($close_callback) === '[object Function]') {
						// 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();
			}
		</script>
	</head>
	<body>
	</body>
</html>