function activateActiveX () {
	if(document.attachEvent && !window.opera) {
		var obj = document.getElementsByTagName('object');
		for (i=0;i<obj.length;i++) {
			obj[i].outerHTML = obj[i].outerHTML;
		}
		var embed = document.getElementsByTagName('embed');
		for (i=0;i<embed.length;i++) {
			embed[i].outerHTML = embed[i].outerHTML;
		}
	}
}

var camera = {
	interval : null,
	cameraSrc : null,
	linkSrc : 'http://napoveda.seznam.cz/kamera.jpg',

	init : function() {
		camera.cameraSrc = document.getElementById('cameraSrc');
		camera.cameraSrc.src = camera.linkSrc + "?rnd=" + Math.round(Math.random()*655360);
		camera.cameraSrc.className = '';
		camera.interval = window.setInterval(camera.change, 3000);
		
		return false;
	},
	
	change : function() {
		camera.cameraSrc.src = camera.linkSrc + "?rnd=" + Math.round(Math.random()*655360);
	}
};

SZN.Print = SZN.ClassMaker.makeClass({
	NAME : 'SZN.Print',
	VERSION : '1.0',
	CLASS : 'class'
});
SZN.Print.prototype.$constructor = function(elm){
	this.elm = SZN.gEl(elm);
	this._link();
}
SZN.Print.prototype.print = function(e,elm){
	SZN.Events.cancelDef(e);
	window.print();
}
SZN.Print.prototype._link = function(){
	this.printAction = SZN.Events.addListener(this.elm,'click',this,'print');
}


/* skryvani obsahu diplomovych pracich  */
SZN.ShowHidde = SZN.ClassMaker.makeClass({
	NAME: "ShowHidde",
	VERSION: "1.0",
	CLASS: "class"
});
		
SZN.ShowHidde.prototype.$constructor  = function(show) {
	var links = SZN.Dom.getElementsByClass(show);		
	for(var a=0; a < links.length; a++){
		SZN.Events.addListener( SZN.Dom.getElementsByClass(show)[a], 'click', this, 'change');
	}
}
	
SZN.ShowHidde.prototype.change = function(e, elm) { 
	if(elm.nextSibling.nextSibling.style.display == 'block') {
		elm.nextSibling.nextSibling.style.display = "none";
		elm.style.backgroundPosition = "0 0";
	}	
	else {
		elm.nextSibling.nextSibling.style.display = "block";
		elm.style.backgroundPosition = "0 -13px";
	}
	SZN.Events.cancelDef(e);
	SZN.Events.stopEvent(e);	
}

/* main pro galerii s jednim obrazkem - zna jeho rozmery */
SZN.LightBox.Main.Novinky = SZN.ClassMaker.makeClass({
	NAME: 'SZN.LightBox.Main.Novinky',
	EXTEND: SZN.LightBox.Main,
	VERSION: '1.0',
	CLASS: 'class'
});

SZN.LightBox.Main.Novinky.prototype.update = function(i){
	this.width = this.owner.data[i].big.width;
	this.height = this.owner.data[i].big.height;

	var imgObj = this.owner.data[i];
	if (imgObj.flash) { /* flash */
		this._generateFlashElm(imgObj);
	} else { /* picture */
		this._generateImgElm(imgObj);
	}
}

SZN.LightBox.Main.Novinky.prototype._generateImgElm = function(img) {
	var em = SZN.cEl('img');
	em.style.visibility = 'hidden';
	em.width = this.width;
	em.height = this.height;
	em.style.width = this.width + 'px';
	em.style.height = this.height + 'px';
	/*em.style.position = 'absolute';*/
	em.src = img.big.url;
	this.dom.mainBox.appendChild(em);
	this._switchImages(em);
};

/* oziveni prvku spoustejicich galerii v Clanku*/
SZN.LightBox.Anchorage.Napoveda = SZN.ClassMaker.makeClass({
	NAME: 'SZN.LightBox.Anchorage.Napoveda',
	EXTEND: SZN.LightBox.Anchorage,
	VERSION: '1.0',
	CLASS: 'class'
});

SZN.LightBox.Anchorage.Napoveda.prototype.$constructor = function(owner) {
	this.callSuper('$constructor',arguments.callee)(owner);
	this.elm = SZN.gEl(this.options.elmId);
};

/**
 * metoda je volana defaultne pri zobrazeni galerie aby se galerie napozicovala
 */
SZN.LightBox.Anchorage.Napoveda.prototype.actualizePosition = function() {
	var hasParent = true;
	if (!this.owner.visible) {
		this.container.style.position = 'absolute';
		this.container.style.top = '-1000px';
		this.container.style.left = '-1000px';
		this.container.style.visibility = 'hidden';
		hasParent = false;
	}

	var body = document.getElementsByTagName('body')[0];
	body.insertBefore(this.container, body.firstChild);

	this._position();

	if (!hasParent) {
		this.container.parentNode.removeChild(this.container);
		this.container.style.visibility = 'visible';
	}
};
SZN.LightBox.Anchorage.Napoveda.prototype._position = function() {
	var portSize = SZN.Dom.getDocSize();
	var w = 20+this.owner.data[0].big.width;
	var h = 20+this.owner.data[0].big.height;
	if (this.useAbsoluteHack) { //ti co neumí position fixed pozicují pres absolute
		var wScroll = SZN.Dom.getScrollPos();
		this.container.style.position = 'absolute';
		this.container.style.top = Math.round(wScroll.y + portSize.height/2 - h/2)+'px';
		this.container.style.left = Math.round(wScroll.x + portSize.width/2 - w/2)+'px';
	} else {
		this.container.style.position = 'fixed';
		this.container.style.top = Math.round(portSize.height/2 - h/2)+'px';
		this.container.style.left = Math.round(portSize.width/2 - w/2)+'px';
	}
};

/* trida ktera se stara o vytvareni galerii ve strance */
SZN.GalleryMaker = SZN.ClassMaker.makeClass({
	NAME:'SZN.GalleryMaker',
	VERSION:'1.0',
	IMPLEMENT:[SZN.SigInterface],
	CLASS:'class'
})

SZN.GalleryMaker.prototype.$constructor = function(type,imgId,conf,data,startPos){
	this.type = type;
	this.imgId = imgId;
	this.conf = conf;
	this.data = data;
	this.startPos = startPos ? startPos : 0;
	this.elmsToHide = ['iframe','object','select','embed'];
	this.hideElements = [];
	this.gallery = null;
	this.init();
};


SZN.GalleryMaker.prototype.$destructor = function(){
	this.gallery.$destructor();
};

SZN.GalleryMaker.prototype.init = function(){
	this.conf.anchorageOpt.elmId = this.imgId;
	this.gallery = new SZN.LightBox(this.data, this.conf);
	/*if(this.type == 'singleTop'){
		this._buildSingle();
		this.gallery.bindElement(SZN.gEl('gallBox'),this.startPos);
	} else if(this.type == 'gallery'){
		this._buildGallery();
		this.gallery.bindElement(SZN.gEl('gallBox'),this.startPos);
	} else if(this.type == 'galleryHP'){
		this._buildGallery();
		this.gallery.bindElement(SZN.gEl('hpGalleryTitle'),this.startPos);	
		this.gallery.bindElement(SZN.gEl(this.imgId),this.startPos);
		return;
	} else {
		if(this.type == 'singleArticle'){
			if(!this.skyscraperHidder){
				this.skyscraperHidder = new LTBSkyscraperHidder('adSkyscraper');
			}
		}
	}*/
	if(SZN.gEl('gallBox')){
		SZN.gEl('gallBox').parentNode.parentNode.style.cursor = (SZN.Browser.client == "ie") ? 'pointer' : "hand";
	}
	this.gallery.bindElement(SZN.gEl(this.imgId),this.startPos);
}

SZN.GalleryMaker.prototype._buildSingle = function(){
	this._activate();
};

SZN.GalleryMaker.prototype._buildGallery = function(){
	this._activate();
};

SZN.GalleryMaker.prototype._activate = function(){
	
	this.addListener('show','_hideElements');
	this.addListener('closed','_showElements');
	
	if((SZN.Browser.client == 'ie') && (SZN.Browser.version < 7)){
		this._fakeActivate();
		return;
	}
	var nd = SZN.gEl('gallBox');
	if(nd){
		SZN.Events.addListener(nd,'mouseover',this,'_over');
		SZN.Events.addListener(nd,'mouseout',this,'_out');
	}
	

}
SZN.GalleryMaker.prototype._over = function(e,elm){
	SZN.gEl('gallBox').className = 'gallBox active';
}
SZN.GalleryMaker.prototype._out = function(e,elm){
	SZN.gEl('gallBox').className = 'gallBox pasive';
}

SZN.GalleryMaker.prototype._fakeActivate = function(){
	var node = SZN.cEl('img');
	node.width = 200;
	node.height = 36;
	node.src = '/static/images/empty.gif';
	node.title = 'Zobrazit galerii';
	node.style.cssText = 'position:absolute;top:0;left:0;width:200px;height:36px;cursor:hand;'
	node.alt="";
	SZN.Events.addListener(node,'mouseover',this,'_over')
	SZN.Events.addListener(node,'mouseout',this,'_out')
	if(SZN.gEl('gallBox')){
		var nd = SZN.gEl('gallBox').appendChild(node);
	}
};

SZN.GalleryMaker.prototype._hideElements = function(){
	for(var i = 0; i < this.elmsToHide.length; i++){
		var nds = document.getElementsByTagName(this.elmsToHide[i])
		for(var j = 0; j < nds.length; j++){
			if (SZN.Dom.getStyle(nds[j],'visibility') == 'hidden'){ continue; }
			nds[j].style.visibility = 'hidden';
			this.hideElements.push(nds[j]);
		}
	}
}

SZN.GalleryMaker.prototype._showElements = function(){
	for(var i = 0; i < this.hideElements.length; i++){
		this.hideElements[i].style.visibility = 'visible';
	}
	this.hideElements = [];
};

/* ozivim obrazky v tele clanku pokud jsou obaleny odkazem ukazujicim do noveho okna */

SZN.addPopupImages = SZN.ClassMaker.makeClass({
	NAME : 'SZN.addPopupImages',
	VERSION : '1.0',
	CLASS : 'class'
});
SZN.addPopupImages.prototype.$constructor = function(articleBoxId){
	this.box = SZN.gEl(articleBoxId);
	this.pictureConf = {
		useShadow: false,
		imagePath: '/frontend/img/shadow-',
		galleryClassName: 'lightBox',
		usePageShader: false,
		components: {
			anchorage: SZN.LightBox.Anchorage.Napoveda,
			main: SZN.LightBox.Main.Novinky,
			strip: SZN.LightBox.Strip,
			pageShader: SZN.LightBox.PageShader,
			navigation: SZN.LightBox.Navigation.Basic,
			transition: SZN.LightBox.Transition,
			others: []
		},
		anchorageOpt: {},
		mainOpt: {className:'singlePicture',useMouseWheelScroll:false},
		stripOpt: { className:'signglePictureStrip' },
		navigationOpt: {continuous: false, showDisabled:false}
	};
	var links = this.box.getElementsByTagName("a");
	for (var i=0;i<links.length;i++) {
		this.data = [];
		var a = links[i];
		var img = a.getElementsByTagName('img')[0];
		if(img){
			this.smallImgId = 'lightImg_'+i;
			img.id = 'lightImg_'+i;
			this.url_img = img.src;
			this.url_link = a.href;
			
			var bigImg = SZN.cEl('img');
			bigImg.src = this.url_link;
			
			var tile = bigImg;
			tile.style.visibility = 'hidden';
			tile.style.position = 'absolute';
			tile.style.top = '-1000px';
			tile.style.left = '-1000px';
			this.box.appendChild(tile);
			var closure = this._returnSmallImgId(this.smallImgId, this.url_img, this.url_link);
			this.loadAct = SZN.Events.addListener(tile, 'load', this, closure);
			/*var aaa = !tile.srcUrl || (tile.complete || (typeof tile.naturalWidth != "undefined" && tile.naturalWidth !== 0));*/
		}
	}
}
SZN.addPopupImages.prototype._returnSmallImgId = function(smallId, urlImg, urlLink){
	var imgId = smallId;
	var urlImg = urlImg;
	var urlLink = urlLink;
	return function(e,elm){
		this._getImgSizes(imgId, urlImg, urlLink, elm);
	}
}
SZN.addPopupImages.prototype._getImgSizes = function(id, urlImg, urlLink, elm){
	var smallImgId = id;
	var urlImg = urlImg;
	var urlLink = urlLink;
	var bw = elm.offsetWidth;
	var bh = elm.offsetHeight;
	this.data = [{
		small : { url : urlImg },
		big : { url : urlLink, width : bw, height : bh }
	}];
	this.box.removeChild(elm);
	new SZN.GalleryMaker('singleArticle',smallImgId,this.pictureConf,this.data);
}

