/* dynlite dhtml dom api  
 * peter assenov- AIP Solutions Ltd.' 2004
 * @version: 2.2.0/12.05.2004
 */
	      
/* dynlite initialisation */
dom=(document.getElementById)?1:0;
ns6=(dom&&!document.all)?1:0;
if(!dom)
{	alert('This site is not compatible with your browser!');
	self.location.href='browser.html';
}
ver=2.2; 
dev=1;
/* dynlite debug */
error=function(msg,url,lno,type)
{	var err=['<msg> '+msg,'<line> '+lno,'<url>   '+url.replace(/^.*(\/|\\)/,'')];
	log.push('!'+(type||'')+'Error: '+err.join(' '));
	if(dev) alert(type+' Error!\n------------------------------------------------\ndynlite detected the following error: \n\n'+err.join('\n'));
return true
}
onerror=error;
info=function(el,vis)
{	if(typeof(el)=='object')
	{	var code=[],j=0;
		if(el.xml) code[0]=el.xml;
		else for(var i in el){code[j++]=i+' -> '+el[i]}
		(vis)?document.write(code.join('<br>')):alert(code.join('\n'));
	}
	else alert(el);
}
Array.prototype.push=function(el){this[this.length]=el;} /* ie5 sucks */
log=['--- dynlite log ---'];
/* events handling */ 
evt=function(elm,evt,obj,met)
{	if(/^on/.test(evt))
	{	cel = window[elm];
		cel[evt]=function(e){(met)?window[obj][met](e):obj(e)};
	}
	else (ns6)?elm.addEventListener(evt,obj,false):elm.attachEvent('on'+evt,obj);
log.push('-added '+evt+' event listener to object '+elm);
}
evoke=function(elm,cevt,pars)
{	if(typeof(elm)=='object')
	{	if(elm[cevt]) (!ns6)? eval(elm[cevt]) : elm[cevt]();
		else if(window[elm.id+cevt]) window[elm.id+cevt]();	
	}
//	var cel= elm:window[elm];
//	var cpars=(pars)? pars.toString():'';									
//return (cel&&cel[cevt])?cel[cevt](cpars):null;							
}
/* stylesheet processing */
css=function(el,prop,val)
{	var root=document.styleSheets;
	for(i=root.length-1;i>=0;i--) 
	{	if(!prop) {(!ns6)? root[i].cssText+=el:root[i].insertRule(el,root[i].length); return 0;}
		var arr=(ns6)? root[i].cssRules:root[i].rules;
		for(var j=arr.length-1;j>=0;j--)
		{	var cel=arr[j];
			if(cel.selectorText.toLowerCase()==el.toLowerCase())				
			{	if(val==null) return(cel.style[prop]);						
				else cel.style[prop]=val;							
			return 0;
			}
		}
	}
	error('no element '+el+' found','dynlite.js','css()','Runtime');	
}
/* onload initialisation */	
load=[];
onload=function(){eval(load.join(";")); if(window.init) init(); log.push('#onload code executed');}
/* auto initialisation */
attr=function(el,attr,val)
{	if(!val) return (!ns6)?el.getAttribute(attr):(el.hasAttribute(attr))?el.getAttribute(attr):null;
	else alert('not implemented');
}
make=function(tag,obj)
{	var arr=document.getElementsByTagName(tag);
	for(var i=arr.length-1;i>=0;i--)
	{	var id=attr(arr.item(i),'id');
		var ob=attr(arr.item(i),'dynobj')||obj;
		if(id)
		{	if(ob&&!window[ob])	error('no class '+ob+' found','dynlite.js','make()','Runtime');
			else window[id]=(ob)? new window[ob](id):window.obj(id); 
		}	
	}
	log.push('- tag '+tag+' processed');
}
/* dynlite layer */ 
obj=function(id)
{ 	el=document.getElementById(id);
	if(!el) {error('no element with id='+id+' found','dynlite.js','obj()','Runtime');return 0;}
	el.css=el.style;
	el.show=function(nest){el.css.visibility=(nest)?'inherit':'visible'};
	el.hide=function(){el.css.visibility='hidden'};
	el.on=function(type){el.css.display=(type)? type:'block';}
	el.off=function(){el.css.display='none';}
	log.push('+obj ['+id+'] created');
return el;
}
load.push('make("DIV")');
/* misc */
gmt=function(){return new Date()}
log.push('#dynlite core loaded- debug '+((dev)?'on':'off'));
//enjoy...
