/**
 * The Scroll
 * @name thescroll.js
 * @author Kaoru Ishikura
 * @version v0.0.4
 * @date March 27, 2008
 * @category Library
 * @Copyright (C) 2008 SAKURA Creative Inc.
 */

(function(){ var theScroll = { settings: { speed: 20, increment: 2
}, ini: function() { var isAnchorTags = document.getElementsByTagName("a"); if (!isAnchorTags) { return;}
for (var i=0,len=isAnchorTags.length; i<len; i++) { var chkAnchorTag = isAnchorTags[i]; if (chkAnchorTag.href && chkAnchorTag.href.indexOf("#site") != -1 &&
(chkAnchorTag.pathname == location.pathname || "/" + chkAnchorTag.pathname == location.pathname)) { theScroll.addListener(chkAnchorTag, "click", theScroll.start);}
}
}, start: function(e) { if (e && e.preventDefault && e.stopPropagation) { e.preventDefault(); e.stopPropagation();} else if (window.event) { window.event.cancelBubble = true; window.event.returnValue = false;}
var isAnchorName = this.hash.substr(1); var isAnchorTags = document.getElementsByTagName('a'); var isScrollTo = document.getElementById(isAnchorName) || null; if (!isScrollTo) { for (var i=0,len=isAnchorTags.length; i<len; i++) { var temp = isAnchorTags[i]; if (temp.name && (temp.name == isAnchorName)) { isScrollTo = temp; break;}
}
}
if (!isScrollTo) { return;}
var isScrollPosition = theScroll.getScrollPosition(); theScroll.isSetInterval = setInterval(function() { theScroll.core(isScrollPosition);}, theScroll.settings.speed);}, core: function(sPosi) { sPosi[0] = Math.max(Math.floor(sPosi[0] / 2), 0); sPosi[1] = Math.max(Math.floor(sPosi[1] - (sPosi[1] / theScroll.settings.increment)), 0); window.scrollTo(sPosi[0], sPosi[1]); if (sPosi[0] <= 0 && sPosi[1] <= 0) { clearInterval(theScroll.isSetInterval); return;}
}, addListener: (function() { if (window.addEventListener) { return function (elem, type, func) { elem.addEventListener(type, func, false);};} else if (window.attachEvent) { return function (elem, type, func) { var fn = function() { func.call(elem, window.event);}; elem.attachEvent("on" + type, fn);};} else { return false;}
})(), getScrollPosition: function() { if (self.pageYOffset || self.pageXOffset) { return [ self.pageXOffset, self.pageYOffset ];} else if (document.documentElement &&
(document.documentElement.scrollTop || document.documentElement.scrollLeft)) { return [ document.documentElement.scrollLeft, document.documentElement.scrollTop ];} else if (document.body) { return [ document.body.scrollLeft, document.body.scrollTop ];}
}
}; theScroll.addListener(window, "load", theScroll.ini);})(); 