setNavState = function(navIndex) {
	if (typeof(navIndex)=="undefined") return;
	var leftNav = document.getElementById("leftNav");
	if (leftNav) {
		var links = leftNav.getElementsByTagName("a");
		if (typeof(links[navIndex])!="undefined") links[navIndex].className += " current";
	}
};


animation = function() {
	this.step = 1;
	this.timeoutid = null;
	this.growtarget = 0;
	this.direction = 1;
	this.element = null;
	this.open = false;
	this.current = null;
};
	animation.prototype.getElemHeight = function() {
		this.element.style.visibility = "hidden";
		this.element.style.position = "absolute";
		this.element.style.display = "block";
		this.growtarget = this.element.offsetHeight;
		this.element.style.display = "none";
		this.element.style.visibility = "visible";
		this.element.style.position = "relative";
	}
	animation.prototype.animateElem = function(id) {
		this.element = document.getElementById(id);
		if (this.open) this.startShrink();
		else this.startGrow();
	};
	animation.prototype.showShippingOption = function(num) {
		if (num==this.current) return; 
		if (num<1 | this.open && this.element) { this.startShrink(num); return; }
		document.getElementById('shipMethod_1').style.display='none';
		document.getElementById('shipMethod_2').style.display='none';
		this.startGrow(num);		
	};
	animation.prototype.startGrow = function(num) {
		if (typeof(num)!='undefined') { //Using for the shipping animation - methods pass the number of the DIV
			this.current = num;
			if (num<1) return;
			//Reset the real field value
			if (num==1) swapShipVal("", false);
			if (num==2) swapShipVal(document.forms.basketForm.elements.ShippingAcctNum.value, false);
			if (num==3) swapShipVal(document.forms.basketForm.elements.phoneTemp.value, true);
			this.element = document.getElementById(("shipMethod_"+num));
		}
		this.step = 1; 
		this.direction = 1; 
		this.getElemHeight();
		var self = this;
		var tmp = function() { self.growShrink(num); }
		this.timeoutid = setTimeout(function(self) { tmp(); }, 20, self);
	};
	animation.prototype.startShrink = function(num) {
		if (!this.element) return;
		this.step = 1; 
		this.direction = -1; 
		var self = this;
		var tmp = function() { self.growShrink(num); }
		this.timeoutid = setTimeout(function(self) { tmp(); }, 20, self);
	};
	animation.prototype.growShrink = function(num) {
		this.element.style.overflow = "hidden";
		var h = (this.direction==1) ? (this.growtarget/10*this.step) : (this.growtarget-(this.growtarget/10)*this.step);
		this.element.style.height = h+"px";
		this.element.style.display = "block";
		this.step++;
		var self = this;
		var tmp = function() { self.growShrink(num); }
		if (this.step<=10) this.timeoutid = setTimeout(function(self) { tmp(); }, 20, self);
		else this.finish(num);
	};
	animation.prototype.finish = function(num) {
		if (this.direction==1) {
			this.open = true;
			this.element.style.height = this.growtarget+"px";
		} else {
			this.open = false;
			this.element.style.display = "none";
			this.element.style.height = "auto";
			if (typeof(num)!="undefined") { //Using for the shipping animation - methods pass the number of the DIV
				var self = this;
				var tmp = function() { self.startGrow(num); }
				this.timeoutid = setTimeout(function(self) { tmp(); }, 20, self);
			}
		}
	};
	
var animation1 = null;
try { animation1 = new animation(); } catch(e) {};
showShippingOption = function(num) {
	if (animation1) {
		try { animation1.showShippingOption(num); } catch(e) {};
	}
};
animateElem = function(id) {
	if (animation1) {
		try { animation1.animateElem(id); } catch(e) {};
	}
}

swapShipVal = function(val, isCallMe) {
	v = (isCallMe & val!="") ? "Call: "+val : val;
	document.forms.basketForm.elements.ShippingAcctNum.value=v;
}


