/*
Functions for controlling popup windows. 
*/

/* Preload any images in the document. */
if (document.images)
{
  pic1= new Image(1033,1033); 
  pic1.src="/images/grid.gif"; 
}

var activePic = '';

function showPopup(flickrPic) {
    if (activePic != '') {
        document.getElementById('sample' + activePic).style.display = 'none';
    }
    activePic = flickrPic;
    sampleToShow = document.getElementById('sample' + flickrPic);
    extPicToShow = document.getElementById('samplePopupExterior' + flickrPic);
    intPicToShow = document.getElementById('samplePopupInterior' + flickrPic);
    shadow1ToShow = document.getElementById('sampleShadow' + flickrPic + 1);
    shadow2ToShow = document.getElementById('sampleShadow' + flickrPic + 2);
    shadow3ToShow = document.getElementById('sampleShadow' + flickrPic + 3);
    shadow4ToShow = document.getElementById('sampleShadow' + flickrPic + 4);
    sampleToShow.style.display = 'block';
    new Effect.Appear(extPicToShow);
    new Effect.Appear(intPicToShow);
    new Effect.Appear(shadow1ToShow, { from:0.0, to:0.2 } );
    new Effect.Appear(shadow2ToShow, { from:0.0, to:0.2 });
    new Effect.Appear(shadow3ToShow, { from:0.0, to:0.2 });
    new Effect.Appear(shadow4ToShow, { from:0.0, to:0.2 });
    new Draggable(sampleToShow);
}

function closePopup(flickrPic) {
    extPicToFade = document.getElementById('samplePopupExterior' + flickrPic);
    intPicToFade = document.getElementById('samplePopupInterior' + flickrPic);
    shadow1ToFade = document.getElementById('sampleShadow' + flickrPic + 1);
    shadow2ToFade = document.getElementById('sampleShadow' + flickrPic + 2);
    shadow3ToFade = document.getElementById('sampleShadow' + flickrPic + 3);
    shadow4ToFade = document.getElementById('sampleShadow' + flickrPic + 4);
    new Effect.Fade(extPicToFade);
    new Effect.Fade(intPicToFade);
    new Effect.Fade(shadow1ToFade);
    new Effect.Fade(shadow2ToFade);
    new Effect.Fade(shadow3ToFade);
    new Effect.Fade(shadow4ToFade);
    activePic = '';
}


var activeCaseStudy = 'caseStudy36';

function showCaseStudy(caseStudyId, flickrPic) {
    document.getElementById(activeCaseStudy).style.display = 'none';
    document.getElementById('mainFeature').src = flickrPic;
    new Effect.Appear(caseStudyId);
    activeCaseStudy = caseStudyId;
}




function hideGridPopup() {
    $('gridPopupContainer').style.display = 'none';
    $('gridPopupExterior').style.display = 'none';
    $('gridPopupInterior').style.display = 'none';
    $('gridPopupShadow1').style.display = 'none';
    $('gridPopupShadow2').style.display = 'none';
    $('gridPopupShadow3').style.display = 'none';
    $('gridPopupShadow4').style.display = 'none';
}

function showGridPopup() {
    $('gridPopupContainer').style.display = 'block';
    new Effect.Appear('gridPopupExterior', { duration:0.5 } );
    new Effect.Appear('gridPopupInterior', { duration:0.5 } );
    new Effect.Appear('gridPopupShadow1', { from:0.0, to:0.2, duration:2.0 } );
    new Effect.Appear('gridPopupShadow2', { from:0.0, to:0.2, duration:2.0 });
    new Effect.Appear('gridPopupShadow3', { from:0.0, to:0.2, duration:2.0 });
    new Effect.Appear('gridPopupShadow4', { from:0.0, to:0.2, duration:2.0 });
}

function showGrid() {
    new Effect.toggle('gridImg', 'appear');
}