/* onload execution */
 if (!ns6){  load.push("document.execCommand('BackgroundImageCache', false, true)"); }
/* ogoogle analatycs */
 var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27556848-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();/* ogoogle analatycs end */
/* library functions */
evt=function(el,evt,obj){(ns6)?el.addEventListener(evt,obj,false):el.attachEvent('on'+evt,obj)}
noevt=function(el,evt,obj){(ns6)?el.removeEventListener(evt,obj,false):el.detachEvent('on'+evt,obj)}
exists=function(nam){return document.getElementById(nam)}
url=function(url){self.location.href=url;}
/* email rewriting */
function eml(cls,a,b,c){document.write('<a href="mailto:'+a+'@'+b+'.'+c+'" class="'+cls+'" onfocus="this.blur()">'+a+'@'+b+'.'+c+'</a>');}
/* telephone rewriting */
function tel(className,country,code,number){document.write('<span class="'+className+'">'+country+' '+code+'/'+number+'</span>')}
/* debug functionality */
document.onkeyup=function(e)
{	if(!e) e=event;
	if(e.altKey&&e.ctrlKey&&e.keyCode==68)	// press Ctrl-Alt-D to visualize debug info
	{	log.push('--- dynlite log end ---');
		var err=log.join('<br>');
			err=err.replace(/#([^<]+)</gi,'<b class="debug"># $1</b><'); // status messages
			err=err.replace(/\!([^<]+)</gi,'<em class="debug">! $1</em><'); // error messages
		var el=obj("debug");
			el.innerHTML=err;
			el.on();
			el.onclick=function(){this.off()}
	}
};
/* show-hide invisible element */
function showHide(id)
{	el=obj(id)
 	if((el.style.display=="none")||(el.style.display=="")){el.on()}else{el.off()}
}
/* div popup class */
function divPopup(id,cont,img)
{	this.id=id;
	this._img=new Image();
	this._contName=cont;
	this._imgName=img;
	this.cont=0;
	this.img=0;
	lastImg='';
}
/* div popup methods */
/* private */
_dp=divPopup.prototype;
_dp._show=function()
{	if(this.time) 
	{	clearTimeout(this.time);
	}
	this.img.src=this._img.src;
	this.cont.style.width=this._img.width;
	this.cont.style.height=this._img.height;
	if(this.lbl)
	{	this.img.width=this._img.width;
		this.img.height=this._img.height;
	}
/* calculating Y-coord of the enlarge div */
	//default x position
	this.cont.style.left=posObjX-this._img.width+"px";
	if((this._img.width+posObjX)>document.body.scrollWidth)
		if((posObjX-this._img.width)<0)
			this.cont.style.left=0;
		else
			this.cont.style.left=posObjX-this._img.width+"px";
	else
		this.cont.style.left=posObjX+"px";
/* calculating Y-coord of the enlarge div */
	//default y position
	this.cont.style.top=posObjY-this._img.height+"px";
	if((this._img.height+posObjY)>document.body.scrollHeight)
		if((posObjY-this._img.height)<0)
			this.cont.style.top=0;
		else
			this.cont.style.top=posObjY-this._img.height+"px";
	else
		this.cont.style.top=posObjY+"px";
	(ns6)? this.cont.style.MozOpacity="1":this.cont.filters.alpha.opacity="100";
	setTimeout("obj('enlargeBottom').on()",450);
}
/* public */
function disableEvent(){return false;}
function enableEvent(){return true;}
_dp.show=function(src,e)
{	if(!this.cont) this.cont=obj(this._contName);
	if(!this.img) this.img=obj(this._imgName);
	if(!ns6) e=event;
	posObjY=e.clientY+document.body.scrollTop;
	posObjX=e.clientX+document.body.scrollLeft;
	this._img.defsrc=this.img.getAttribute("defsrc",false);
	this._img.src=src;
	this._img.onload=function(){dp._show();};
	this.time=setTimeout("dp._show()",100);
	obj('enlargeBottom').off();
	this.cont.on();
	document.onselectstart = disableEvent;
	document.onmousedown = disableEvent;
	document.ondragstart = disableEvent;
}
_dp.close=function()
{	this.cont.off();
	this.img.src=this._img.defsrc;
	(ns6)? this.cont.style.MozOpacity=".7":this.cont.filters.alpha.opacity="70";
	document.onselectstart = enableEvent;
	document.onmousedown = enableEvent;
	document.ondragstart = enableEvent;
}
_dp.drag=function(e)
{	if(!ns6) e=event;
	this.offsetY=e.clientY-this.cont.offsetTop;
	this.offsetX=e.clientX-this.cont.offsetLeft;
	evt(document,'mousemove',dp_move);
	evt(document,'mouseup',dp_stopmove);
}
function dp_move(e)
{	if(!ns6) e=event;
	dp.cont.style.top=e.clientY-dp.offsetY;	
	dp.cont.style.left=e.clientX-dp.offsetX;
	//e.cancelBubble = true
	//dp.cont.onmouseout=function(){dp_stopmove();}
	//if(parseInt(dp.cont.style.top)<10) info(e);//setTimeout('dp_stopmove()',10);
		
}
function dp_stopmove(e)
{	noevt(document,'mousemove',dp_move);
}
_dp.resize=function(e)
{	if(!ns6) e=event;
	this.lbl=1;
	this.offsetY=e.clientY-this.img.height;
	this.offsetX=e.clientX-this.img.width;
	evt(document,'mousemove',dp_size);
	evt(document,'mouseup',dp_stopsize);
	
}
function dp_size(e)
{	if(!ns6) e=event;
	dp.cont.style.width=e.clientX-dp.offsetX;
	dp.cont.style.height=e.clientY-dp.offsetY;
	dp.img.width=e.clientX-dp.offsetX;
	dp.img.height=e.clientY-dp.offsetY;
}
function dp_stopsize(e)
{	noevt(document,'mousemove',dp_size);
}	

/* static object creation */
dp=new divPopup('dp','enlarge','enlargePic');

