var hrefSelect;
var altSelect;

$("p > .img").click (function (){
    $(".disp").css({
                    width: "0px",
                    height: "0px"
                    });
    $(".disp").children(".items").empty();
    $(".disp").hide("slow");
    hrefSelect = $(this).attr("href");
    altSelect = $(this).attr("title");
    $(this).parent("p").parent(".gal_img").parent(".img_cont").children(".disp").each(function() {
                $(this).animate({
                    width: "790px",
                    height: "460px"
                    //left: "5%",
                    //opacity: 0.97
                    //borderWidth: "1px"
                    }, 1500);
                $(this).each(function () {
                    $(this).load("blankpage.php",function(){
                                $(".viewGal").load("blankpage_old.php?link=" + hrefSelect, function(){
                                    $(this).parent(".disp").children(".scrollable").scrollable({vertical:true, size: 3});
                                    });
                                $(this).parent(".img_cont").children(".gal_img").children("p").children(".noimg").each(function() {
                                    $(this).clone().prependTo($(this).parent("p").parent(".gal_img").parent(".img_cont").children(".disp").children(".scrollable").children(".items"));
                                    $(".items > a").removeClass("noimg");
                                    $(".items > a").addClass("img");
                                    });
                                $(this).parent(".img_cont").children(".gal_img").children("p").children(".img").each(function() {
                                    $(this).clone().prependTo($(this).parent("p").parent(".gal_img").parent(".img_cont").children(".disp").children(".scrollable").children(".items"));
                                    $(".items > .img").animate({opacity: 0.7}, 200);
                                    });
                                $(".items > .img").click(function() {
                                    $(".info").html(" " + $(this).attr("title") + " ");
                                    $(".items > .img").animate({opacity: 0.7}, 200);
                                    //$(".items > .img").removeClass("selectImg");
                                    $(this).animate({opacity: 1}, 500);
                                    //$(this).addClass("selectImg");
                                    $(this).parent(".items").parent(".scrollable").parent(".disp").children(".viewGal").html("<img src='/galeryimg/preload.gif' />").load("blankpage_old.php?link=" + $(this).attr("href"));
                                    return false;
                                });
                                $(".closeGal").click (function (){
                                    $(this).parent(".disp").children(".items").empty();
                                    //$(this).parent(".disp")
                                    $(".disp").hide("slow").css({
                                                    width: "0px",
                                                    height: "0px"
                                                    });
                                    return false;
                                 });
                                    $(document).pngFix(); 
                                 });
                    
                    });
                });
    return false;
    });

