﻿var fgm = {
	shit: !-[1,] && !window.XMLHttpRequest,	
	scrollTop: function() {
		return document.documentElement.scrollTop || document.body.scrollTop;
	},
	currentStyle: function(obj, attr) {
		return parseInt(obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr]);
	},
	fixed: function(element) {
		if(this.shit) {
			var top = this.currentStyle(element, "top") || 0,
			dd = "(document.documentElement)";
			document.documentElement.style.textOverflow = "ellipsis";
			element.style.position = "absolute";
			element.style.setExpression("top", "eval(" + dd + ".scrollTop + " + (top - this.scrollTop()) + ') + "px"');
		}
		else {
			element.style.position = "fixed";	
		}
	},
	doMove: function(obj, iTarget, callback) {
		clearInterval(obj.timer);
		obj.timer = setInterval(function() {
			var iCur = fgm.currentStyle(obj, "height"),
			iSpeed = (iTarget - iCur) / 5;
			iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
			iTarget == iCur ? (clearInterval(obj.timer), callback && callback.call(obj)) : obj.style.height = iSpeed + iCur + "px";
		}, 30);		
	}
};
window.onload = function() {
	var oWrap = document.getElementById("wrap"),
	oTopBar = document.getElementById("topBar"),
	oTopBar1 = document.getElementById("topBar1"),
	oNav = document.getElementById("nav"),
	oNav1 = document.getElementById("nav1"),
	ozxdh = document.getElementById("zxdh"),
	fnStatus = function(status) {
		!!status ?
		(function() {
//		    oWrap.className="wrap2";
			ozxdh.style.display="block";
			oNav.className = "hide";
			fgm.doMove(oTopBar, 0);
			fgm.doMove(oTopBar1, 0);
			fgm.doMove(oNav,45, function() {
				oNav.style.background="url('/images/navbg.jpg') repeat-x scroll 28px 0 #f2f2f2";
			});
			fgm.doMove(oNav1,45, function() {
				oNav1.style.background="url('/images/navbg.jpg') repeat-x scroll 28px 0 #f2f2f2";
			});
		})() :
		(function() {
//		    oWrap.className="wrap";
			ozxdh.style.display="none";
			fgm.doMove(oTopBar, 28);
			fgm.doMove(oTopBar1, 28);
			fgm.doMove(oNav, 65, function() {
				this.className = ""	;
				oNav.style.background="url('/images/wrapnavbg.jpg') repeat-x scroll 28px 0 #f2f2f2";
			})
			fgm.doMove(oNav1, 65, function() {
				//this.className = ""	;
				oNav1.style.background="url('/images/wrapnavbg.jpg') repeat-x scroll 28px 0 #f2f2f2";
			})
		})();
	};	
	fgm.fixed(oWrap);//IE6 Fixed
	window.onscroll = function() {
		var iScrollTop = fgm.scrollTop();
		fnStatus(iScrollTop > 0);
		document.onmouseover = function(ev) {
			var oEv = ev || event,
			oTarget = oEv.target || oEv.srcElement,
			contains = function() {
				if(oWrap.contains) {
					return oWrap.contains(oTarget);	
				}
				else if(oWrap.compareDocumentPosition) {
					return !!(oWrap.compareDocumentPosition(oTarget) & 16);
				}
			}();
			//fnStatus(!contains && iScrollTop > 0);
		};
	};
	window.onscroll();
};


