/*--------------------------------------------------------------------------
 *  Smooth Scroller Script, version 1.0.1
 *  (c) 2007 Dezinerfolio Inc. <midart@gmail.com>
 *
 *  For details, please check the website : http://dezinerfolio.com/
 *
/*--------------------------------------------------------------------------*/

Scroller = {
	// control the speed of the scroller.
	// dont change it here directly, please use Scroller.speed=50;
	speed:10,

	// returns the Y position of the div
	gy: function (d) {
		gy = d.offsetTop
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},

	// returns the current scroll position
	scrollTop: function (){
		body=document.body
	    d=document.documentElement
	    if (body && body.scrollTop) return body.scrollTop
	    if (d && d.scrollTop) return d.scrollTop
	    if (window.pageYOffset) return window.pageYOffset
	    return 0
	},

	// attach an event for an element
	// (element, type, function)
	add: function(event, body, d) {
	    if (event.addEventListener) return event.addEventListener(body, d,false)
	    if (event.attachEvent) return event.attachEvent('on'+body, d)
	},

	// kill an event of an element
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true
			window.event.returnValue = false
      		return;
    	}
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault()
	      e.stopPropagation()
	    }
	},
	
	// move the scroll bar to the particular div.
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop()
		if(d>a)
			if(h-d>i)
				a+=Math.ceil((d-a)/Scroller.speed)
			else
				a+=Math.ceil((d-a-(h-d))/Scroller.speed)
		else
			a = a+(d-a)/Scroller.speed;
		window.scrollTo(0,a)
	  	if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval)
	  	Scroller.offsetTop=a
	},
	// initializer that adds the renderer to the onload function of the window
	init: function(){
		Scroller.add(window,'load', Scroller.render)
	},

	// this method extracts all the anchors and validates then as # and attaches the events.
	render: function(){
		a = document.getElementsByTagName('a');
		Scroller.end(this);
		window.onscroll
	    for (i=0;i<a.length;i++) {
	      l = a[i];
	      if(l.href && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){
	      	Scroller.add(l,'click',Scroller.end)
	      		l.onclick = function(){
	      			Scroller.end(this);
		        	l=this.hash.substr(1);
		        	 a = document.getElementsByTagName('a');
				     for (i=0;i<a.length;i++) {
				     	if(a[i].name == l){
				     		clearInterval(Scroller.interval);
				     		Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a[i])+')',10);
						}
					}
				}
	      	}
		}
	}
}

///////////////////////////////////////////////////////////////////////////////////////

bAgent = navigator.userAgent;
bName = navigator.appName;
bPlugins = navigator.plugins;

w = window;
s = w.screen;
d = document;

usrUrl = location.href;

function sniffer(){
/* OS */
	this.Win = bAgent.indexOf("Win",0) != -1 ? 1 : 0;
	this.WinVista = bAgent.indexOf("Windows NT 6.0",0) != -1 ? 1 : 0;
	this.Mac = bAgent.indexOf("Mac",0) != -1 ? 1 : 0;
	this.MacOSX = ((bAgent.indexOf("Mozilla") != -1) && (bAgent.indexOf("Mac OS X") != -1)) ? 1 : 0;
	if(bPlugins){for(i = 0 ;i < bPlugins.length;i++){if(this.Mac && (bPlugins[i].filename.indexOf("QuickTime Plugin.plugin") != -1)){this.MacOSX = true;}}}

/* Browser */
	this.IE        = ((bAgent.indexOf("MSIE") != -1) && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.NS        = ((bName == "Netscape") && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.NC        = ((bName == "Netscape") && (bAgent.indexOf("Gecko") == -1) && (bAgent.indexOf("Opera") == -1)) ? 1 : 0;
	this.Gecko     = (bAgent.indexOf("Gecko") != -1) ? 1 : 0;
	this.Moz       = ((bAgent.indexOf("Gecko") != -1) && (bAgent.indexOf("Safari",0) == -1)) ? 1 : 0;
	this.OPERA     = bAgent.indexOf("Opera",0) != -1 ? 1 : 0;
	this.Firefox   = (bAgent.indexOf("Firefox") != -1) ? 1 : 0;
	this.SAFARI    = bAgent.indexOf("Safari",0) != -1 ? 1 : 0;
	this.ICAB      = bAgent.indexOf("iCab",0) != -1 ? 1 : 0;

/* Object */
/* SAFARI,Firefox,NS6+,OPERA6=4, IE5+,OPERA5,7+=3, IE4=2, NS4=1, others=0 */
	this.checkObj      = d.all ? (d.getElementById ? 3 : 2) : (d.getElementById ? 4 : (d.layers ? 1 : 0));
	this.checkObj4     = (d.getElementById && !d.all) ? 1 : 0;
	this.checkObj3     = (d.getElementById && d.all) ? 1 : 0;
	this.checkObj2     = (d.all && !d.getElementById) ? 1 : 0;
	this.checkObj1     = d.layers ? 1 : 0;
	this.allObj        = ((this.checkObj == 3) || (this.checkObj == 4));

/* Compat Mode */
	this.modeStandard  = d.compatMode == "CSS1Compat" ? 1 : 0;
	this.modeQuirks    = d.compatMode == "BackCompat" ? 1 : 0;

/* Each Browser */
	this.IE5           = (this.Win && this.IE && (bAgent.indexOf('MSIE 5.',0) != -1));
	this.IE55          = (this.Win && this.IE && (bAgent.indexOf('MSIE 5.5.',0) != -1));
	this.IE55later     = (this.Win && this.IE && (w.createPopup != -1));
	this.IE6           = (this.Win && this.IE && (bAgent.indexOf('MSIE 6.',0) != -1));
	this.IE6below      = (this.IE5 && this.IE55 && this.IE6);
	this.IE7           = (this.Win && this.IE && (bAgent.indexOf('MSIE 7.',0) != -1));

	this.WinIEs        = (this.Win && this.IE && this.modeStandard);
	this.WinIEq        = (this.Win && this.IE && this.modeQuirks);

	this.MacFirefox    = (this.Mac && this.Firefox);
	this.MacOPERA      = (this.Mac && this.OPERA);

	return this;
}
var usr = new sniffer;

///////////////////////////////////////////////////////////////////////////////////////


// invoke the initializer of the scroller
if(!usr.OPERA){
	Scroller.init();
}

/*------------------------------------------------------------
 *						END OF CODE
/*-----------------------------------------------------------*/