var source_y, destination_y, t, dy, dt;		// scrolling variables
var showWhat = 0;							// switching variables
var goWhere = 0;							//
var query = window.location.search;			//
var subtract = 0;

// smaller dt = slower and smoother scroll

dt = 1/40;

// domain and range of this function must be [0,1]

function goto(x)
	{
	 var steepness = 2;
	 return 1 - Math.pow(0.5 + Math.sin(Math.PI*(0.5 - x))/2,steepness);
	}

function scroller()
	{
	 var y;

	 if(window.pageYOffset)
		{
		 y = window.pageYOffset;
		}
	 else
		{
		 y = document.documentElement.scrollTop;
		}

	 if( ((dy < 0 && y > destination_y) || (dy > 0 && y < destination_y)) && t < 1.0)
		{
		 t+=dt;
		 window.scroll(0,source_y+dy*goto(t));
	    	 setTimeout('scroller()', 10);
		}
	 else
		{
		 if(subtract)
			{
			 hidediv('footer1', 1);
			 hidediv('footer2', 1);
			 subtract = 0;
			}
		 if(showWhat)
			{
			 select(showWhat);
			 showWhat = 0;
			}

		 if(goWhere)
			{
			 parent.location = goWhere;
			 goWhere = 0;
			}
		}
	}

function scrollTo(to)
	{
	 if(to == 'the_very_top')
		{
		 destination_y = 0;
		}
	 else
		{
		 to = document.getElementById(to);
		 destination_y = to.offsetTop;
		}
	 if(window.pageYOffset)
		{
		 source_y = window.pageYOffset;
		}
	 else
		{
		 source_y = document.documentElement.scrollTop;
		}

	 destination_y -= subtract;

	 dy = destination_y - source_y;
	 t = 0;
	 scroller();
	}

function scrollShow(to, tab)
	{
	 showWhat = tab;
	 scrollTo(to);
	}

function showScroll(to, tab)
	{
	 selectFooter(tab);
	 scrollTo(to);
	}

function scrollHide(to)
	{
	 subtract = document.documentElement.clientHeight;
	 scrollTo(to);
	}

function scrollSwitch(url)
	{
	 goWhere = url;
	 scrollTo('the_very_top');
	}

function scrollSwitchScroll(url, to)
	{
	 scrollSwitch(url+"?"+to);
	}

function scrollSwitchScrollShow(url,to,tab)
	{
	 scrollSwitch(url+"?"+to+":"+tab);
	}

document.documentElement.clientHeight
window.onload = function() 
	{
	 if (query.substring(0, 1) == '?')
		{
		 query = query.substring(1);
		}

	 if(query !== '')
		{
		 query = query.split(":",2);
		 if(!query[1])
			{
			 scrollTo(query);
			}
		 else
			{
			 scrollShow(query[0],query[1]);
			}
		}
	}