$(
function(){
	// menu
	$('#menuul').find('.first ul').hide();
	$('#menuul').find('.first act').find('ul').show();

	$('#menuul').find('.first').each(function(){
		var cName=$(this).attr('class');
		cName=cName.split('first').join('');
		$(this).attr('class',cName);
		//alert(cName);
	});
	$('#menuul').find('li').find('ul').each(function(){
		$(this).parent('li').attr('class',$(this).parent('li').attr('class')+' first');
		$(this).parent('li').find('a:first').replaceWith($(this).parent('li').find('a').html());
	});

	// click
	$('#menuul').find('li.first').click(function(){
		if($(this).attr('class')!='first open'){
			$('#menuul').find('.open').attr('class','first').find('ul').slideUp();
			$(this).find('ul').slideDown();
			$(this).attr('class','first open');
		}
	});
	// slide
	slideFlag=false;
	$('#slide').find('.l,.r').mouseover(function(){
		$(this).css('opacity',1.0);
	}).mouseleave(function(){
		$(this).css('opacity',0.5);
	}).click(function(){
		switch($(this).attr('class')){
			case 'pa r':
				var type='r';
				break;
			default:
				var type='l';
				break;
		}
		slideIt(type);
	});
	// speed
	SPEED=400;
	// ������� �����?
	N=$('#slide').find('img').size();
	function slideIt(type){
		// ������� ������� ���� || 
		var L=parseInt($('#slide').find('#move').css('left'));
		switch(type){
			case 'r':
				l=-L<220*(N-1)?"-=220px":"0px";
				break;
			case 'l':
				l=L!=0?'+=220px':-220*(N-1)+'px';
				break;
		}
		if(!slideFlag) $('#slide').find('#move').animate({left: l},SPEED);
		slideFlag=true;
		setTimeout(function(){slideFlag=false;},SPEED);
	}
	// autoslide
	setInterval(function(){slideIt('r');},4000);
	// menu_btm
	$('#polka .item').mouseover(function(){
		$(this).find('.arrow').css({backgroundPosition:'0px 0px'});
	}).mouseleave(function(){
		$(this).find('.arrow').css({backgroundPosition:'-21px 0px'});
	});
	
	// slideshow
	$('#inputn').val(1);
	$('#slideshow').find('#desc').html(
		$('#slideshow').find('#desc'+$('#slideshow').find('img.act').attr('id')).html()
	);
	ARR=$('#slideshow').find('img');
	SN=ARR.length;
	
	// ����� �������
	SlideShowInterval=6000;
	SSINT=setInterval(function(){startSlideshow('r');},SlideShowInterval);
	// slideshow btn
	$('#slideshow .btn').mouseover(function(){
		$(this).animate({opacity:0.8},200);
	}).mouseleave(function(){
		$(this).animate({opacity:0.5},400);
	});
	$('#slideshow .btn').find('.l, .r').mouseover(function(){
		$(this).animate({opacity:1.0},200);
	}).mouseleave(function(){
		$(this).animate({opacity:0.5},200);
	}).click(function(){
		var type='';
		switch($(this).attr('class')){
			case 'l pa':
				type='l';
				break;
			default:
				type='r';
				break;
		}
		clearInterval(SSINT);
		
		startSlideshow(type);
		SSINT=setInterval(function(){startSlideshow('r');},SlideShowInterval);
	});
});
// slideshow function
oldType='';
function startSlideshow(type){
	n=parseInt($('#inputn').val());
	$('#slideshow').find('img.act').animate({opacity:0.0},300);
	switch(type){
		case 'r':
			n<(SN-1)?nn=n+1:nn=0;
			break;
		case 'l':
			n>0?nn=n-1:nn=SN-1;
			//oldType!=type?nn-=1:nn=nn;
			break;
	}
	setTimeout(function(){
		$('#slideshow').find('img.act').hide().attr('class','');
		$(ARR[n]).css({opacity:0.0}).show().animate({opacity:1.0},300).attr('class','act');
		$('#slideshow').find('#desc').html(
			$('#slideshow').find('#desc'+$(ARR[n]).attr('id')).html()
		);
	},300);
	$('#inputn').val(nn);
	oldType=type;
}












