

var project_data=[
        //  project_id, 1st image to load, project title, portfolio_page_number
        ["dresser",getImage("img/dresser/thumbs/1.jpg"),"Pennsylvania Chester County Dresser","1"],
        ["desk",getImage("img/desk/thumbs/1.jpg"),"Cherry Desk with Serpentine Front","1"],
        ["mudroom",getImage("img/mudroom/thumbs/1.jpg"),"Mud Room Storage Benches", "2"],
        ["cupboard",getImage("img/cupboard/thumbs/1.jpg"),"Decorative Cherry Cupboard", "2"],
        ["small_projects",getImage("img/small_projects/thumbs/6.jpg"),"Small Projects", "2"],
        ["bookchair",getImage("img/bookchair/thumbs/1.jpg"),"Bookcase Chair and Ottoman", "1"],
        ["silver_chest",getImage("img/silver_chest/thumbs/1.jpg"),"Small Silverware Chest", "1"],
        ["record_cabinet",getImage("img/record_cabinet/thumbs/1.jpg"),"Tiger Maple Record Cabinet", "1"]
    ]

var image_data=[
        //  project_id, img_id, img_description
        ["dresser","1","Dresser dimensions: 5.5'H x 3'W x 2'D"],
        ["dresser","2",""],
        ["dresser","3","Hand-cut dovetails for all drawers"],
        ["dresser","4","Solid Red Aromatic Cedar was used in all drawer bottoms"],
        ["dresser","5",""],
        ["desk","1",'Desk dimensions: 60"L x 30"W x 29"H.'],
        ["desk","2","In order to workout the design and construction details, the finished product started out as a model created in SketchUp."],
        ["desk","3",""],
        ["desk","4",'These elegantly curved full extension drawers are 20" deep with file drawers on the bottom boasting a 150lb load capacity. One thing you will not notice are the hidden drawer slides.'],
        ["desk","5",""],
        ["desk","6","Simple, elegant and unique... this desk brightens any office space!"],
        ["cupboard","1",""],
        ["cupboard","2",""],
        ["mudroom","1","A picture is worth a thousand words, and this sketch was used to help the client envision the end product."],
        ["mudroom","2",'The 4 full extension 24"W x 24"D x 15"H drawers offer enough storage space for even the biggest pack-rat.'],
        ["mudroom","3"," The cedar lined storage bins on top are perfect for storing your hats and gloves."],
        ["mudroom","4","True to the sketch... the finished product is a perfect fit!"],
        ["mudroom","5","Corner bench - delivered and installed."],
        ["mudroom","6","Deep storage compartments inside the corner bench offer additional storage space."],
        ["small_projects","1","This small display box  made out of cherry was given as a gift to an avid coin collector."],
        ["small_projects","2","Stationery Box, Sycamore and Walnut"],
        ["small_projects","3",""],
        ["small_projects","4","Stationery Box, Figured Maple and Cherry"],
        ["small_projects","5","His and Her Ring Boxes. Cherry and Walnut."],
        ["small_projects","6","This beautiful ached-top clock made of maple and cherry veneer looks great on a mantle or desk."],
        ["small_projects","7","The drawers are delicate enough to hold even the most valuable jewels."],
        ["bookchair","1","Fun, functional and comfy, this leather upholstered chair will encourage anyone to sit down and relax with a good book."],
        ["bookchair","2",""],
        ["bookchair","3","Now with books!"],
        ["silver_chest","1",'Chest dimensions: 19"W x 14"D x 13"H. Proportions are generous, guaranteeing scratch-free storage.'],
        ["silver_chest","2","Exceptional craftsmanship and attention to every detail is evident in the decorative inlays added to the top and drawer fronts."],
        ["silver_chest","3","Top drawer is dedicated to the place settings. The bottom two drawers cradle serving pieces in a thick felt, keeping them safe and accessible."],
        ["record_cabinet","1","What better way to show the client a finished piece of work even before a speck of sawdust is made then to present a 3D model created in SketchUp."],
        ["record_cabinet","2",'Cabinet dimensions: 42"H x 52"W x 24"D'],
        ["record_cabinet","4",""],
        ["record_cabinet","5","The bottoms of each drawer are corrugated, preventing the records from sliding and falling when there are only a few records in the drawer."],
        ["record_cabinet","6","The tape drawers are designed for easy access.  The spokes allow you to flip through all the tapes in order to see each album name."],
        
    ]

function getImage(path){
    var image=new Image()
    image.src=path
    return image
}


function onImageLoad(opacity){
   
   var div=document.getElementById("selected_image")
   opacity+=0.1
   div.style.setopacity(opacity)
}

function getPortfolioThumbnail(portfolio_id){

    
    if (project_data.length==0) load_data()

    //  select portfolio thumbnail image
    var i = 0;
    for (i=0; i<project_data.length; i++){
        if (portfolio_id==project_data[i][0]){
            return project_data[i][1];
        }
    }
    return alert("can't fund thumbnail for portfolio '" + portfolio_id + "'")
}

function showPortfolioDetail(portfolio_id){

    var html;
    html='<div id="project_name"><div id="back_to_portfolio"><a href="portfolio' + getPortfolioPageNumber(portfolio_id) + '.html"><< to Portfolio</a></div><h3>' + getProjectName(portfolio_id) + '</h3></div>';
    html+=  '<div id="thumbs">';

    //  select images for the portfolio
    var i = 0;
    for (i=0; i<image_data.length; i++){
        if (portfolio_id==image_data[i][0]){
            //  print HTML for each thumbnail image
            html+=      '<a href="javascript:showBigImage(&quot;' + portfolio_id + '&quot;,' + image_data[i][1] + ');"><img src="img/' + portfolio_id + '/thumbs/' + image_data[i][1] + '.jpg"></a>';
        }
    }
    html+=  '</div>';
    
    //  load 1st image as default
    html+='<div id="selected_image">';
    html+="<img src='img/" + portfolio_id + "/1.jpg'  onload='setTimeout(onImageLoad(0.1), 3);'><div id='image_description'>" + getImageDescription(portfolio_id, 1) + "</div>";
    html+='</div>';

    //  update page
    document.getElementById("content_area").innerHTML=html;

}


function showBigImage(portfolio_id, image_id){

    var content = document.getElementById("selected_image");    
    content.innerHTML="<img src='img/" + portfolio_id + "/" + image_id + ".jpg' onload='setTimeout(onImageLoad(0.1), 3);'><div id='image_description'>" + getImageDescription(portfolio_id, image_id) + "</div>";
}


function getPortfolioPageNumber(portfolio_id){

    var i
    for (i=0; i<project_data.length; i++){
        if (portfolio_id==project_data[i][0]) return project_data[i][3]
    }
    return "Can't find portfolio page number for portfolio id '" + portfolio_id + "'"
}

function getProjectName(portfolio_id){
    
    var i
    for (i=0; i<project_data.length; i++){
        if (portfolio_id==project_data[i][0]) return project_data[i][2]
    }
    return "Can't find name for portfolio id '" + portfolio_id + "'"
}


/*
function getProjectDescription(portfolio_id){
    
    var i
    for (i=0; i<project_data.length; i++){
        if (portfolio_id==project_data[i][0]) return project_data[i][3]
    }
    return "Can't find description for portfolio id '" + portfolio_id + "'"
}
*/

function getImageDescription(portfolio_id, image_id){

    var i
    for (i=0; i<image_data.length; i++){
        if (portfolio_id==image_data[i][0] && image_id==image_data[i][1]) return image_data[i][2]
    }
    return "Can't find description for image id '" + image_id + "' in portfolio '" + portfolio_id + "'"
}