function onloadfunc()
{
	$$('.rating a').each(function(el){
		el.addEvent('mouseover', function(){
			this.getElements('img').each(function(child) {child.set('src', '/assets/media/star1.gif');});
		}.bind(el));
		el.addEvent('mouseout', function(){
			this.getElements('img').each(function(child) {child.set('src', '/assets/media/star.gif');});
		}.bind(el));
	});
	
	$$('.rat img').each(function(el){
		el.addEvent('mouseover', function(){
			this.set('src', '/assets/media/star1.gif');
		}.bind(el));
		el.addEvent('mouseout', function(){
			this.set('src', '/assets/media/star.gif');
		}.bind(el));
	});
	
	/*$$('.head .avtoris form input').each(function(el) {
		el.addEvent('click', function () {
			this.getNext('.avtoris-select').setStyle('display', 'block');
		}.bind(el));
	});*/
	
	$$('.submenu li').each(function(el) {
		el.addEvent('mouseover', function() {
			var ch = this.getFirst('ul.subsub');
			if (ch)
				ch.setStyle('display', 'block');
		}.bind(el));
		
		el.addEvent('mouseout', function() {
			var ch = this.getFirst('ul.subsub');
			if (ch)
				ch.setStyle('display', 'none');
		}.bind(el));
	});
	initSlimbox();
	
	$$('a.encmail').each(function(item){
		alert(item);
		item.addEvent('click', function(){
			window.location = 'mailto:admin@dm-b.net';
			return false;
		});
	});
}

function initSlimbox()
{
	$$("a[class*=slimbox]").slimbox({
		loop: false,
		overlayOpacity: 0.6,
		overlayFadeDuration: 200,
		}, function(el) {
			var imgEl = el.getElement('img');
			var srcStr = imgEl.get('src').replace(/^\/imagecache\/[^\/]+\//, '/assets/images/');
			var link_str = "<a href=\"" + srcStr + "\" target=\"_blank\">Прямая ссылка</a>";
			var t = el.title || imgEl.alt;
			t += (t ? "<br />" : "") + link_str;
			return [srcStr, t];
		}
	);
}

function refreshCaptcha()
{
	var r = Math.floor(Math.random() * 10000000);
	if ($('captcha_pic'))
		$('captcha_pic').set('src', '/manager/includes/veriword.php?rand=' + r);
}

function showOverlay(overlayID)
{
	var content = $(overlayID);
	if (!content)
		return;
	if (!winOverlay)
		winOverlay = new RepostOverlay();
	winOverlay.setContent(content);
	winOverlay.show();
}

var tabs = {
	'repost' : ['code', 'result']
};
function switchTab(set, tab)
{
	var tabSet = tabs[set];
	if (!tabSet)
		return;
	tabSet.each(function(item){
		$('tab_' + item).removeClass('activ');
		$('tab_' + item + '_content').setStyle('display', 'none');
	});
	$('tab_' + tab).addClass('activ');
	$('tab_' + tab + '_content').setStyle('display', '');
}

