$(document).ready(function() {

    // license container show/hide
    $("#gallery").hide();
    
    $("#open-close").click(function() {
        $(this).text(($("#open-close").text() == 'hide') ? 'view more' : 'hide');
        $("#gallery").slideToggle('slow');
    });
    
    // slideshow
    function title() { 
	$('#title').html(this.alt); 
    }
    
    $('#slideshow').cycle({
	fx: 'fade',
	timeout: 	15000,
	speed: 		1500,
	next:   	'#left', 
	prev:   	'#right',
	before:   	title,
	pager:  	'#gallery-images',
	pagerAnchorBuilder: function(idx, slide) { 
	    return '<a><img src="' + slide.src + '" width="64" height="36" /></a>';
	}
    });
    
    // gallery images opacity
    $("#gallery-images a img").css('opacity', 0.5);
    
    $("#gallery-images a img").hover(function(){
        $(this).stop().animate({opacity: 0.8}, 200);
        },
        function() {
        $(this).stop().animate({opacity: 0.5}, 200);
    });
    
    // overstate
    $(".menuoverstate").each(function(i) {

        preload_image = new Image();
        preload_image.src = this.src.replace(".png", "_o.png");

        $(this).hover(function() {
            if (this.src.indexOf("_o.png") == -1) {
                this.src = this.src.replace(".png", "_o.png");
            }
        }, function() {
            this.src = this.src.replace("_o.png", ".png");
        });
    });
    
});
