$(function(){

	{	// формы добавления работ
		
		$('#addwork_form TR:nth-child(even)').addClass('even');
		$('#addwork_form input[name=file]').parents('TR').addClass('even');
		
		
	}
	
	
	{	// обработка формы регистрации
		
		$('input[name=lico]').click(function () {

			var _countSep = 0,
				_this = this;
			
			$('.fields_content tr').each(function () {

				if ($('.separator', this).length) {
					_countSep++;
				}
				
				if (2 == _countSep) {
					if ('fizic' == $(_this).val()) {
						$(this).hide();
					}
					else {
						$(this).show();
					}
				}
				
			});
		
		});

		if ($('input[name=lico]:checked').length) {
			$('input[name=lico]:checked').click();
		}
		else {
			$('input[name=lico]:last').click();
		}		

	}
	
	
	$(window).resize(onResize);
	onResize();
	
	{	/* рубрикатор конкурсов  */
		
		$('.competition_rubrics a').click(function () {
			
			var _parent = $(this).parents('LI:first');
		
			if ($(this).is('.minus')) {
				$('>UL', _parent).slideUp();
				$('.descr', _parent).slideUp();
				$(this).addClass('plus').removeClass('minus');
			}
			else {
				$('>UL', _parent).slideDown();
				$('.descr', _parent).slideDown();
				$(this).addClass('minus').removeClass('plus');
			}

			if ($('>UL', _parent).length) {
				return false;
			}

		});
		
	}
	
});

function onResize(){
	
	var h = $('.main').height();
	var w = $('.main').width();
	
	/* place left and right column's content as vertical-align: middle */
	var hh = (h-640)/2;
	$('.mainLeft .inner').css({'padding-top': hh*.4});
	$('.mainRight .inner').css({'padding-top': hh*.4});
	
	$('.mainLeft .inner').css({'min-height': h-hh*.8});
	$('.mainRight .inner').css({'min-height': h-hh*.8});
	
	/* trace height and width */
	// $('.mainCenter .content .trace').html(h+' x '+w);
	
	
	/*  resizing scrollable block */
	$('.scrollCenter').height(0); // reset scrollable block  height 
	if ( h <= 640 ){
		h = 640;
	} 
	if ( h >= 790 ){
		if ( h <= 830 ){
			$('.scrollCenter').height(h-(h-730)/2);
			$('.mainCenter .content').css('padding-top', (h-830)/2+80);
			$('.mainCenter .content').css('padding-bottom', 100);
			$('.scrollTop').css('height', 34-(730-h)/2);
			$('.scrollBottom').css('height', 91);
		} else {
			$('.scrollCenter').height(790);
			$('.mainCenter .content').css('padding-top', 90);
			$('.mainCenter .content').css('padding-bottom', 100);
			$('.scrollTop').css('height', 94);
			$('.scrollBottom').css('height', 91);
		}
	} else {
		if ( h >= 730 ){
			$('.scrollCenter').height(h-(h-730)/2);
			$('.mainCenter .content').css('padding-top', (h-830)/2+80);
			$('.mainCenter .content').css('padding-bottom', 100);
			$('.scrollTop').css('height', 34-(730-h)/2);
			$('.scrollBottom').css('height', 91);
		} else {
			$('.scrollCenter').height(h);
			$('.mainCenter .content').css('padding-top', (h-830)/2+80);
			$('.mainCenter .content').css('padding-bottom', (h-830)/2+150);
			$('.scrollTop').css('height', 0);
			$('.scrollBottom').css('height', 91-(730-h)/2);
		}
	}
	if ( h >= 830 ){
		var hhh = -790/2-30;
		$('.mainCenter').css('margin-top', hhh);
		
	} else {
		$('.mainCenter').css('margin-top', -h/2);
	}
	/* */
	
	// var s =$('.scrollTop').height();
	// $('.scrollTop').html(s);
	
	if($.flash.version.major > 9 && $('#intro .flash').length){
		$('#intro .flash').flash({
			swf: _root + 'public/flash/intro.swf',
			width: 100+'%',
			height: 100+'%',
			wmode: 'opaque', 
			bgcolor: '#000', 
			flashvars:{
				redirectURL: _redirectURL
			}
		}
	)};
	
}

