$(function() {
// *******************************************************
// *********  MAIN PAGE, GALLERY
// *******************************************************
	$('.gallery ul').css({width: $('.gallery li').length*90+'px'});
	$('.gallery li').each(function() {
		$(this).find('a').append('<i></i>');
	});
	function scroll_main_gallery() {
		$('.gallery ul').animate({left: '-90px'}, 1000, 'easeInOutExpo', function() {
			$(this).find('li:first').clone().appendTo($(this)).end().end().remove();
			$(this).css({left: 0});
			$(this).delay(1500).each(function() {
				scroll_main_gallery();
			});
		});
	}
	scroll_main_gallery();
// *******************************************************
// *********  MAIN PAGE, ACCORDION
// *******************************************************
	$('.accordion').accordion({
		header: '.title',
		autoheight: false,
		fillSpace: false,
		event: 'mouseenter',
		active: false,
		changestart: function(event, ui) {
			if(ui.newHeader.text()!='') {
				$('.acc_items', this).animate({paddingBottom: '7px', paddingTop: '7px'}, 200);
			} else {
				$('.acc_items', this).animate({paddingBottom: '17px', paddingTop: '17px'}, 200);
			}
		},
		change: function(event, ui) {
		}
	}).bind('mouseleave', function() {
		$(this).accordion('activate', -1);
	});
// *******************************************************
// *********  TABLE DECORATING
// *******************************************************
/*
	$('table.decorated').each(function() {
		$(this).wrap('<div style="width: '+$(this).width()+'px"></div>');
	});
	$('table.decorated tr th:first').append('<div class="first_corner"/>');
	$('table.decorated tr th:last').append('<div class="last_corner"/>');
	$('table.decorated td').css({border: '1px dotted #1a2227'});
	$('table.decorated tr td').parent().each(function() {
		$(this).first().find('td').css({borderTop: '1px solid #f00', background: '#f00'})
	});
*/
// *******************************************************
// *********  RADIOBOX
// *******************************************************
	$(".radio input:radio").css({opacity: '0'}).bind('change click', function() {
		$(this).parent().parent().find('.radiobox_').attr('class', 'radiobox');
		if(this.checked) {
			this.parentNode.className='radiobox_';
		} else {
			this.parentNode.className='radiobox';
		}
	}).parent().attr('class', 'radiobox');
	$(".radio input:radio:checked, .radiobox input:radio:checked").parent().attr('class', 'radiobox_');
});
