// Define variables
var background = '';
var box_pos_x = '';
var box_pos_y = '';

// Ready
jQuery().ready(function() {
	$("#box").draggable({ scroll: false });
	setTimeout( function() { $('#box .container .scroll').jScrollPane( {showArrows:true, scrollbarWidth:21, arrowSize:21} ); }, 100)

    // Minimize button
    $('#minimize').mouseup(function() {
        if (box_pos_x == $("#box").css('left') && box_pos_y == $("#box").css('top'))
        {
            if (background == '')
            {
                // Save the background
                background = $("#box").css('backgroundImage');
                $(this).addClass('active');

                $("#box").css('backgroundImage', 'none');
                $("#box .container").css('visibility', 'hidden');
            }
            else
            {
                $("#box").css('backgroundImage', background);
                $("#box .container").css('visibility', 'visible');
                $(this).removeClass('active');

                // Clear it
                background = '';
            }
        }
    }).mousedown(function() {
        box_pos_x = $("#box").css('left');
        box_pos_y = $("#box").css('top');
    });

    $("a[rel='colorbox']").colorbox();
    
    if ($('#gallery h3 a').length)
    {
        $('#gallery h3 a').click(function() {
            var link = $('a[class="cboxelement"]', $(this).parent().parent());
            link.click();
        });
    }

    $(".youtube").colorbox({iframe:true, width:600, height:400});

	// Music
    if ($('#music').length) {
        $('#music ul').jcarousel({
            scroll: 1,
			wrap: 'both'
        });
    };
	
	if ($('#musicplayer').length) {
		$('#musicplayer').loadFlash({width: 530, height: 117, filename:_root+'web/files/music/MusicPlayer.swf', params: {flashvars:'xmlPath='+_root+'web/files/music/playlist.xml&stylesURL='+_root+'web/files/music/styles.css'}});
	}
	
	if ($('body.index_page').length)
	{
		$('#language').fadeOut('fast').fadeIn('fast').fadeOut('fast').fadeIn('fast');
	}
});

$(function(){  
	$.fn.supersized.options = {  
		startwidth: 1900,
		startheight: 1425,
		minsize: .10,
		slideshow: 0 
	};
	
	$('#supersize').supersized();  
}); 

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
