function act(totok){
	if (totok.className.indexOf('act') < 0){
		totok.className += ' act';
	} else {
		totok.className = totok.className.replace(/\bact\b/,'');
	}
}

function switchdiv(totok,idlink,iddiv1,iddiv2){
	var div1 = $(iddiv1);
	var div2 = $(iddiv2);
	var link = $(idlink);

	if (totok.className){
		totok.className = '';
	} else {
		totok.className = 'act';
	}

	if (link.className){
		link.className = '';
	} else {
		link.className = 'act';
	}

	if (div1.style.display){
		if (div1.style.display == 'none'){
			div1.style.display = 'block';
		}
	}

	if (div2.style.display){
		if (div2.style.display == 'block'){
			div2.style.display = 'none';
		}
	}
	return false;
}

function randomXToY(minVal,maxVal,floatVal){
	var randVal = minVal+(Math.random()*(maxVal-minVal));
	return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
}

function shop_slide(){
	var cells = $$('#shop_slide div.cell');
	if (cells.length > 1){
		for(var i=0;i<cells.length;i++){
			if (cells[i].style.opacity == 1){
				cells[i].set('tween',{duration: 2000});
				cells[i].tween('opacity',0);
				//cells[i].style.zIndex = '99';
				//cells[i].fx = new Fx.Style(cells[i], 'opacity', {duration: 2000}).start(0);
				if (i==cells.length-1){
					//cells[0].style.zIndex = '100';
					//cells[0].fx = new Fx.Style(cells[0], 'opacity', {duration: 2000}).start(1);
					cells[0].set('tween',{duration: 2000});
					cells[0].tween('opacity',1);
				} else {
					//cells[i+1].style.zIndex = '100';
					//cells[i+1].fx = new Fx.Style(cells[i+1], 'opacity', {duration: 2000}).start(1);
					cells[i+1].set('tween',{duration: 2000});
					cells[i+1].tween('opacity',1);
				}
				break;
			}
		}
	}
	setTimeout("shop_slide()",1000*10);
}

window.addEvent('domready', function() {
	var slide = $('shop_slide');

	if (slide){
		
		var cells = $$('#shop_slide div.cell');
		var rand_no = randomXToY(1,cells.length) -1;
		for (var i=0;i<cells.length;i++){
			cells[i].set('tween',{duration: 1});
			if (i==rand_no){
				cells[i].tween('opacity',1);
			} else {
				cells[i].tween('opacity',0);
			}
		}
		slide.style.display = 'block';
		shop_slide();
	}
});

var BASE_IMG = 0;

function switchImages(src,fgId,bgId){
	var fg = $(fgId);
	var bg = $(bgId);
	var tmpsrc = fg.src;
		if (BASE_IMG == 0){
				bg.src = src;
				fg.set('tween',{duration:1000});
				fg.tween('opacity',0);
				bg.set('tween',{duration:1000});
				bg.tween('opacity',1);
				BASE_IMG = 1;
		} else {
				fg.src = src;
				bg.set('tween',{duration:1000});
				bg.tween('opacity',0);
				fg.set('tween',{duration:1000});
				fg.tween('opacity',1);
				BASE_IMG = 0;
		}
	/*fg.fx = new Fx.Style(fg,'opacity',{duration: 2000}).start(0);
	bg.fx = new Fx.Style(fg,'opacity',{duration: 2000}).start(1);*/
}


//accordion
window.addEvent('domready', function() {
	//create our Accordion instance
		var url_last = '';
		var ind = location.href.indexOf('#');
		if (ind >= 0 ){
			url_last = location.href.substr(ind+1);

		}

		if ($('accordion')){
		var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
			opacity: false,
			onActive: function(toggler, element){
				toggler.setStyle('color', '#41464D');
			},
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#528CE0');
			}
		});
		if (url_last){
			var els = $('accordion').getElementsByTagName('h3');
			for (var i=0;i<els.length;i++){
				if (els[i].id == url_last){
					myAccordion.display(i);
				}
			}
		}
		}
});

window.addEvent('domready', function() {
	var ii = $$('.eml');
	if (ii){
		for (var i=0;i<ii.length;i++){
			var rp = ii[i].innerHTML.replace(/(.*)\[zavinac\](.*)\[bodka\](.*)/gi, "\$1@\$2.\$3");
			ii[i].innerHTML = '<a href="mailto:'+rp+'">'+rp+'</a>';
			ii[i].style.visibility = 'visible';
		}
	}
});

function hvr(totok){
	if (totok.className.indexOf('hover') == -1){
		totok.className += ' hover';
	} else {
		totok.className = totok.className.replace(/\bhover\b/,''); 
	}
}

function popimage(chemin,title,sirka,vyska){
	i1 = new Image;
	i1.src = chemin;
	html = '<html><head><title>'+title+'</title></head><body style="vertical-align: middle; text-align: center; background: #000000; margin: 0px; padding: 0px; ""><a href="#" onclick="window.close()"><img id="obr" src="'+chemin+'" style="border: 0px; padding: 0px; margin: 0px" name="ImageMax" onLoad="window.resizeTo(document.ImageMax.width+10,document.ImageMax.height+30);" /></a></body></html>';
	popupImage = window.open('','image','width='+sirka+',height='+vyska+',toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,status=1');
	popupImage.document.open();
	popupImage.document.write(html);
	popupImage.document.close();
	return false;
}

