jQuery(document).ready(function(){
    //scroll to opening div
    jQuery('a[href*=#]').click(function(){
        if(location.pathname.replace(/^\//,'')== this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname){
            var $target = $(this.hash);
            $target = $target.length && $target
            || $('[name=' + this.hash.slice(1) +']');
            if ($target.length){
                var targetOffset = $target.offset().top;
                $('html,body')
                .animate({scrollTop: targetOffset}, 1200);
                //return false; //added in the href for smoothness
            }
        }
    });

    //Open and close links
    $('.extend').click(function(){
        var id = $(this).attr('id');
        var d = $('#' + id + '_info').css('display');

        if(d == 'none'){
            $('.content').fadeOut(400);
            $('.info').slideUp(800);
            $('#' + id + '_info').slideDown(800);
            $('.content').css({'display' : 'block'});
        } 
    });

    $('#btt').click(function(){
        $('.info').slideUp(800); 
    });

    $('a.zoom').click(function() {
        $.fancybox({
            'overlayOpacity'	: 0.7,
            'overlayColor'		: '#000',
            'overlayShow'		: 'true',
            'padding'			: 0,
            'autoScale'		    : false,
            'transitionIn'   	: 'fade',
            'transitionOut'     : 'fade',
            'title'				: this.title,
            'width'				: 560,
            'height'			: 340,
            'href'				: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'				: 'swf',
            'swf'				: {
	            'wmode'	 			: 'transparent',
	            'allowfullscreen'   : 'false'
            }
        });
    return false;
    });


    $('a.zoomText').fancybox({
        'overlayOpacity'	: 0.8,
        'overlayColor'		: '#000',
        'overlayShow'		: 'true',
        'width'             : '50%',
        'height'            : '90%',
        'type'              : 'iframe'
    });

    $('#about').fancybox({
        'overlayOpacity'	: 0.8,
        'overlayColor'		: '#000',
        'overlayShow'		: 'true',
        'width'             : '50%',
        'height'            : '90%',
        'type'              : 'iframe'
    });

    $('.piece').fancybox({
        'overlayOpacity'	: 0.8,
        'overlayColor'		: '#000',
        'overlayShow'		: 'true',
        'type'              : 'image'
    });

    //main div button rollovers
    $('a.orange').mouseover(function(){
        $(this).fadeTo('medium', 0);
    });
    $('a.orange').mouseout(function(){
        $(this).fadeTo('medium', 1.0);
    });
});


