jQuery.fn.eachDelay = function (callback, speed) {
    return jQuery.eachDelay(this, callback, speed)
}
jQuery.extend({
    eachDelay: function (object, callback, speed) {
        var name, i = -1,
            length = object.length,
            $div = $('<div>'),
            id;
        if (length === undefined) { //not an array process as object
            var arr = [],
                x = -1;
            for (name in object) arr[++x] = name;
            var id = window.setInterval(function () {
                if (++i === arr.length || callback.call(object[arr[i]], arr[i], object[arr[i]]) === false) clearInterval(id);
            }, speed);
        } else { //array-compatible element ie. [], jQuery Object
            var id = window.setInterval(function () {
                if (++i === object.length || callback.call(object[i], i, object[i]) === false) clearInterval(id);
            }, speed);
        }
        return object;
    }
});
$(document).ready(function () { /* HOME */
    $('.info').hide();
    $('.first').delay(300).animate({
        width: '250px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('.first .info').delay(1000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('.second').delay(700).animate({
        width: '250px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('.second .info').delay(1300).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('.third').delay(1200).animate({
        width: '420px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('.third .info').delay(1700).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    }); /* END HOME */
    /* BEGIN PORTFOLIO */
    $('.summary').hide();
    $(function () {
        $('#portfolio li').hover(function () {
            $(this).find('.summary').fadeIn('fast');
        }, function () {
            $(this).find('.summary').fadeOut();
        });
    });
    $('.thumb').eachDelay(function () {
        $(this).animate({
            height: '130px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
    }, 80);
    $('.thumb .info').eachDelay(function () {
        $(this).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
    }, 200); /* END PORTFOLIO */
    /* SINGLE PORTFOLIO */
    $('#single').delay(500).animate({
        height: '360px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#single .info').delay(1000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    }); /* END SINGLE PORTFOLIO */
    /* PROFILE */
    $('#Profile').delay(500).animate({
        height: '360px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Profile .info').delay(1000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Profile .info').queue(function () {
        $('#Profile li.wd').animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.wd span').delay(300).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        }); /**/
        $('#Profile li.wp').delay(200).animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.wp span').delay(500).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        }); /**/
        $('#Profile li.md').delay(300).animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.md span').delay(600).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        }); /**/
        $('#Profile li.so').delay(400).animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.so span').delay(700).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        }); /**/
        $('#Profile li.ac').delay(500).animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.ac span').delay(800).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        }); /**/
        $('#Profile li.dp').delay(500).animate({
            width: '250px'
        }, {
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
        $('#Profile .alignright li.dp span').delay(800).fadeIn({
            duration: 'slow',
            easing: 'easeInOutExpo'
        });
    }); /* END PROFILE */
    /* CONTACT */
    $('#Contact').delay(500).animate({
        height: '360px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Contact .info').delay(1000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    }); /* END CONTACT */
    /* WHAT WE DO */
    $('#Whatwedo').delay(500).animate({
        height: '360px'
    }, {
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Whatwedo .info').delay(1000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Whatwedo .info .box4').delay(1500).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Whatwedo .info .box3').delay(2000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Whatwedo .info .box2').delay(2500).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    });
    $('#Whatwedo .info .box1').delay(3000).fadeIn({
        duration: 'slow',
        easing: 'easeInOutExpo'
    }) /* END WHAT WE DO */
    $(window).resize(function () {
        $('.container').css({
            position: 'absolute',
            left: ($(window).width() - $('.container').outerWidth()) / 2,
            top: ($(window).height() - 35 - $('.container').outerHeight()) / 2
        });
    });
    $(window).resize();
});
