﻿var timerTop;
var timerBottom;

function displayContact(obj)
{
    var agt = navigator.userAgent.toLowerCase();
    
    var c = getObj(obj);
    if(c.style.display == 'block')
    {
        c.style.display = 'none';
        if(agt.indexOf("msie 6.") != -1)
        {
            if(isPortfolio())
                document.all['mc_container'].style.marginTop = "-502px";
            else
                document.all['mc_container'].style.marginTop = "-278px";
        }
    }
    else
    {
        c.style.display = 'block';
        if(agt.indexOf("msie 6.") != -1)
        {
            if(isPortfolio())
                document.all['mc_container'].style.marginTop = "-656px";
            else
                document.all['mc_container'].style.marginTop = "-432px";
        }
    }
}

function slideShow(start, appPath, img1, img2, img3, img4)
{
    var pic = new Array();
    pic[0] = appPath + "Images/Basement_A_2.jpg";
    pic[1] = appPath + "Images/slide_show_separator.png";
    pic[2] = appPath + "Images/Bathroom_A_3.jpg";
    pic[3] = appPath + "Images/slide_show_separator.png";    
    pic[4] = appPath + "Images/Stairs_1.jpg";
    pic[5] = appPath + "Images/slide_show_separator.png";    
    pic[6] = appPath + "Images/Floor_B_2.jpg";
    pic[7] = appPath + "Images/slide_show_separator.png";    
    pic[8] = appPath + "Images/Kitchen_A_2.jpg";
    pic[9] = appPath + "Images/slide_show_separator.png";    
    pic[10] = appPath + "Images/Dining_Room_A_1.jpg";
    pic[11] = appPath + "Images/slide_show_separator.png";    
    pic[12] = appPath + "Images/Trim_and_Finishing_1.jpg";
    pic[13] = appPath + "Images/slide_show_separator.png";
    pic[14] = appPath + "Images/Garage_1.jpg";
    pic[15] = appPath + "Images/slide_show_separator.png";
    
    for (var i = 0; i < 4; i++)
    {
        if (start > 15)
            start = 0;
            
        var j = getObj(eval("img" + (i+1)));
        j.src = pic[start++];
    }
    
    start += 1;
    
    setTimeout("slideShow("+start+",'"+appPath+"','"+img1+"','"+img2+"','"+img3+"','"+img4+"')", 4000);
}

function changeImage(obj, src)
{
    var i = getObj(obj);
    i.src = src;
}

function scrollToTop(obj)
{
    clearTimeout(timerTop);
    var b = getObj(obj);
    b.scrollTop -= 1;
    timerTop = setTimeout("scrollToTop('"+obj+"')",10);
}

function scrollToBottom(obj)
{
    clearTimeout(timerBottom);
    var b = getObj(obj);
    b.scrollTop += 1;
    timerBottom = setTimeout("scrollToBottom('"+obj+"')",10);
}

function scrollStop()
{
    clearTimeout(timerTop);
    clearTimeout(timerBottom);
}

function getObj(obj)
{
    if (document.getElementById)
  	    return document.getElementById(obj);
    else if (document.all)
        return document.all[obj];
    else if (document.layers)
        return document.layers[obj];
}

function isPortfolio()
{
    var loc = window.location.href;
    if(loc.indexOf("Portfolio") > -1 && loc.indexOf("portfolio") > -1)
        return true;
    else
        return false;
}