function str_replace(srch, need, subj){
	var re = new RegExp (srch, 'gi') ;
	var newstr = subj.replace(re, need) ;
	return newstr;
}



function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
		x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0){
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d)
		d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)
		x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById)
			x=d.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
		}
}

function overed(action, elem){
	el = document.getElementById(elem);
	if (el){
		if (action) el.style.display = 'block';
		else el.style.display = 'none';
	}
}

function saveank(aoid,ankid)
{
	var apath = location.href.split("#");
	var l = apath[0].length;
	var path = apath[0];
	if (apath[0].indexOf('?')>0)
	{
		if (apath[0].substring(l-1,l)!='?') path += '&';
	}
	else path += '?';
	path += "aoid="+aoid+"&ankid="+ankid;
	location.href = path;
}

function newsletter()
{
	var rex  = /^[-a-zA-Z0-9_.]+@[-a-zA-Z0-9_.]+\.[a-zA-Z]{2,4}$/;
	if (document.getElementById('newsletterjmeno').value=='' || document.getElementById('newsletterjmeno').value=='<?=_t("          name")?>') {alert('<?=_t("Empty name.")?>'); return 0;}
	if (document.getElementById('newsletteradr').value=='' || document.getElementById('newsletteradr').value=='<?=_t("   e-mail address")?>') {alert('<?=_t("Empty e-mail address.")?>'); return 0;}
	if (!rex.test(document.getElementById('newsletteradr').value)) {alert('<?=_t("Wrong format of your e-mail address.")?>'); return 0;}

	var apath = location.href.split("#");
	var l = apath[0].length;
	var path = apath[0];
	if (apath[0].indexOf('?')>0)
	{
		if (apath[0].substring(l-1,l)!='?') path += '&';
	}
	else path += '?';
	path += "newsletteradr="+document.getElementById('newsletteradr').value+"&newsletterjmeno="+document.getElementById('newsletterjmeno').value;
	location.href = path;
}

var new_img_idx = 1;
cur_op = 1;
new_op = 0;
var fade_step = 0.05;
var fade_duration = 1000;
var show_time = 8000;

function fade_img()
{
	cur_op -= fade_step;
	new_op += fade_step;

	if (cur_op < fade_step)
	{
		document.getElementById("cur_img").style.backgroundImage = document.getElementById("new_img").style.backgroundImage;
		set_opacity("cur_img", 1);
		document.getElementById("cur_img").innerHTML = document.getElementById("new_img").innerHTML;
		new_img_idx++;
		if (new_img_idx == imgs.length) new_img_idx = 0;
		document.getElementById("new_img").style.backgroundImage = "url('/img/rounded/panorama/" + imgs[new_img_idx] + "')";
		cur_op = 0.99; new_op = 0;
		setTimeout(fade_img, show_time);
	}
	else
	{
		set_opacity("cur_img", cur_op);
		set_opacity("new_img", new_op);
		setTimeout(fade_img, fade_duration * fade_step);
	}
}

function set_opacity(obj, op)
{
	document.getElementById(obj).style.opacity = op;
	document.getElementById(obj).style.MozOpacity = op;
	document.getElementById(obj).style.filter = "alpha(opacity=" + (op * 100) + ")";
}

var slide_imgs = 0;
var slideshow_act = '1';
var timeout;
var interval;

function slideshow_int()
{
	var i = parseInt(slideshow_act);
	i++;
	if (i > slide_imgs) i = 1;
	slideshow(i.toString(), false);
}

function slideshow(img, clearint)
{
	if (clearint) clearInterval(interval);
	document.getElementById("slideshow_img").src = '/images/slideshow/' + pgid + '/' + img + '.jpg';
	if (slideshow_act != img)
	{
		if (pgid == 1)
		{
			document.getElementById("nab_ucho_" + slideshow_act).className = "";
			document.getElementById("nab_ucho_" + img).className = "active";
		}
		slideshow_act = img;
	}
}

