var CatchEye = {
	loader	: null,
	im1		: null,
	im2		: null,
	imNo1	:Math.round((Math.random()*9)+1),
	imNo2	:Math.round((Math.random()*9)+1),
	path	: '',
	foto	: 1,
	
	init : function () {
		this.loader = Dom.gO('catch-eye');
		path = 'img/catcheye/';
		this.im1 = new Image(100,65);
		this.im2 = new Image(100,65);
		this.im1.src = path+this.imNo1+'.jpg';
		this.im2.src = path+this.imNo2+'.jpg';
		this.im1.alt = this.imNo1;
		this.im2.alt = this.imNo1;
		this.im2.style.marginLeft = '100px';
		Dom.aE(this.im1,this.loader);
		Dom.aE(this.im2,this.loader);
		document.onload = CatchEye.slideShow();
	},
	
	slideShow : function () {
		window.setInterval("CatchEye.changeImage()",5000);
	},
	
	changeImage : function () {
		
		var act1 = this.imNo1;
		var act2 = this.imNo2;
			
		var ok = false;
		while(ok == false) {
			var rnd = Math.round((Math.random()*9)+1);
			switch(this.foto) {
				case 1: 
					if((rnd != act1) && (rnd != act2)) {
						this.im1.src = path+rnd+'.jpg';
						this.imNo1 = rnd;
						ok = true;
						this.foto = 2;
					}
				break;
				
				case 2:
					if((rnd != act2) && (rnd != act1)) {
						this.im2.src = path+rnd+'.jpg';
						this.imNo2 = rnd;
						ok = true;
						this.foto = 1;
					}
				break;
			}
		}
	}
};

var Dom = {
	gO : function (o) { return document.getElementById(o); },
	
	aE : function (co,kam) { return kam.appendChild(co); },
	
	rE	: function (co,odkud) { return odkud.removeChild(co); }
};

var foto = {

	img	: {
		show : function (url) {
			var w = window.open('',400,400,'status=no,directories=no,resize=yes,scroll=yes')
			w.document.write(	'<html>'+
								'<head><title>KVH Bruntál - foto</title><script type="text/javascript" src="js/kvh.js"></script></head>'+
								'<body onload="foto.img.wResize(Dom.gO(\'foto\'));" style="pading:0; margin:0; text-align:center;">'+
								'<img src="'+url+'" id="foto" alt="Kliknutím zavřete." onclick="self.close();">'+
								'</body>'+
			'</html>');
			w.document.close();
			w.focus();
			return false;
		},
		
		wResize : function (im) {
			var sX = im.width;
			var sY = im.height;
			if (im.width > screen.width)
				sX = screen.width - 200;
			if (im.height > screen.height)
				sY = screen.height - 200;
				
			window.resizeTo(sX,sY);
		}
	},
	
	movie : {
		show : function (fileName) {
			var player = 	'<div id="player">';
				player +=	'';
				player +=	'';
				player +=	'';
				player +=	'';
				player +=	'';
				player +=	'</div>';
		}
	}
}
