
var eventflag =0;

	var _IE  = (navigator.appName.toUpperCase().indexOf('MICROSOFT')!=-1);
	var timeId;
	var bodyp;
	
	
function intval(v) 
{ 
    v = parseInt(v); 
    return isNaN(v) ? 0 : v; 
} 

// 获取元素信息 
function getPos(e) 
{ 
    var l = 0; 
    var t  = 0; 
    var w = intval(e.style.width); 
    var h = intval(e.style.height); 
    var wb = e.offsetWidth; 
    var hb = e.offsetHeight; 
    while (e.offsetParent){ 
        l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0); 
        t += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0); 
        e = e.offsetParent; 
    } 
    l += e.offsetLeft + (e.currentStyle?intval(e.currentStyle.borderLeftWidth):0); 
    t  += e.offsetTop  + (e.currentStyle?intval(e.currentStyle.borderTopWidth):0); 
    return {x:l, y:t, w:w, h:h, wb:wb, hb:hb}; 
} 

// 获取滚动条信息 
function getScroll()  
{ 
    var t, l, w, h; 
     
    if (document.documentElement && document.documentElement.scrollTop) { 
        t = document.documentElement.scrollTop; 
        l = document.documentElement.scrollLeft; 
        w = document.documentElement.scrollWidth; 
        h = document.documentElement.scrollHeight; 
    } else if (document.body) { 
        t = document.body.scrollTop; 
        l = document.body.scrollLeft; 
        w = document.body.scrollWidth; 
        h = document.body.scrollHeight; 
    } 
    return { t: t, l: l, w: w, h: h }; 
} 

// 锚点(Anchor)间平滑跳转 
function scroller(el, duration) 
{ 
    if(typeof el != 'object') { el = document.getElementById(el); } 

    if(!el) return; 

    var z = this; 
    z.el = el; 
    z.p = getPos(el); 
    z.s = getScroll(); 
    z.clear = function(){window.clearInterval(z.timer);z.timer=null}; 
    z.t=(new Date).getTime(); 

    z.step = function(){ 
        var t = (new Date).getTime(); 
        var p = (t - z.t) / duration; 
        if (t >= duration + z.t) { 
            z.clear(); 
            window.setTimeout(function(){z.scroll(z.p.y, z.p.x)},13); 
        } else { 
            st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t; 
            sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l; 
            z.scroll(st, sl); 
        } 
    }; 
    z.scroll = function (t, l){window.scrollTo(l, t)}; 
    z.timer = window.setInterval(function(){z.step();},13); 
} 

//平滑移动到某个锚点处	by TRS
	function test(evt){
		clearTimeout(timeId);
		if (evt.wheelDelta > 0) {
		 bodyp = $(document.body).offset();
			timeId = setTimeout(function(){
				
				var position_2 = $("#anchor22").offset();
				var position_3 = $("#anchor33").offset();
				var position_4 = $("#anchor44").offset();
				var position_5 = $("#anchor55").offset();
				var position_6 = $("#anchor66").offset();
				var position_7 = $("#anchor77").offset();
		/*alert(bodyp.top);
 		   alert(position_2.top);
			 alert(position_3.top);
			 alert(position_4.top);
			 alert(position_5.top);
			 alert(position_6.top);
			 alert(position_7.top);*/
			 if(bodyp.top<position_2.top||bodyp.top==position_7.top||bodyp.top==position_6.top||bodyp.top==position_5.top||bodyp.top==position_4.top||bodyp.top==position_3.top||bodyp.top==position_2.top) {
										// scroller('anchor1', 800);
										scroller('anchor00', 0);
											//alert("第0版");
									}
			 else
			   if(bodyp.top<position_2.top||bodyp.top==position_7.top-2||bodyp.top==position_6.top-2||bodyp.top==position_5.top-2||bodyp.top==position_4.top-2||bodyp.top==position_3.top-2||bodyp.top==position_2.top-2) {
										// scroller('anchor1', 800);
										scroller('anchor00', 0);
											//alert("第0版");
									}
			 else
				if (bodyp.top > position_2.top && bodyp.top < position_3.top) {
					scroller('anchor22', 0);
					//alert("第1版");
				}
				else 
					if (bodyp.top > position_3.top && bodyp.top < position_4.top) {
						scroller('anchor33', 0);
							//alert("第2版");
					}
					else 
						if (bodyp.top > position_4.top && bodyp.top < position_5.top) {
							scroller('anchor44', 0);
								//alert("第3版");
						}
						else 
							if (bodyp.top > position_5.top && bodyp.top < position_6.top) {
								scroller('anchor55', 0);
									//alert("第4版");
							}
							else 
								if (bodyp.top > position_6.top && bodyp.top < position_7.top) {
									scroller('anchor66', 0);
										//alert("第4版");
								}
								else 
									if (bodyp.top > position_7.top) {
										scroller('anchor77', 0);
											//alert("第5版");
									}
									else if(bodyp.top<position_2.top||bodyp.top==position_7.top||bodyp.top==position_6.top||bodyp.top==position_5.top||bodyp.top==position_4.top||bodyp.top==position_3.top||bodyp.top==position_2.top) {
										// scroller('anchor1', 800);
										scroller('anchor00', 0);
											//alert("第0版");
									}
				
				
			}, 500);
			
		}
		
		
		
	}
