$(document).ready(function()
{
	/*
	// Меню
	$('.menu_tree li').each(function()
	{
		if($(this).children('ul').html())
		{
			$(this).children('ul').hide();
			$(this).prepend('<div class="menu_tree_plus"></div>');
		} else {
			$(this).prepend('<div class="menu_tree_blank"></div>');
		}
	});

	$('.menu_tree_plus').click(function()
	{
		if($(this).attr('class') == 'menu_tree_plus')
			$(this).removeClass('menu_tree_plus').addClass('menu_tree_minus').next().next().show();
		else
			$(this).removeClass('menu_tree_minus').addClass('menu_tree_plus').next().next().hide();
	});
	
    $('a[href="/'+curent_url+'/"]').attr({actived:'actived'});
    $('.menu_tree [actived="actived"]').addClass('menu_tree_actived').next().show();
    $('.menu_tree [actived="actived"]').prev().removeClass('menu_tree_plus').addClass('menu_tree_minus');
    $('.menu_tree [actived="actived"]').parents('ul').show();
	*/

	// Портфолио
	var i = 0;

	$('#portfoller_favs a').each(function()
	{
		$(this).css({ left:'-'+(i * 7)+'px' });
		if((i + 1) == $('#portfoller_favs').children('a').length)
			$(this).addClass('portfoller_fav_act');
		else
			$(this).addClass('portfoller_fav');
		i++;
	});
	i = 0;
	
	$('#portfoller_favs a').click(function()
	{
		$('#portfoller_favs .portfoller_fav_act').removeClass('portfoller_fav_act').addClass('portfoller_fav');
		$(this).removeClass('portfoller_fav').addClass('portfoller_fav_act');
		portfoller_load();
	});

	var portfoller_dw = 280,
		portfoller_dwr;

	$('#portfoller_data #preload').animate({opacity:'.0'}, function(){ portfoller_load(); });
	
	function portfoller_load(a)
	{
		if($(window).width() > 1300) portfoller_dwr = 5;
		if($(window).width() > 1200 && $(window).width() < 1300) portfoller_dwr = 4;
		if($(window).width() > 950 && $(window).width() < 1200) portfoller_dwr = 3;
		if($(window).width() < 950) portfoller_dwr = 2;
		$('#portfoller_data').css({width:(portfoller_dw * portfoller_dwr) - 20});
	
		var ar = new Array();
		i = 0;

		ar = {
				0 : {
						'name' : '1 пример',
						'src' : 'im.png',
						'price' : 10000
					},
				1 : {
						'name' : '2 пример',
						'src' : 'im.png',
						'price' : 2000
					},
				2 : {
						'name' : '3 пример',
						'src' : 'im.png',
						'price' : 5000
					},
				3 : {
						'name' : '3 пример',
						'src' : 'im.png',
						'price' : 5000
					}
			}
		$('#portfoller_data').html('');

		for(var a in ar)
		{
			$('#portfoller_data').append('<div id="portfoller_el"><img src="images/'+ar[a]['src']+'" alt="'+ar[a]['name']+'" /></div>');
			i++;
			if(i >= portfoller_dwr) break;
		}
		i = (portfoller_dwr - 1);

		$('#portfoller_data #portfoller_el').css({opacity:'.0'});
		
		function portfoller_ef1(a, i)
		{
			$(a).animate(
			{
				opacity:'1',
				top:'+=220'
			}, 100, function()
			{
				$(a).children('img').animate(
				{
					width:224,
					height:218,
					marginTop:18,
					marginLeft:19
				}, function()
				{
					$(a).addClass('portfoller_el');
				});

				$(a).animate(
				{
					width:262,
					height:257,
					left:(280 * i),
					top:14
				}, 100, function()
				{
					i--;
					if($(a).prev().html()) portfoller_ef1($(a).prev(), i);
				});
			});
		}

		portfoller_ef1('#portfoller_data #portfoller_el:last', i);
	}
	
	/*
	$('#menu ul li a').click(function()
	{
		if($(this).next('ul').size()) return false;
		//if($(this).next('ul').size()) $(this).next('ul').slideToggle();
		if(!$(this).attr('href')) return false;
		//if($(this).next('ul').attr('class') == 'active' || !$(this).next('ul').size()) return false;
		//$('#menu ul.active').slideToggle().removeClass('active');
		//$(this).next('ul').slideToggle().addClass('active');
	});
	*/
});

