// JavaScript Document

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");

		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_f."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_f.", "_n."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_n.", "_f."));
				}
			}
		}
	}
}

if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}



/*--------------------------------------------------------------------------
 *  Smooth Scroller Script
/*--------------------------------------------------------------------------*/

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) {
		var gy = d.offsetTop;
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},

	// returns the current scroll position
	scrollTop: function (){
		var body=document.body;
	    var 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){
		var i = window.innerHeight || document.documentElement.clientHeight;
		var h=document.body.scrollHeight;
		var 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(){
		var a = document.getElementsByTagName('a');
		var areas = document.getElementsByTagName('area');

		Scroller.end(this);
		window.onscroll;
		for (i=0;i<a.length;i++) {
			var l = a[i];
			if(l.href && l.href.indexOf('#') != -1){
				if((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');
						var element = document.getElementById(l);
						var target = null;
						var implemented = false;

						if(element){
							target = element;
							target.name = l;
							implemented = true;
						}

						if(!implemented){
							for(i=0; i<a.length; i++){
								if(a[i].name == l){
									target = a[i];
									break;
								}
							}
						}

						if(target){
							clearInterval(Scroller.interval);
							Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(target)+')',10);
						}
					}
				}
			}
		}

		for (i=0;i<areas.length;i++) {
			var l = areas[i];
			if(l.href && l.href.indexOf('#') != -1){
				if((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);

						var element = document.getElementById(l);
						var target = null;
						var implemented = false;

						if(element){
							target = element;
							target.name = l;
							implemented = true;
						}

						if(!implemented){
							for(i=0; i<areas.length; i++){
								if(areas[i].name == l){
									target = areas[i];
									break;
								}
							}
						}

						if(target){
							clearInterval(Scroller.interval);
							Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(target)+')',10);
						}
					}
				}
			}
		}
	}
}
// invoke the initializer of the scroller
Scroller.init();


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