

function goPoll(code) {
	$('#poll-place').html(code);
}

$(document).ready(function(){
	// галлерейное изображение
	$("a[rel=gallery]").fancybox({
		'opacity'		: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition' : 'over',
		'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over"><a href="' + currentOpts.href+'" target="_blank" style="float:right">оригинал (<span style="font-size:9px;">'+currentOpts.width+'x'+currentOpts.height+'</span>)</a>' + (currentIndex + 1) + ' из ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	// upload page
	$("a.upld").fancybox({
		'titleShow'		    : false,
		'width'				: '50%',
		'height'			: '60%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	// adminpanel
	$("a#adminpanel").fancybox({
		'titleShow'		    : false,
		'width'				: '80%',
		'height'			: '95%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});
	// login place
	$("#logbut").fancybox({
		'scrolling'		: 'no',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titleShow'		: false,
		'showCloseButton':false
	});
	// registration place
	$("#regbut").fancybox({
		'scrolling'		: 'no',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titleShow'		: false,
		'showCloseButton':false
	});
	// loading polls
	$('#poll-place').load('/system/vote.php');
	// выпадающие инфо
	$('.file_table td a').hover( function(){
			$('.file_table .pre').hide();
			$(this).parent().find('.pre').slideDown(200);
		}, function(){ $(this).parent().find('.pre').slideUp(100); }
	);
	// механика спойлера
	$('.bb-spoiler-head').click(function(){
		if($(this).children('img').attr('src') === spoiler_image_minus) {
			$(this).children('img').attr('src',spoiler_image_plus);
			$(this).removeClass('bb-spoiler-head-hide');
			$(this).parent().children('div.bb-spoiler-body').hide();
		} else  {
			$(this).children('img').attr('src',spoiler_image_minus);
			$(this).addClass('bb-spoiler-head-hide');
			$(this).parent().children('div.bb-spoiler-body').show();
		}
		return false;
	});
	// Автоселект ссылок
	$('.links input[type=text]').click(function(){ $(this).select(); });	
	// комменты, панель кнопок
	$('.comment').hover(function(){
		$(this).find('.controls:first').stop(true, true);
		$(this).find('.controls:first').show();
		},function() {	$(this).find('.controls:first').hide(); }
	);
	// редактирование коммента
	$('.controls a.edit').click(function(){
		var obj = $(this).parent().parent();
		var post = obj.parent().attr('id');
		obj.find('.text').html('loading...');
		$.post('/system/ajax.php',
			{code:01,post:post},
			function(txt){obj.find('.text').html(txt);}
		);
	});
	// удаление коммента
	$('.controls a.delete').click(function(){
		var obj = $(this).parent().parent();
		var post = obj.parent().attr('id');
		obj.find('.text').html('loading...');
		$.post('/system/ajax.php',
			{code:04,post:post},
			function(txt){obj.find('.text').html(txt);}
		);
	});
	// ответ на коммент
	$('.controls a.reply').click(function(){
		$('span.reply-place').empty();
		var obj = $(this).parent().parent();
		var post = obj.parent().attr('id');
		obj.find('span.reply-place').html('loading...');
		$.post('/system/ajax.php',
			{code:05,post:post},
			function(txt){obj.find('span.reply-place:first').html(txt);}
		);
	});
	// запросы, ответ
	$('.controls a.replyneed').click(function(){
		$('span.reply-place').empty();
		var obj = $(this).parent().parent();
		var post = obj.parent().attr('id');
		obj.find('span.reply-place').html('loading...');
		$.post('/system/ajax.php',
			{code:'rneed',post:post},
			function(txt){obj.find('span.reply-place:first').html(txt);}
		);
	});
});
// Обратная связь
function pbreak_form() {
	window.open('/system/pbreak.php', '_postbreak', 'toolbar=0,location=0,status=0, left=0, top=0, menubar=0,scrollbars=yes,resizable=0,width=640,height=510');    
}
function loadBar(i){
	if(i===1){
		maskHeight = $(document).height();
		maskWidth = $(window).width();
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		winH = $(window).height();
		winW = $(window).width();
		var win = $('#loading');	
		var top = winH/2-win.height()/2-100;
		if(top < 5) {
			top=5;
		}
		var left = winW/2-win.width()/2;
		win.css('top', top);
		win.css('left', left);
		$('#mask').show();
		$('#loading').css('visibility','visible');
	} else {
		$('#mask').hide();
		$('#loading').css('visibility','hidden');
	}
}
