$(document).ready(function() {
    $(".streetExpand").click(function() {
        $(this).parent().next().slideToggle();
    });

    $(".addressExpand").hover(function() {
        $('.addressExpand').css("cursor","pointer");
    });

    $(".addressExpand").click(function() {
        $('#hidden').slideToggle();
    });


    $(".icon_block").each(function(index) {
        if($(this).hasClass("last") === false) {
            if(index == 4) index = 3;
            $(this).css({left: index*210 + "px", top: 0});
        }
    });

    var animation = false;
    $(".icon_block .icon").mouseenter(function () {
//        $(this).parent().parent().addClass('expanded');
//        $(this).parent().parent().nextAll().animate({left: "+=200px"}, 200);
//        $(this).parent().parent().animate({'width': '400px'}, 225);
        //if(animation === false) {
            animation = true;
            $(this).parent().parent()
            .animate({'width': '400px'}, { queue:false, duration:200, complete: function () { animation = false; } })
            .nextAll().each(function() {
                var index = $(this).prevAll(".icon_block").length;
                $(this).animate({left: ((index+1)*210)-10 + "px"}, { queue:false, duration:200});
            });
        //}
	});
	
	$(".icon_block .icon").mouseleave(function () {
//        $(this).parent().parent().nextAll().animate({left: "-=200px"}, 200);
//        $(this).parent().parent().animate({'width': '200px'}, 200);
        //if(animation === false) {
            animation = true;
            $(this).parent().parent()
            .animate({'width': '200px'}, { queue:false, duration:200 })
            .nextAll().each(function() {
                var index = $(this).prevAll(".icon_block").length;
                $(this).animate({left: (index)*210 + "px"}, { queue:false, duration:200});
            });
        //}
	});
    
    $(".icon_block").filter(".last").children("div").children(".icon").unbind("mouseover");
    $(".icon_block").filter(".last").children("div").children(".icon").unbind("mouseout");

    $(".icon_block").filter(".last").children("div").children(".icon").children("img").mouseover(function() {
        $(this).parent().parent().parent().prevAll().each(function() {
                var index = $(this).prevAll(".icon_block").length;
                $(this).animate({left: ((index-1)*210)+10 + "px"}, { queue:false, duration:200});
            });
//        $(this).css({left: '0px'}).animate({'left': '-=200px'}, 200);
        $(this).parent().siblings(".text").animate({'left': '-200px'},  { queue:false, duration:200});
    });

    $(".icon_block").filter(".last").children("div").children(".icon").children("img").mouseout(function() {
        $(this).parent().parent().parent().prevAll().each(function() {
                var index = $(this).prevAll(".icon_block").length;
                $(this).animate({left: (index)*210 + "px"}, { queue:false, duration:200});
            });
//        $(this).children("div").children(".icon").css({left: '-200px'}).animate({'left': '+=200px'}, 200);
        $(this).parent().siblings(".text").animate({'left': '0px'},  { queue:false, duration:200});
    });

//    $(".icon_block").filter(".last").children("div").children(".icon").mouseout(function() {
//        $(this).parent().parent().prevAll().animate({left: "+=200px"}, 200);
//        $(this).css({left: '-200px'}).animate({'left': '+=200px'}, 200);
////        $(this).siblings(".text").css({left: '-200px'}).animate({'left': '+=200px'}, 200);
//    });
});

