$(document).ready(function() {
    currentPhoto = 1;
    for(x = 1; x < 11; x++) {
        $("#photo"+x).click(function() {
        addr  = $(this).attr("src");
        info = addr.replace('images/thumb', "");
        info = info.replace('.jpg', "");
        if (currentPhoto != info) {
            addr  = $(this).attr("src");
            newAddr = "images/gal"+addr.replace('images/thumb', "");
            $("#imgcaption").fadeOut("4000");
            $("#galimage").fadeOut("4000", function() {
                switch(info) {
                    case "1":
                        document.getElementById('imgcaption').innerHTML = "Supermarket Roof - Top Dehumidification Unit";
                        break;
                    case "2":
                        document.getElementById('imgcaption').innerHTML = "Supermarket Overhead Refrigeration Piping #2 - New Supermarket Install.";
                        break;
                    case "3":
                        document.getElementById('imgcaption').innerHTML = "Supermarket Overhead Refrigeration Piping.";
                        break;
                    case "4":
                        document.getElementById('imgcaption').innerHTML = "Underground Refrigeration Piping - New Sweetbay Supermarket in Tampa, FL";
                        break;
                    case "5":
                        document.getElementById('imgcaption').innerHTML = "Mechanical House Service";
                        break;
                    case "6":
                        document.getElementById('imgcaption').innerHTML = "GC Project - Exterior Block Wall Construction Including Custom Gates Made In-House - Miramar, FL";
                        break;
                    case "7":
                        document.getElementById('imgcaption').innerHTML = "";
                        break;
                    case "8":
                        document.getElementById('imgcaption').innerHTML = "";
                        break;
                    case "9":
                        document.getElementById('imgcaption').innerHTML = "";
                        break;
                    case "10":
                        document.getElementById('imgcaption').innerHTML = "";
                        break;
                }
                $("#galimage").attr("src", newAddr).load(function() {
                    $("#galimage").fadeIn("4000");
                    $("#imgcaption").fadeIn("4000");
                });
            });
            currentPhoto = info;
        }
        });
        $("#photo"+x).hover(function() {
            $(this).fadeTo("slow", .7);
        },
        function() {
            $(this).fadeTo("slow", 1);
        });
    }
    
    $("#arrowdown").click(function() {
        if ($("#galbox").css("marginTop") != "-378px") {
            $("#galbox").animate({marginTop: "-=63px"}, "1000");
        }
    });
    $("#arrowup").click(function() {
        if ($("#galbox").css("marginTop") != "0px") {
            $("#galbox").animate({marginTop: "+=63px"}, "1000");
        }
    });
    
    $("#arrowdown").hover(function() {
        $(this).fadeTo("slow", .7);
    },
    function() {
        $(this).fadeTo("slow", 1);
    });
        
    $("#arrowup").hover(function() {
            $(this).fadeTo("slow", .7);
    },
    function() {
        $(this).fadeTo("slow", 1);
    });
    
});