/* 	public area scripts
 *	AIP Solutions Ltd'2005
 *	www.aip-solutions.com
 *	mod version : 0.8.1.0
 *	mod date	: 2005-12-01
 */

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

/* 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;
}
/* div popup methods */
/* private */
_dp=divPopup.prototype;
_dp._show=function(pos)
{	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;

	(ns6)? this.cont.style.MozOpacity="1":this.cont.filters.alpha.opacity="100";
	setTimeout("obj('enlargeBottom').on()",450);
}
/* public */
_dp.show=function(src,pos)
{	if(!this.cont) this.cont=obj(this._contName);
	if(!this.img) this.img=obj(this._imgName);
	this._img.defsrc=this.img.getAttribute("defsrc",false);
	this._img.src=src+'B.jpg';
	this._img.onload=function(){dp._show(pos)};
	this.time=setTimeout("dp._show()",100);
	obj('enlargeBottom').off();
	this._selectable('on');
	this.cont.on();
	posY=pos.offsetTop+this._img.height+100
	contY=obj('content').offsetHeight;
	this.cont.style.top=(posY>contY)?pos.offsetTop-220:pos.offsetTop;
	//if(ns6) this.cont.addEventListener('mousedown',dp.drag,false);
}
_dp._selectable=function(mode)
{	if(document.all)
		for(i in document.all)
			document.all[i].unselectable=mode;
}

_dp.close=function()
{	this.cont.off();
	this.img.src=this._img.defsrc;
	(ns6)? this.cont.style.MozOpacity=".7":this.cont.filters.alpha.opacity="70";
	this._selectable('off');
}
_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_stop);
}
function dp_move(e)
{	if(!ns6) e=event;
	dp.cont.style.top=e.clientY-dp.offsetY;
	dp.cont.style.left=e.clientX-dp.offsetX;
}
function dp_stop(e)
{	noevt(document,'mousemove',dp_move);
}

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

/* tabs */
var oldVar=1;
function tab(newVar)
{	obj('tabButton'+oldVar).on();
	obj('tabButtonA'+oldVar).off();
	obj('tab'+oldVar).off();
	obj('tabButtonA'+newVar).on();
	obj('tabButton'+newVar).off();
	obj('tab'+newVar).on();
	//alert(oldVar+'->'+newVar)
	oldVar=newVar;
}

/* randdom img - fade*/
var filterStep=(ns6)?(5/100):5;
var filterMax=(ns6)?1:100;
var mozOp=0;
var clr=null;
var clrTime=0;
var currEl=0;
var randNum=0;

function chngImg()
{	nextEl=randNum;
	while (nextEl==randNum)
		nextEl=Math.floor(Math.random()*5);
	randNum=nextEl;
	img=document.getElementsByTagName('IMG')
	for(i in img)
		if(img[i].id && img[i].getAttribute('el')=='yes')
			currEl=img[i].id.replace(/middleLeftBanner/, "");
	fade();
}
function fade()
{	filtrCurrEl=(ns6)?obj("middleLeftBanner"+currEl).style.MozOpacity:obj("middleLeftBanner"+currEl).filters.alpha.opacity;
	filtrnextEl=(ns6)?obj("middleLeftBanner"+nextEl).style.MozOpacity:obj("middleLeftBanner"+nextEl).filters.alpha.opacity;
	clrTime=setTimeout('fade()',40);
	if(filtrCurrEl>0)
	{	if(ns6)obj("middleLeftBanner"+currEl).style.MozOpacity-=filterStep;
		else obj("middleLeftBanner"+currEl).filters.alpha.opacity-=filterStep;
	}
	else
	{	obj("middleLeftBanner"+currEl).style.display="none";
		obj("middleLeftBanner"+currEl).setAttribute('el','no');
	}
	obj("middleLeftBanner"+nextEl).style.display="block";
	obj("middleLeftBanner"+nextEl).setAttribute('el','yes')
	if(filtrnextEl<filterMax)
	{	if(ns6)
		{	mozOp+=filterStep;
			obj("middleLeftBanner"+nextEl).style.MozOpacity=mozOp;
		}
		else obj("middleLeftBanner"+nextEl).filters.alpha.opacity+=filterStep;
	}
	else
	{	mozOp=0;
		clearTimeout(clrTime)
	}
}