/*
 * Copyright by Daken, 2011
 * mailto:me@daken.ru
 * http://www.daken.ru
 *
*/

var currentHowStep = 1;

$(document).ready(function(){
    $('#optimiz').click(function(){
        $('#keywords-wrapper').slideToggle(500);
    });
    if($('#optimiz').is(':checked')){

    }else{
        $('#keywords-wrapper').slideUp(1);
    }

    $('#images-switch').click(function(){
        if($(this).hasClass('active'))
            return false;
        $(this).addClass('active');
        $('#list-switch').removeClass('active');
        $('#portfolio-list').fadeOut(500, function(){
            $('#portfolio-images').fadeIn(500);
        });

        //$('#portfolio-list').hide();
        return false;
    });

    $('#list-switch').click(function(){
        if($(this).hasClass('active'))
            return false;
        $(this).addClass('active');
        $('#images-switch').removeClass('active');
        $('#portfolio-images').fadeOut(500, function(){
            $('#portfolio-list').fadeIn(500);
        });

        //$('#portfolio-images').hide();
        //$('#portfolio-list').show();
        return false;
    });

    $('.how-next').click(function(){
        $('#step-'+currentHowStep).fadeOut(500, function(){
            currentHowStep += 1;
            $('#step-'+currentHowStep).fadeIn(500);
        });
        return false;
    });

    $('.how-prew').click(function(){
        $('#step-'+currentHowStep).fadeOut(500, function(){
            currentHowStep -= 1;
            $('#step-'+currentHowStep).fadeIn(500);
        });
        return false;
    });

    $('.menuitem_glow').mouseover(function() {
        $(this).attr('animating', 1);
        var id = $(this).attr('id');

        $('#' + id).stop();
        $('#' + id).animate({opacity: 1.0}, 250);
    });
    $('.menuitem_glow').mouseout(function(e) {
        $(this).attr('animating', 1);
        var id = $(this).attr('id');
        $('#' + id).stop();
        $('#' + id).animate({opacity: 0}, 250);
    });

    //setInterval("nextSlide()", 1000);
    $('#benefits-wrapper .selected a').click();
    //$('#benefits-wrapper').trigger( 'start' );
});

function nextSlide(){
    var id = $('#benefits-wrapper .selected a').attr('href').split('-');
    id[1] = parseInt(id[1]) + 1;
    if(id[1] >= 5)
        id[1] = 1;
    data = new Object;
    data.id = "#benefit-" + id[1];

    console.log(data.id);
    trigger(data);
}

function toggleCat(year){
	if (year){
		$('.portfolio-year:visible').fadeOut(500, function(){
			$('#py-' + year).fadeIn(500);
		});
		$('#portfolio-switch a').removeClass('active');
		$('#p-'+year).addClass('active');
	}
	else{
		$('.portfolio-year:visible').fadeOut(500, function(){
			$("div[id^='py-']").fadeIn(500);
		});
		$('#portfolio-switch a').removeClass('active');
		$('#p-all').addClass('active');
		
	}
}
