// This code has been created by Arash Motamedi, motamedi_arash@yahoo.com
// Used for smooth scrolling the window to a destination point.
// Call the SetStartPoint function at body onload if your page is beeing scrolled before it's smooth scrolled by Move function.

var StartPoint = 0
var Timer
var Direction = 0 // Horizontal Move
var EndPoint = 0
var t
var FadeOut
var FadeIn

function SetStartPoint(LoadStartPoint) {
	StartPoint = LoadStartPoint
	Direction = 1 // Vertical Move
	}

function Move(Destination, Out, In) {
	EndPoint = Destination
	FadeOut = Out
	FadeIn = In
	t = 0
	Timer = window.setInterval('ScrollScreen()', 10)
	}

function ScrollScreen() {

	if (Direction == 0) {
		window.scrollTo(0, StartPoint + (EndPoint - StartPoint) * Math.sin(Math.PI * t / 180))
	} else {
		window.scrollTo(StartPoint + (EndPoint - StartPoint) * Math.sin(Math.PI * t / 180))
	}
	
	FadeOut.style.filter = "alpha(opacity=" + (100 - (t * 20/9)) + ")"
	FadeIn.style.filter = "alpha(opacity=" + (t * 10/9) + ")"

	t = t + 1.5
	if (t==90) {
		window.clearInterval(Timer)
		StartPoint = EndPoint
		FadeOut.style.filter = "alpha(opacity=0)"
		FadeIn.style.filter = "alpha(opacity=100)"
		if (Direction == 0) {
			window.scrollTo(0, EndPoint)
		} else {
			window.scrollTo(EndPoint)
		}
		}
	}