Event.observe(window, 'load', function() {
  showImage();
});

var counter = 1;
var company = 'i';

var images = { 'i1': {'width': 234, 'height':168},
	             'i2': {'width': 338, 'height':198},
	             'i3': {'width': 182, 'height':136},
	             'i4': {'width': 269, 'height':223},
	             's1': {'width': 290, 'height':164},
	             's2': {'width': 212, 'height':169},
	             's3': {'width': 175, 'height':157},
	             's4': {'width': 283, 'height':176}};


function rnd(max) {
	 return Math.random() * max;
}

function isIE()
{
  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function showImage(){
	//380 x 445
	var img = company + counter;
	var width = images[img].width;
	var height = images[img].height;
	if (isIE()) {
		width -=5;
		height -=5;
	}
	var frame = $('image_' + company);
	frame.setStyle({width: width + 'px'});
	frame.setStyle({height: height + 'px'});
	var left; var top;
	if (company == 'i') {
			left = rnd(380 - width);
			top = rnd(445 - height);
	}
	else {
			left = 410 + rnd(380 - width);
			top = rnd(400 - height);
	}
	frame.setStyle({left: left + 'px'});
	frame.setStyle({top: top + 'px'});
	var ie_path = isIE() ? 'ie/' : '';
	frame.setStyle({backgroundImage:'url(img/' + ie_path + img + '.png)'});
	new Effect.Appear(frame.id, {duration:0.8});
	setTimeout("new Effect.Fade($('image_" + company + "'), {duration:1.5});", 1700);
	setTimeout("showImage()", 1600);
	if (company == 's') {
			counter = (counter < 4) ? counter + 1 : 1;
			company = 'i';
		}
	else
			company = 's';
}

