/**
* @package JS Nav
* @subpackage public.plugins.jsn
* @author shay anderson 11.09
* @version 1.0
* @desc javascript drop down navigation
* @example 
	(after <ul id="jsn"></ul>) $jsn.add('href_id','node_id');
	(before <ul id="jsn"></ul>) window.onload=function() { $jsn.add('href_id','node_id'); };
	<ul id="jsn">
	    <li><a href="#" id="jsn0">Parent 0</a>
	        <div id="jsn00">
	        <a href="#">Child 00</a>
	        <a href="#">Child 01</a>
	        </div>
	    </li>
	    <li><a href="#" id="jsn1">Parent 1</a>
	        <div id="jsn10">
	        <a href="#">Child 10</a>
	        <a href="#">Child 11</a>
	        </div>
	    </li>
	</ul>
	<div id="jsn_eof"></div>
*/
function jsn() {
	var node=0;
	this.timeout=500;
	this.timer=0;
	
	function $(node_id) { /** @return obj */
		return document.getElementById?document.getElementById(node_id):document.all(node_id);
	} // $
	
	function isObj(node_in) { /** @return bool */
		inode=node_in?node_in:node;
		return typeof inode=='object'?true:false;
	} // isObj
	
	this.over=function(node_id) {
		this.reset();
		if(isObj()) {
			try { node.style.visibility='hidden'; } catch(err) {}
		} // if
		node=$(node_id);
		if(isObj()) {
			try { node.style.visibility='visible'; } catch(err) {}
		} // if
	} // over
	
	this.hide=function() {
		if(isObj()) {
			try { node.style.visibility='hidden'; } catch(err) {}
		} // if
	} // hide
	
	this.out=function() {
		this.timer=window.setTimeout(this.hide,this.timeout);
	} // out
	
	this.reset=function() {
		if(this.timer) {
			window.clearTimeout(this.timer);
			this.timer=0;
		} // if
	} // reset
	
	this.add=function(a_id, node_id) {
		var a=$(a_id);
		var anode=$(node_id);
		if(isObj(a)) {
			a.onmouseover=function(){$jsn.over(node_id);};
			a.onmouseout=function(){$jsn.out();};
		} // if
		if(isObj(anode)) {
			anode.onmouseover=function(){$jsn.reset();};
			anode.onmouseout=function(){$jsn.out();};
		} // if
	} // add
	
} // jsn
var $jsn=new jsn();
document.onclick=$jsn.hide;