/**
 * @fileoverview 基础的页面模块
 * @author xukai.ken@gmail.com
 *
 */

define(function(require, exports, module) {

	_registerMap = new Hash({

		// 滚动事件监听列表
		'always-0' : function(hook) {
			var topBannerEl = $('navigator'), scrollTopEl = $('scrolltop'), headerEl = $('header');
			if (hook < 68) {
				topBannerEl.setStyle({
					'position' : 'static'
				});
				headerEl.setStyle({
					'height' : '70px'
				});
				scrollTopEl.hide();
			} else {
				topBannerEl.setStyle({
					'position' : 'fixed'
				});
				headerEl.setStyle({
					'height' : '102px'
				});
				scrollTopEl.show();
			}
		}
	});

	exports.init = function() {
		$('scrolltop').observe('click', function() {
			$(window).scrollTo(0);
		});

		// IE6不支持fixed属性
		if (Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5)) == 6) {
			$('scrolltop').remove();
			return;
		}

		// 设置头部吸顶
		Event.observe(window, 'scroll', function(evt) {
			var viewPort = document.viewport;
			var offsets = viewPort.getScrollOffsets();
			var yOffset = offsets[1];
			_registerMap.each(function(pair) {
				if (pair.key.indexOf('always') != -1)
					pair.value(yOffset);
				else if (yOffset == pair.key)
					pair.value(yOffset);
			});
		});
	};
});

@@ -922,25 +922,21 @@
 %0D%0A%09%09
-%09return;%0D%0A%09%09%7D%0D%0A%0D%0A
+%7D else %7B%0D%0A%0D%0A%09
 %09%09//
@@ -944,16 +944,17 @@
 %E8%AE%BE%E7%BD%AE%E5%A4%B4%E9%83%A8%E5%90%B8%E9%A1%B6%0D%0A
+%09
 %09%09Event.
@@ -995,24 +995,25 @@
 (evt) %7B%0D%0A%09%09%09
+%09
 var viewPort
@@ -1035,16 +1035,17 @@
 wport;%0D%0A
+%09
 %09%09%09var o
@@ -1082,24 +1082,25 @@
 sets();%0D%0A%09%09%09
+%09
 var yOffset 
@@ -1114,16 +1114,17 @@
 ts%5B1%5D;%0D%0A
+%09
 %09%09%09_regi
@@ -1150,24 +1150,25 @@
 on(pair) %7B%0D%0A
+%09
 %09%09%09%09if (pair
@@ -1195,32 +1195,33 @@
 ') != -1)%0D%0A%09%09%09%09%09
+%09
 pair.value(yOffs
@@ -1222,24 +1222,25 @@
 (yOffset);%0D%0A
+%09
 %09%09%09%09else if 
@@ -1262,16 +1262,17 @@
 r.key)%0D%0A
+%09
 %09%09%09%09%09pai
@@ -1293,21 +1293,173 @@
 t);%0D%0A%09%09%09
+%09
 %7D);%0D%0A
+%09%09%09%7D);%0D%0A%09%09%7D%0D%0A%0D%0A%09%09// %E5%A2%9E%E5%8A%A0%E5%AF%B9%E5%85%A8%E5%B1%80%E9%94%AE%E7%9B%98%E4%BA%8B%E4%BB%B6%E7%9A%84%E7%9B%91%E5%90%AC%0D%0A%09%09Event.observe(document, 'keydown', function(evt) %7B%0D%0A%09%09%09if (evt.keyCode == Event.KEY_ESC) %7B%0D%0A%09%09%09%09return;%09%09%09%09%0D%0A%09%09%09%7D%0D%0A
 %09%09%7D);%0D%0A%09

add the eexecution for esc key.