﻿$(document).ready(function () {


//Turn on the lights
Shadowbox.init({
    handleOversize: "drag",
    overlayOpacity: 0.9,
    animSequence: "wh",
});

 Shadowbox.setup("a.actions", {
        gallery:        "actions",
        continuous:     true,
        counterType:    "skip"
    });  

	Shadowbox.setup("a.lithium", {
        gallery:        "lithium",
        continuous:     true,
        counterType:    "skip"
    });  
	
	Shadowbox.setup("a.titulo", {
        gallery:        "titulo",
        continuous:     true,
        counterType:    "skip"
    }); 
	
	Shadowbox.setup("a.pan", {
        gallery:        "pan",
        continuous:     true,
        counterType:    "skip"
    });
	
//show goods  	
	$("#foot").fadeTo(2000, 0); 	
	$('#mason .img-container').fadeIn(2000);
	$('#lang-choice').fadeIn(2000);    


    var
    speed = 1000;
    $wall = $('#mason');

    // sort goods
    $wall.masonry({
        columnWidth: 224,
        itemSelector: '.img-container:not(.invis)',
        animate: true,
        animationOptions: {
            duration: speed,
            queue: false,
            easing: 'linear'
        }
    });

	//Filter Goods - Masonry
    $('#filter a').click(function () {
        var filClass = '.' + $(this).attr('class');

        if (filClass == '.all') {
            // show all hidden boxes
            $wall.children('.invis').toggleClass('invis').fadeIn(speed);
        } else {
            // hide visible boxes 
            $wall.children().not(filClass).not('.invis').toggleClass('invis').fadeOut(speed);
            // show hidden boxes
            $wall.children(filClass + '.invis').toggleClass('invis').fadeIn(speed);
        }
        $wall.masonry();

        return false;
    });

    $(".box").hover(function () {
        $(".box").not(this).stop().fadeTo(500, 0.5);
    }, function () {
        $(".box").not(this).stop().fadeTo(500, 1);
    });    
	
	
	//language
	
	$("#lang-en").click(function(){
	$("body").changeLang({lang: "en", file: "lang.xml"}); 
	});

	$("#lang-es").click(function(){
	$("body").changeLang({lang: "es", file: "lang.xml"}); 
	});		
	//language iPhone
	$("#langen").click(function(){
	$("body").changeLang({lang: "en", file: "lang.xml"}); 
	});

	$("#langes").click(function(){
	$("body").changeLang({lang: "es", file: "lang.xml"}); 
	});	
	
	//Fade Footer 
		
    $("footer").hover(function () {
        $("#foot").stop().fadeTo(500, 1.0);
    }, function () {
        $("#foot").stop().fadeTo(800, 0);
    });

	//language Button Follows Screen
    var yOffset = $("#lang-choice").offset().top;
    $(window).scroll(function () {
        if ($(window).scrollTop() > yOffset) {
            $("#lang-choice").css({
                'top': 0,
				'right':26,
                'position': 'fixed'
            });
        } else {
            $("#lang-choice").css({
                'top': yOffset + 'px',
				'right':0,
                'position': 'absolute'
            });
        }
    });


	//Smooth Scrolling
    $.localScroll({
        queue: true,
        duration: 1100,
        hash: false,
    });

	//Change class on scroll
    $(window).scroll(function () {
        var inview = '#' + $("#main> section:in-viewport:first").attr('name'),
            $link = $('nav a').filter('[hash=' + inview + ']');

        if ($link.length && !$link.is('.current')) {
            $('nav a').removeClass('current');
            $link.addClass('current');
        }
    });

	//Animate Graphs
	
	   $(".stats li").fadeTo(0, 0.75);
	
$(window).scroll(function () {
  var $show = $("#main > section:in-viewport:first").attr('name'),
		vel=5000;
  if ($show == ('about')) {
  
		$('.photoshop').animate({ marginLeft: '-1%' }, vel );		
		$('.illustrator').animate({ marginLeft: '-11.26%' }, vel );		
		$('.cinema').animate({ marginLeft: '-25.32%' }, vel );		
		$('.htmlcss').animate({ marginLeft: '-6.21%' }, vel );
		$('.afteref').animate({ marginLeft: '-25.39%' }, vel );
		$('.sb').animate({ marginLeft: '-19.34%' }, vel );
		$('.foto').animate({ marginLeft: '-13.47%' }, vel );
		$('.dance').animate({ marginLeft: '0%' }, vel );
  }
});


	//Style for language Button
 $(".switch a").click(function (e) {
        e.preventDefault();
        var $this = $(this),
            $parent = $this.parent();
        if ($parent.hasClass($this.attr("class"))) {
            return;
        }

        if ($parent.hasClass("off")) {
            $parent.removeClass("off").addClass("on");
        } else {
            $parent.removeClass("on").addClass("off");
        }
    });
		


		
		
});










