/* Using an external library to load JavaScript is much faster, because the file gets cached */

window.generalLibOnloadOld = window.onload ? window.onload : function(){};
window.onload = function() {
	
	window.w3c = document.getElementById("w3c");
	w3c.style.width = "100%";
	w3c.style.height = "100%";
	var winW = window.innerWidth ? window.innerWidth : ((document.documentElement&&document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth);
	var winH = window.innerHeight ? window.innerHeight : ((document.documentElement&&document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight);
	w3c.style.height = winH+"px";
	w3c.style.width = winW+"px";
	w3c.style.overflow = "auto";
	w3c.style.overflowY = "scroll";
	
	
	var links = document.getElementsByTagName("*");
	for(var x in links) {
		links[x]._isForumLink = false;
		if(links[x]) {
			var li = links[x];
			while(li.parentNode) {
				li = li.parentNode;
				if(li.className && li.className.substring(0,6)=="forum ")
					links[x]._isForumLink = true;
			}
		}
		// for button mouseover effects:
		//if(links[x] && links[x].className && (links[x].className.substring(0,7)=="button " || links[x].className.indexOf(" button ")!=-1 || links[x].className.substring(links[x].className.length-7,links[x].className.length)==" button" || links[x].className=="button")) {
		if(links[x] && HasClass(links[x],"button")==true && links[x]._isForumLink==false) {
			links[x].onmouseover = function(e){ AddClass(this,"buttonhover"); return window.NullFunction(e); };
			links[x].onmouseout = function(e){ StripClass(this,"buttonhover"); StripClass(this,"buttonpressed"); return window.NullFunction(e); };
			links[x].onmousedown = function(e){ AddClass(this,"buttonpressed"); return window.NullFunction(e); };
			links[x].onmouseup = function(e){ StripClass(this,"buttonpressed"); return window.NullFunction(e); };
			links[x].onselectstart = window.NullFunction;
			links[x].oncontextmenu = window.NullFunction;
		}
		// convert links to NetYellow's new "pop effect":
		if(links[x] && links[x].className && links[x].className.indexOf("opendialog")>-1 && links[x]._isForumLink==false) {
			links[x].onclick = function(e) {
				var w = null;
				var h = null;
				if(this.className.indexOf("dialogsize(")>-1) {
					var dims = this.className.substring(this.className.indexOf("dialogsize(")+11, this.className.indexOf(")", this.className.indexOf("dialogsize(")+10)).split(",");
					w = parseInt(dims[0]);
					h = parseInt(dims[1]);
				}
				OpenDialog(this.href, w, h);
				this.blur();
				if(!e) e=window.event;
				if(e.returnValue)
					e.returnValue = false;
				if(e.preventDefault)
					e.preventDefault();
				return false;
			};
		}
	}
	
	var inputs = document.getElementsByTagName("input");
	for(var x in inputs) {
		// disable all non-number characters:
		if(inputs[x] && inputs[x].className && (inputs[x].className.indexOf("input_numbersonly ")>-1 || inputs[x].className=="input_numbersonly")) {
			inputs[x].allowedChars = new Array(48,49,50,51,52,53,54,55,56,57, 96,97,98,99,100,101,102,103,104,105, 9,8,46, 37,38,39,40, 16,17,18,27);
			
			inputs[x].numbersonly_oldkeypress = inputs[x].onkeypress ? inputs[x].onkeypress : function(e){};
			inputs[x].numbersonly_oldkeydown = inputs[x].onkeydown ? inputs[x].onkeydown : function(e){};
			inputs[x].numbersonly_oldkeyup = inputs[x].onkeyup ? inputs[x].onkeyup : function(e){};
			
			inputs[x].numbersonly_checkkey = function(e) {
				if(!e) e=window.event;
				if( array_contains(this.allowedChars,(e.keyCode?e.keyCode:e.which))==true )
					return this.numbersonly_oldkeypress(e);
				this.numbersonly_oldkeypress(e)
				return window.NullFunction(e);
			};
			
			inputs[x].onkeypress = function(e) {
				if(!e) e=window.event;
				return this.numbersonly_checkkey(e);
			};
			inputs[x].onkeydown = function(e) {
				if(!e) e=window.event;
				return this.numbersonly_checkkey(e);
			};
			inputs[x].onkeyup = function(e) {
				if(!e) e=window.event;
				return this.numbersonly_checkkey(e);
			};
		}
		// limit characters if needed:
		if(inputs[x] && inputs[x].className && inputs[x].className.indexOf("input_limitchars(")>-1) {
			inputs[x].charLimit = parseInt(inputs[x].className.substring( inputs[x].className.indexOf("input_limitchars(")+17 , inputs[x].className.indexOf(")",inputs[x].className.indexOf("input_limitchars(")+17) ));
			inputs[x].nonCharKeys = new Array(9,8,46, 37,38,39,40, 16,17,18,27);
			inputs[x].charLimit_oldkeypress = inputs[x].onkeypress ? inputs[x].onkeypress : function(e){};
			inputs[x].onkeypress = function(e) {
				if(!e) e=window.event;
				if(this.value.length < this.charLimit || array_contains(this.nonCharKeys,this.lastKeyDown)==true)
					return this.charLimit_oldkeypress(e);
				else {
					this.charLimit_oldkeypress(e);
					return window.NullFunction(e);
				}
			};
			inputs[x].charLimit_oldkeydown = inputs[x].onkeydown ? inputs[x].onkeydown : function(e){};
			inputs[x].onkeydown = function(e) {
				if(!e) e=window.event;
				this.lastKeyDown = e.keyCode ? e.keyCode : e.which;
				if(this.value.length < this.charLimit || array_contains(this.nonCharKeys,this.lastKeyDown)==true)
					return this.charLimit_oldkeydown(e);
				else {
					this.value = this.value.substring(0,this.charLimit);
					this.charLimit_oldkeydown(e);
					return window.NullFunction(e);
				}
			};
			inputs[x].charLimit_oldkeyup = inputs[x].onkeyup ? inputs[x].onkeyup : function(e){};
			inputs[x].onkeyup = function(e) {
				if(!e) e=window.event;
				if(this.value.length < this.charLimit || array_contains(this.nonCharKeys,this.lastKeyDown)==true)
					return this.charLimit_oldkeyup(e);
				else {
					this.charLimit_oldkeyup(e);
					return window.NullFunction(e);
				}
			};
		}
		// phone number input fields:
		if(inputs[x] && inputs[x].className && HasClass(inputs[x],"input_dialer")==true) {
			inputs[x].allowedChars = new Array(48,49,50,51,52,53,54,55,56,57, 96,97,98,99,100,101,102,103,104,105, 9,8,46, 37,38,39,40, 16,17,18,27);
			
			inputs[x].dialer_checkkey = function(e) {
				if(!e) e=window.event;
				if( array_contains(this.allowedChars,(e.keyCode?e.keyCode:e.which))==true )
					return this.dialer_oldkeypress(e);
				this.dialer_oldkeypress(e);
				
				var allowed = new Array("0","1","2","3","4","5","6","7","8","9");
				
				var newvalue = "";
				for(var pos=0; pos<this.value.length; pos++)
					if(array_contains(allowed,this.value.substring(pos,pos+1))==true && pos<10)
						newvalue += this.value.substring(pos,pos+1);
				
				if(newvalue.length>=6)
					newvalue = newvalue.substring(0,3)+"-"+newvalue.substring(3,6)+"-"+newvalue.substring(6,9);
				else if(newvalue.length>=3)
					newvalue = newvalue.substring(0,3)+"-"+newvalue.substring(3,newvalue.length);
				this.value = newvalue;
				
				return window.NullFunction(e);
			};
			
			inputs[x].dialer_oldkeypress = inputs[x].onkeypress ? inputs[x].onkeypress : function(e){};
			inputs[x].dialer_oldkeydown = inputs[x].onkeydown ? inputs[x].onkeydown : function(e){};
			inputs[x].dialer_oldkeyup = inputs[x].onkeyup ? inputs[x].onkeyup : function(e){};
			inputs[x].dialer_oldblur = inputs[x].onblur ? inputs[x].onblur : function(e){};
			
			inputs[x].onkeypress = function(e) {
				if(!e) e=window.event;
				return this.dialer_checkkey(e);
			};
			inputs[x].onkeydown = function(e) {
				if(!e) e=window.event;
				return this.dialer_checkkey(e);
			};
			inputs[x].onkeyup = function(e) {
				if(!e) e=window.event;
				return this.dialer_checkkey(e);
			};
			inputs[x].onblur = function(e) {
				var numbers = new Array("0","1","2","3","4","5","6","7","8","9","-");
				var newval = "";
				for(var x=0; x<this.value.length; x++)
					if(array_contains(numbers,this.value.substring(x,x+1))==true)
						newval += this.value.substring(x,x+1);
				this.value = newval;
				return this.dialer_oldblur(e);
			};
		}
		
		// JSlide:
		if(inputs[x] && inputs[x].className && inputs[x].className.indexOf("JSlide(")>-1) {
			var baseInput = inputs[x];
			var params = baseInput.className.substring( baseInput.className.indexOf("JSlide(")+7 , baseInput.className.indexOf(")",baseInput.className.indexOf("JSlide(")+7) ).split(",");
			var min = parseInt(params[0]);
			var max = parseInt(params[1]);
			var myJSlide = new JSlide(baseInput,min,max);
		}
		
	}	// end "inputs" loop
	
	
	if(document.getElementById("ContentScroller_display")) {
		ContentScroller.init(document.getElementById("ContentScroller_display"));
	}
	
	// Execute the old "onload" function:
	window.generalLibOnloadOld();
};

window.generalLibOnResizeOld = window.onresize ? window.onresize : function(){};
window.onresize = function() {
	w3c.style.width = "100%";
	w3c.style.height = "100%";
	var winW = window.innerWidth ? window.innerWidth : ((document.documentElement&&document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.clientWidth);
	var winH = window.innerHeight ? window.innerHeight : ((document.documentElement&&document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.clientHeight);
	w3c.style.height = winH+"px";
	w3c.style.width = winW+"px";
	w3c.style.overflow = "auto";
	w3c.style.overflowY = "scroll";
	window.generalLibOnResizeOld();
};



window.onkeydown = function(e) {
	if(!e) e=window.event;
	var key = e.keyCode ? e.keyCode : e.which;
	if(key==27 && window.currentdialog && window.currentdialog.Close)		// esc
		window.currentdialog.Close();
};






window.NullFunction = function(e) {
	if(!e) e = window.event;
	if(e.preventBubble)
		e.preventBubble = true;
	if(e.returnValue)
		e.returnValue=false;
	if(e.StopPropagation)
		e.StopPropagation();
	if(e.preventDefault)
		e.preventDefault();
	return false;
};





array_contains = function(array,what) {
	for(var x=0; x<array.length; x++)
		if(array[x]==what)
			return true;
	return false;
};





// The following function is improper use of JavaScript:  (fix me)
function roll_over(img_name, img_src) {
	document[img_name].src = img_src;
}


function loginForm() {
	window.location.href = "http://www.netyellow.ca/members/";
}



// add/remove CSS classes quickly:
function AddClass(el,className) {
	var c = el.className;
	//if(c.indexOf(" "+className+" ")==-1 && c.indexOf(" "+className)!=c.length-className.length-1 && c.indexOf(className+" ")!=0 && c!=className)
	if(HasClass(el,className)==false)
		el.className += " "+className;
}


function StripClass(el,className) {
	var c = el.className;
	//if(c.indexOf(" "+className+" ")>-1 || c.indexOf(" "+className)==c.length-className.length-1 || c.indexOf(className+" ")==0 || c==className)
	if(HasClass(el,className)==true)
		el.className = c.substring(0,c.indexOf(" "+className)) + c.substring(c.indexOf(" "+className)+className.length+1, c.length);
}


function HasClass(el,className) {
	if(el && el.className && (el.className.substring(0,className.length+1)==className+" " || el.className.indexOf(" "+className+" ")!=-1 || el.className.substring(el.className.length-className.length-1,el.className.length)==" "+className || el.className==className))
		return true;
	return false;
}











window.currentdialog = null;
function OpenDialog(url, width, height) {
	if(window.currentdialog!=null)
		window.currentdialog.Close();
	
	window.currentdialog = function(){
		this.open = true;
		this.url = null;
	};
	window.currentdialog.url = url;
	
	var winW = window.innerWidth ? window.innerWidth : ((document.documentElement && document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.clientWidth);
	var winH = window.innerHeight ? window.innerHeight : ((document.documentElement && document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.clientHeight);
	
	var d = document.createElement("iframe");
	if(width==null || height==null) {
		d.style.top = "10%";
		d.style.left = "5%";
		d.style.width = "90%";
		d.style.height = "80%";
	}
	else {
		d.style.top = (winH-height)/2+"px";
		d.style.left = (winW-width)/2+"px";
		d.style.width = width+"px";
		d.style.height = height+"px";
	}
	d.className = "dialog";
	d.dialogClass = window.currentdialog;
	d.src = url;
	d.setAttribute("src",url);
	document.body.appendChild(d);
	//d.Close = function(){ window.currentdialog.Close(); };
	//d.contentWindow.Close = function(){ window.currentdialog.Close(); };
	window.currentdialog.displayArea = d;
	
	var f = document.createElement("div");
	f.className = "dialogFader";
	f.style.height = winH+"px";
	f.style.width = winW+"px";
	f.dialogClass = window.currentdialog;
	f.onmousedown = function(){ this.dialogClass.Close(); };
	document.body.appendChild(f);
	window.currentdialog.fader = f;
	
	var c = document.createElement("span");
	//c.style.cssText = "z-index:950; color:#FFFFFF; font-size:18px; font-weight:bold; cursor:pointer; position:absolute; top:"+(d.offsetTop-8)+"px; left:"+(d.offsetLeft+d.offsetWidth-12)+"px; margin:0px; padding:0px; padding-bottom:1px; padding-left:0.2em; padding-right:0.3em; background:#BB0000; border:1px outset #666666;";
	c.className = "dialogCloseButton";
	c.style.top = (d.offsetTop-8)+"px";
	c.style.left = (d.offsetLeft+d.offsetWidth-12)+"px";
	c.innerHTML = "&times;";
	c.dialogClass = window.currentdialog;
	c.onclick = function(){ this.blur(); this.dialogClass.Close(); };
	c.onmouseover = function(){ this.style.background="#FF1111"; };
	c.onmouseout = function(){ this.style.background="#BB0000"; };
	document.body.appendChild(c);
	window.currentdialog.closeButton = c;
	
	var c = document.createElement("div");
	//c.style.cssText = "z-index:850; color:#222222; text-indent:0.6em; font-size:12px; position:absolute; width:100%; top:0px; left:0px; margin:0px; padding-top:3px; padding-bottom:2px; background:#EEEEBB; border-bottom:1px solid #CCCC99;";
	c.className = "dialogInformation";
	c.innerHTML = "Please use the <span style=\"background:#BB0000; padding-left:0.3em; padding-right:0.3em; border:1px outset #666666; color:#FFFFFF; font-weight:bold;\">&times;</span> button <strong>below</strong> to close this window.";
	c.dialogClass = window.currentdialog;
	document.body.appendChild(c);
	window.currentdialog.dialogInformation = c;
	
	window.currentdialog.Close = function(){
		document.body.removeChild(this.displayArea);
		document.body.removeChild(this.closeButton);
		document.body.removeChild(this.dialogInformation);
		document.body.removeChild(this.fader);
		KillDialog();
	};
}
function KillDialog() {
	window.currentdialog = null;
}
















window.ContentScrollers = new Array();

function ContentScrollerClass(area, pauseDuration) {
	//this.pauseDuration = pauseDuration!=null ? pauseDuration : 5000;
	this.panels = new Array();
	this.menuitems = new Array();
}


ContentScrollerClass.prototype.init = function(area) {
	this.area = area;
	this.area.parentContentScroller = this;
	
	this.id = window.ContentScrollers.length;
	window.ContentScrollers[this.id] = this;
	
	var els = document.getElementsByTagName("div");
	for(var x in els) {
		if(els[x] && els[x].id && els[x].id.indexOf("ContentScroller_display_panel_")==0) {
			var element = els[x];
			element.parentContentScroller = this;
			element.panelID = element.id.substring(30,element.id.length);
			this.panels.push(element);
		}
	}
	
	this.panelCount = this.panels.length;
	this.currentpanel = this.panels[0];

	for(var x in this.panels) {
		var item = document.getElementById("ContentScroller_menuitem_"+this.panels[x].panelID);
		item.parentContentScroller = this;
		item.panelID = this.panels[x].panelID;
		item.onclick = function(e){ if(!e)e=window.event; this.parentContentScroller.SwitchTo(this.panelID); return this.parentContentScroller.NullFunction(e); };
		item.onmousedown = this.NullFunction;
		item.oncontextmenu = this.NullFunction;
		item.onselectstart = this.NullFunction;
		item.onfocus = function(){ this.blur(); };
		this.menuitems[this.panels[x].panelID] = item;
	}
	
	var newpanels = new Array();
	for(var x in this.panels)
		newpanels[this.panels[x].panelID] = this.panels[x];
	this.panels = newpanels;
	newpanels = null;

	this.AddClass(this.menuitems[this.currentpanel.panelID],"current");
	
	/*
	this.area.ContentScroller_oldmouseover = this.area.onmouseover ? this.area.onmouseover : function(e){};
	this.area.onmouseover = function(e){
		if(this.parentContentScroller.autoFadeTimeout!=null) {
			clearTimeout(this.parentContentScroller.autoFadeTimeout);
			this.parentContentScroller.autoFadeTimeout = null;
		}
		this.ContentScroller_oldmouseover(e);
	};
	
	this.area.ContentScroller_oldmousemove = this.area.onmousemove ? this.area.onmousemove : function(e){};
	this.area.onmousemove = function(e){
		if(this.parentContentScroller.autoFadeTimeout!=null) {
			clearTimeout(this.parentContentScroller.autoFadeTimeout);
			this.parentContentScroller.autoFadeTimeout = null;
		}
		this.ContentScroller_oldmousemove(e);
	};
	
	this.area.ContentScroller_oldmouseout = this.area.onmouseout ? this.area.onmouseout : function(e){};
	this.area.onmouseout = function(e){
		this.parentContentScroller.ResetAutoFader();
		this.ContentScroller_oldmouseout(e);
	};
	
	this.ResetAutoFader();
	*/
};

ContentScrollerClass.prototype.SwitchTo = function(newpanel) {
	if(typeof(newpanel)=="string")
		newpanel = this.panels[newpanel];
	
	if(newpanel==this.currentpanel)
		return false;
	
	if(this.scrollTimeouts && this.scrollTimeouts.length>0) {
		for(var x=0; x<this.scrollTimeouts.length; x++) {
			try{ clearInterval(this.scrollTimeouts.pop()); } catch(err){};
		}
	}
	
	// 1 = down , (-1) = up
	var dir = 1;
	dir = this.menuitems[newpanel.panelID].parentNode.offsetTop - this.menuitems[this.currentpanel.panelID].parentNode.offsetTop;
	dir = dir/Math.abs(dir);
	
	for(var x in this.panels)
		this.panels[x].style.display = "none";
	
	this.currentpanel.style.left = "0px";
	this.currentpanel.style.display = "block";
	this.currentpanel.style.top = "0px";
	newpanel.style.left = "0px";
	newpanel.style.top = (dir*this.area.offsetHeight)+"px";
	newpanel.style.display = "block";
	
	var s = window.homepage_scroll_speed!=null ? window.homepage_scroll_speed : 1;
	var t=0;
	this.scrollTimeouts = new Array();
	for(t=0; t<=this.area.offsetHeight; t+=20)
		this.scrollTimeouts.push(setTimeout("document.getElementById(\""+this.currentpanel.id+"\").style.top='"+(-dir*t)+"px'; document.getElementById(\""+newpanel.id+"\").style.top='"+dir*(this.area.offsetHeight-t)+"px';", t*s+100));
	this.scrollTimeouts.push(setTimeout("if(document.getElementById(\""+newpanel.id+"\").parentContentScroller==document.getElementById(\""+newpanel.id+"\")) { document.getElementById(\""+this.currentpanel.id+"\").style.display='none'; document.getElementById(\""+newpanel.id+"\").style.top='0px'; }", (t+20)*s+100));
	
	
	
	this.StripClass(this.menuitems[this.currentpanel.panelID],"current");
	this.AddClass(this.menuitems[newpanel.panelID],"current");
	
	this.currentpanel = newpanel;
	
	/* this.ResetAutoFader(); */
};

ContentScrollerClass.prototype.Next = function() {
	var ps = new Array();
	for(var x in this.panels)
		ps.push(this.panels[x]);
	var ind = ps[0];
	for(var x in ps)
		if(ps[x] && ps[x].panelID && ps[x].panelID==this.currentpanel.panelID && x<ps.length)
			next = ps[x+1];
	this.SwitchTo(next);
	//var ind = ps.indexOf(this.currentpanel.panelID);
	//this.SwitchTo( (ind==ps.length-1) ? this.getPanelById(ps[0]) : this.getPanelById(ps[ind+1]) )
};

/*
ContentScrollerClass.prototype.ResetAutoFader = function() {
	if(this.autoFadeTimeout!=null)
		clearTimeout(this.autoFadeTimeout);
	this.autoFadeTimeout = setTimeout("var scroller=getContentScrollerById("+this.id+"); if(scroller){ scroller.Next(); scroller.autoFadeTimeout=null; }", this.pauseDuration);
};
*/

ContentScrollerClass.prototype.NullFunction = function(e) {
	if(!e) e = window.event;
	if(e.preventBubble)
		e.preventBubble = true;
	if(e.returnValue)
		e.returnValue=false;
	if(e.StopPropagation)
		e.StopPropagation();
	if(e.preventDefault)
		e.preventDefault();
	return false;
};

ContentScrollerClass.prototype.AddClass = function(el,className) {
	var c = el.className;
	if(HasClass(el,className)==false)
		el.className += " "+className;
}
ContentScrollerClass.prototype.StripClass = function(el,className) {
	var c = el.className;
	if(HasClass(el,className)==true)
		el.className = c.substring(0,c.indexOf(" "+className)) + c.substring(c.indexOf(" "+className)+className.length+1, c.length);
}
ContentScrollerClass.prototype.HasClass = function(el,className) {
	return (el && el.className && (el.className.substring(0,className.length+1)==className+" " || el.className.indexOf(" "+className+" ")!=-1 || el.className.substring(el.className.length-className.length-1,el.className.length)==" "+className || el.className==className))
}

ContentScrollerClass.prototype.getPanelById = function(panelID) {
	for(var x in this.panels)
		if(this.panels[x].panelID==panelID)
			return this.panels[x];
	return false;
};


window.getContentScrollerById = function(id){
	return window.ContentScrollers[id];
};




ContentScroller = new ContentScrollerClass();



















// JSlide JavaScript "Slider" Input Enhancement:

function JSlide(textInputField, min, max, precision) {
	if(typeof(textInputField)=="string")
		textInputField = document.getElementById(textInputField);
	this.base = textInputField;
	this.base.JSlide = this;

	this.oldkeydown = this.base.onkeydown ? this.base.onkeydown : function(e){ return true; };
	this.oldkeyup = this.base.onkeyup ? this.base.onkeyup : function(e){ return true; };
	this.oldkeypress = this.base.onkeypress ? this.base.onkeypress : function(e){ return true; };

	this.base.onkeydown = function(e) { if(this.JSlide.HandleKey(e)==false) { this.JSlide.oldkeydown(e); return this.JSlide.NullFunction(e); } return this.JSlide.oldkeydown(e); };
	this.base.onkeyup = function(e) { if(this.JSlide.HandleKey(e)==false) { this.JSlide.oldkeyup(e); return this.JSlide.NullFunction(e); } return this.JSlide.oldkeyup(e); };
	this.base.onkeypress = function(e) { if(this.JSlide.HandleKey(e)==false) { this.JSlide.oldkeypress(e); return this.JSlide.NullFunction(e); } return this.JSlide.oldkeypress(e); };
	
	this.min = min;
	this.max = max;
	this.precision = precision!=null ? parseInt(precision) : 0;
}

JSlide.prototype.HandleKey = function(e) {
	if(!e) e=window.event;
	var key = String.fromCharCode(e.keyCode?e.keyCode:e.which);
	if(e.type=="keydown")
		this.lastDownKey = key;
	else if(e.type=="keypress")
		key = this.lastDownKey;
	var val = parseFloat(this.base.value);
	if(!val || val==null || val=="NaN" || val=="undefined")
		val = this.min;
	val = Math.round(val*Math.pow(10,this.precision)) / Math.pow(10,this.precision)
	var uval = true;
	if(val < this.min) {
		val = this.min;
		uval = false;
	}
	if(val > this.max) {
		val = this.max;
		uval = false;
	}
	this.base.value = val.toString();
	
	var allowedChars = new Array("0","1","2","3","4","5","6","7","8","9","\b","\t");
	var rval = false;
	for(var x in allowedChars)
		if(key==allowedChars[x])
			rval = true;
	return (rval==false || uval==false)?false:true;
};

JSlide.prototype.NullFunction = function(e) {
	if(!e) e = window.event;
	if(e.preventBubble)
		e.preventBubble = true;
	if(e.returnValue)
		e.returnValue=false;
	if(e.StopPropagation)
		e.StopPropagation();
	if(e.preventDefault)
		e.preventDefault();
	return false;
};





















// Tooltips:
var tooltip_oldmouseouts = new Array();
function tooltip( el_input , text ) {			// parameters:  element receiving tooltip ,  tooltip text
	if(!text)
		return false;
	var el = el_input?el_input:this;
	el.onmousemove = function(e) {
		if(!e){ e=window.event; }
		var mouseX, mouseY;
		if(e.pageX) { mouseX = e.pageX; mouseY = e.pageY; }
		else if(e.clientX) { mouseX = e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft; mouseY = e.clientY+document.body.scrollTop+document.documentElement.scrollTop; }
		var tip = document.getElementById('tooltip');
		if(!tip) {
			sid = "tooltip_inner_"+Math.random()*5;
			tip = document.createElement('div');
			tip.setAttribute("id","tooltip");
			tip.style.position = "absolute";
			tip.style.left = "-999em";
			tip.style.top = "-999em";
			tip.innerHTML = "<span id=\""+sid+"\">"+text+"</span>";
			document.body.appendChild(tip);
			if(document.getElementById(sid).offsetWidth < tip.offsetWidth)
				tip.style.width = document.getElementById(sid).offsetWidth + "px";
		}
		if(mouseY+20+tip.offsetHeight < document.body.offsetHeight)
			tip.style.top = (mouseY+20)+"px";
		else
			tip.style.top = (mouseY - tip.offsetHeight - 20) + "px";
		if(mouseX+20+tip.offsetWidth < document.body.offsetWidth)
			tip.style.left = (mouseX+20)+"px";
		else
			tip.style.left = (document.body.offsetWidth - tip.offsetWidth) + "px";
	}
	tooltip_oldmouseouts[el] = el.onmouseout?el.onmouseout:function(e){};
	el.onmouseout = function(e) { this.onmouseout=tooltip_oldmouseouts[this]; if(document.getElementById("tooltip")) document.getElementById("tooltip").parentNode.removeChild(document.getElementById("tooltip")); this.onmouseout(e); }
	return true;
}











