/* public javascript code
 * based on	dynlite dhtml dom api
 * @author:  Peter Assenov- AIP Solutions Ltd.' 2001-2007
 * @version: 2.2.1.3/2007-03-21
 * !requires: dynlite.0.9.js
 */

  
/* 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)}
/* 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()}
	}
};

/* 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;
	obj('ert').value=dp.cont.style.top;
	//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');

/* additional web site functionalities */
function showhide(dId)
{ if(obj(dId).style.display=='block')	obj(dId).off();
	else	obj(dId).on();
}

/* fade view pictures */
/* class constructor */
function trans(id)
{	this.id=id;
	this.steps=20;
	this.time=30;
	this.interval=0;
	this.cords=[];
	this.i=0;
}
tp=trans.prototype;
/* private methods */
tp._calc=function(start,end)//original source of bezier method- http://astronomy.swin.edu.au/~pbourke/curves/bezier/ 
{	var cords=[];
	for(var i=this.steps;i>=0;i--)
	{	var mu=i/this.steps;
		var mu2=mu*mu;
		var mum1=1-mu;
		var mum12=mum1*mum1;
		cords[i]=Math.round(start*mum12+2*end*mum1*mu+end*mu2);
	}
return cords;	
}
tp._step=function()
{	this.i+=this.dir;
	this.evoke('ontrans');
	if(!this.i||this.i>=this.steps)	
	{	clearInterval(this.interval);
		this.evoke((this.dir==1)? 'ontransin':'ontransout');
	}
}
/* public methods */
tp.evoke=function(evt,e)
{	if(this[evt]) this[evt](e);
}
tp.go=function(dir)
{	clearInterval(this.interval);
	this.dir=dir||1;
	this.evoke('ontransstart');
	this.interval=setInterval(this.id+"._step()",this.time);
}
tp.stop=function()
{	clearInterval(this.interval);
	this.evoke('ontransstop');
}
/* gardarte image transition class */
function gallery(id)
{	this.id=id;
	this.cords=this._calc(1,99);
	this.bussy=0;
}
gp=gallery.prototype=new trans;
gp._trans=function(obj,trans)
{	//alert(obj.tagName)
	if(obj.tagName!="DIV"){
		if(obj.filters)	obj.filters.alpha.opacity = trans;
		else			obj.style.setProperty("-moz-opacity",trans/100,"");
	}
	else {obj.style.display="block"}
}
gp.preview=function(image,border)
{	//alert(obj(image).id);
	if(this.bussy||this.image==image) return;
/* swap image */
	this.nimage=image;
	this.go(1);
/* on/over effects */
	if(obj(this.border).filters)	obj(this.border).filters.alpha.opacity = 99;
	else	obj(this.border).style.setProperty("-moz-opacity",99/100,"");
	this.border=border;
	if(obj(this.border).filters)	obj(this.border).filters.alpha.opacity = 50;
	else	obj(this.border).style.setProperty("-moz-opacity",50/100,"");
	//pisture position calculate with the use of the size of the div-container --- 414x386
	objWidth=(obj(image).tagName=="IMG")?obj(image).width:obj(image).offsetWidth-6;
	objHeight=(obj(image).tagName=="IMG")?obj(image).height:obj(image).offsetHeight;
	leftPos=(360-objWidth)/2;
	topPos=(300-objHeight)/2;
	obj(image).style.margin=topPos+" 0 0 "+leftPos;
}
/* custom event handlers */
gp.ontransstart=function()
{	this.bussy=1;
	this._trans(obj(this.nimage),1);
	obj(this.nimage).on();
}
gp.ontrans=function()
{	var val=this.cords[this.i];
	this._trans(obj(this.image),100-val);
	this._trans(obj(this.nimage),val);
}
gp.ontransin=function()
{	this.i=0;
	obj(this.image).off();
	this.image=this.nimage;
	this.bussy=0;
}
/* creation of the actual object */
t=new gallery('t');