
var site = {
	scroll: undefined,
	move: function(dir) {
		//if(dir == "right" && window.scrollX <= 10) return false;
		//if(dir == "left" && mouse.overLeft == false) return false;
		
		if(dir == "left")
			var target = this.divs.rotate(-1)[0];
		else
			var target = this.divs.rotate(1)[0];
		site.scroll = $(window).scrollTo(
			target, 800,
			{
				target: target,
				axis: 'x',
				offset: {left:-153, top:0},
			}
		);
		//this.divs = this.divs.removeDuplicates();
	},
	divs: ['.portfolio-col.packaging','.portfolio-col.print', '.portfolio-col.web','.portfolio-col.video', '.portfolio-col.branding','.portfolio-col.packaging']
};

$(document).ready(function() {
	$("#nav-right").bind('click', function(e) {
		site.move("right");
	});
	$("#nav-left").bind('click', function(e) {
		site.move("left");
	});
	$("#view-portfolio").bind('click', function(e) {
		
		$(window).scrollTo(
			'#portfolio-nav', 800,
			{
				axis: 'x',force:true
			}
		);
	});
	$('#logo').bind('click', function(e){
		
		$(window).scrollTo(
			'#container', 800,
			{
				axis: 'x'
			}
		);
	});
	$("a[rel='portfolio']").colorbox({iframe: true,innerWidth:'1014px',innerHeight:'680px' });
        $('#header_resume').toggle(function() {
    
            $('#info_resume').animate({
                bottom: '+=457'
            }, 'slow', 'swing', function() {
				$('#header_resume').addClass('open');
                // Animation complete. CALLBACK?
            });
    
        }, function() {
    
            $('#info_resume').animate({
                bottom: '-=457'
            }, 'slow', 'swing', function() {
				$('#header_resume').removeClass('open');
                // Animation complete. CALLBACK?
            });
        });
        $('#header_contact').toggle(function() {
    
            $('#info_contact').animate({
                bottom: '+=48'
            }, 'slow', 'swing', function() {
				$('#header_contact').addClass('open');
                // Animation complete. CALLBACK?
            });
    
        }, function() {
    
            $('#info_contact').animate({
                bottom: '-=48'
            }, 'slow', 'swing', function() {
				$('#header_contact').removeClass('open');
                // Animation complete. CALLBACK?
            });
        });
        $('#header_about').toggle(function() {
    
            $('#info_about').animate({
                bottom: '+=580'
            }, 'slow', 'swing', function() {
				$('#header_about').addClass('open');
                // Animation complete. CALLBACK?
            });
    
        }, function() {
    
            $('#info_about').animate({
                bottom: '-=580'
            }, 'slow', 'swing', function() {
				$('#header_about').removeClass('open');
                // Animation complete. CALLBACK?
            });
        });
});
Array.prototype.rotate = (function() {
    var unshift = Array.prototype.unshift,
        splice = Array.prototype.splice;

    return function(count) {
        var len = this.length >>> 0,
            count = count >> 0;

        unshift.apply(this, splice.call(this, count % len, len));
        return this;
    };
})();
Array.prototype.removeDuplicates = function (){
	var temp=new Array();
	this.sort();
	for(i=0;i<this.length;i++){
		if(this[i]==this[i+1]) {continue}
			temp[temp.length]=this[i];
	}
	return temp;
} 

