var devicesblockDiv = $('devicesblock');
if(devicesblockDiv != null && devicesblockDiv != undefined){
	
	coor=$('devicesblock').getPosition();
	yco=coor.y;

	devHeight=340;
	if (window.ie6)	{
		yco=yco-15; devHeight=340
	}
	$$(".device").each(function(el) {
		//add borders to devices :-( 
		bla="t"+el.id;
		bla2=(bla.substring(5))*1;
		targ=$("toolblok"+bla2);
		if (targ != null) {
			if (bla2<5) {
				el.addClass('firstline')
			}
			if ((bla2/4)==(Math.floor(bla2/4))) {
				el.addClass('lastcol')
			}
			pos=bla2-1;
			line=Math.floor(pos/4);

			linePos=(yco-170)+devHeight*line;
			coll=pos-4*line;
			if (coll<2) {
				collPos=198+(coll+1)*187; 
				targ.setStyle('background', 'url(/shop/img/ej/bg_blue_detail.png)');
				targ.addClass('imgright')
			} else {
				collPos=190+(coll-2)*187;
				targ.setStyle('background', 'url(/shop/img/ej/bg_blue_detail_inv.png)');
				targ.addClass('imgleft')
			}
			targ.setStyle('top',linePos);
			targ.setStyle('left',collPos);
	
			//add events
			el.addEvent('mouseenter', function(el){
				var existimg=this.getElement('img.detailimg');
				if (!existimg) {
					var bigimg = this.getElement("var.imge");
					if(bigimg != null) {
						var big_img = bigimg.innerHTML;
						var theimg = new Element('img', {
							src: big_img,
							alt: '',
							'class': 'detailimg'
						});
						theimg.inject(this);
					}
				}
				this.delayTimer=this.setStyle.delay(500, this, ["display", "block"]);
			}.bind(targ))
	
			el.addEvent('mouseleave', function(el){
				$clear(this.delayTimer);
				this.hide();
			}.bind(targ))
		}
	});
}
