// JavaScript Document

//change mainpic when selecting thumbnails - residential
function changeThumbnail(thumbpic)
{

changeLink(thumbpic);
thumbnail = thumbpic;
picture = document.getElementById('mainpic');
picture.setAttribute('src',thumbnail);
}

//change link of mainpic - residential

function changeLink(mainLink){

theLink = "javascript:enlargePicture('pop_up.php?image=" + mainLink + "');";
themainLink = document.getElementById('mainpiclink');
themainLink.setAttribute('href',theLink);


}

function changeCommercialThumbnail(thumbpic)
{

changeCommercialLink(thumbpic);
thumbnail = thumbpic;
picture = document.getElementById('mainpic');
picture.setAttribute('src',thumbnail);
}

//change link for commercial pics
function changeCommercialLink(mainLink){

theLink = "javascript:enlargePicture('pop_upcommercial.php?image=" + mainLink + "');";
themainLink = document.getElementById('mainpiclink');
themainLink.setAttribute('href',theLink);


}


//call pop-up-window
function enlargePicture(MyPage) {
    features = 'width=705,height=545,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no';
	if (!window.window2) {
        // has not yet been defined
        window2 = window.open(MyPage,'imagewindow',features);
    }
    else {
        // has been defined
        if (!window2.closed) {
            // still open
            window2.close();
            window2 = window.open(MyPage,'imagewindow',features);

        }
        else {
            window2 = window.open(MyPage,'imagewindow',features);
        }
    }
}