// common functions
// author: PablO
// 2005-03-16
// last update: 2005-09-12

// API

// switch class
// this function removes passed class from object if set,
// otherwise set this class to object
// last update: 2005-07-22 
// c - string, name of the class
// o - reference to object, if no, html is taken
function sCl(c,o){if((o=o||gET('html')[0]).className==rCl(o,c))aCl(o,c)}

sCl('JSON')

// add Class
// adding class to object
// o - reference to object
// c - class name to add
function aCl(o,c){o.className+=' '+c}

// remove Class
// removing class from object
// o - reference to object
// c - class name to remove
function rCl(o,c){return o.className=o.className.replace(new RegExp('\\b'+c+'\\b','g'),'')}

// getElementsByTagName
// getting elements by tag name
// t - tag name
// p - parent (optional)
function gET(t,p){return(p||document).getElementsByTagName(t)}

// getElementById
// getting element by id
function gId(i,p){return(p||document).getElementById(i)}

// get Event Element
// getting event element
function gEE(e){return e||window.event}

// get Source Element
// getting source element of the event
function gSE(e){return (e=gEE(e)).target||e.srcElement}

// add Event Listener (DO NOT ultrapack like Elus)
// attaching events to elements
// last update: 2005-07-22 
// o - object
// t - type (ex. load)
// f - function
// b - bubble (true or false)
function aEL(o,t,f,b,x){return(o.addEventListener)?o.addEventListener(t,f,b||false):(o.attachEvent)?o.attachEvent('on'+t,f):!1}


// menu

aEL(window,'load',function(){
	function mAClick(e){sCl('show',gET('ul',e=gSE(e).parentNode)[0]);sCl('curr',e)}

	for(i=0,o=gET('a',gId('mapMenu'));a=o[i++];){if(gET('ul',a.parentNode)[0]){aEL(a,'click',mAClick);aCl(a,'activatesSubmenu')}}
})
