/* nav.js should be included on every page after browserdetect_lite.js and before common.js */

//*******************************************************
// FUNCTION slideRight()
//*******************************************************
// slideRight() moves a navigation to it's end position 
//
// arguments: 
// nav - the name of the object (created by navItem) to be moved
//*******************************************************
    function slideRight(nav) {
	if (nav.xpos < nav.end) {
		if (nav.end-nav.xpos < nav.xinc){
		    //stop increments, move immediately to end
		    nav.xpos = nav.end;
		    nav.obj.left = nav.xpos;
		    activateNav(nav);
		}
		else {
		    //move to right by set increment
		    nav.xpos += nav.xinc;
		    nav.obj.left = nav.xpos;
		    if (browser.isMac){
			//accelerate increment
		        if ((nav.end-nav.xpos) > ((nav.end-nav.start)/2)) nav.xinc += 2;
			//decelerate increment
		        else if (nav.xinc>10) nav.xinc-=3;
		    }
		    else {
			//accelerate increment
		        if ((nav.end-nav.xpos) > (2*(nav.end-nav.start)/5)) nav.xinc+=2;
			//decelerate increment
		        else if (nav.xinc>5) nav.xinc-=3;
		    }
		    setTimeout("slideRight("+nav.name+")",30);
		}
	}
	else activateNav(nav)
    }


//*******************************************************
// FUNCTION slideLeft()
//*******************************************************
// slideLeft() moves a navigation to it's start position 
//
// arguments: 
// nav - the name of the object (created by navItem) to be moved
//*******************************************************
    function slideLeft(nav) {
	if (nav.xpos > nav.start) {
		if (nav.xpos-nav.start < nav.xinc){
		    //stop increments, move immediately to start
		    nav.xpos = nav.start;
		    nav.obj.left = nav.xpos;
		    activateNav(nav);
		}
		else {
		    //move to left by set increment
		    nav.xpos -= nav.xinc;
		    nav.obj.left = nav.xpos;
		    if (browser.isMac){
			//accelerate increment
		        if ((nav.end-nav.xpos) < ((nav.end-nav.start)/2)) nav.xinc += 2;
			//decelerate increment
		        else if (nav.xinc>10) nav.xinc-=3;
		    }
		    else {
			//accelerate increment
		        if ((nav.end-nav.xpos) < (3*(nav.end-nav.start)/5)) nav.xinc+=2;
			//decelerate increment
		        else if (nav.xinc>5) nav.xinc-=3;
		    }
		    setTimeout("slideLeft("+nav.name+")",30);
		}
	}
	else activateNav(nav)
    }


//*******************************************************
// FUNCTION activateNav()
//*******************************************************
// activateNav() redirects the user to a new page if the navigation has been activated
//
// arguments: 
// nav - the name of the object (created by navItem) to be activated
//*******************************************************
    function activateNav(nav){if (nav.activated) setTimeout("window.location='"+nav.url+"'",250);}


//*******************************************************
// FUNCTION navItem()
//*******************************************************
// navItem() creates a sliding navigation object
//
// arguments: 
// name - the id of the div containing the navigation AND the name of the JavaScript variable
// start - the left-most position of the navigation
// end - the right-most position of the navigation
// url - the url the navigation links to
//*******************************************************
    function navItem(name,start,end,url){

	if (document.getElementById) this.obj = document.getElementById(name).style;
	else if (document.all) this.obj = document.all[name].style;
	else if (document.layers) this.obj = document.layers[name];
	
	if (this.obj) this.xpos = parseInt(this.obj.left);

	if (browser.isMac && !(browser.isSafari)) this.xinc = 10;
	else this.xinc = 5;

	this.name = name;
	this.start = start;
	this.end = end;
	this.url = url;
	this.activated = false;
    }