﻿function killResPic(cond)
    {
        switch(cond)
        { case 1:  $("#resPicTwo").fadeOut(500); $("#resPicThree").fadeOut(500); break;
        case 2: $("#resPicOne").fadeOut(500); $("#resPicThree").fadeOut(500); break;
        case 3: $("#resPicTwo").fadeOut(500); $("#resPicOne").fadeOut(500); break;
        default: $("#resPicThree").fadeOut(500); $("#resPicTwo").fadeOut(500); $("#resPicOne").fadeOut(500); 
        alert("default in switch statement tripped. 'killResPic'.");
        }
    }
function killComPic(cond)
    {
        switch(cond)
        { 
            case 1: $("#comPicTwo").fadeOut(500); $("#comPicThree").fadeOut(500); $("#comPicFour").fadeOut(500); $("#comPicFive").fadeOut(500); break;
            case 2: $("#comPicOne").fadeOut(500); $("#comPicThree").fadeOut(500); $("#comPicFour").fadeOut(500); $("#comPicFive").fadeOut(500); break;
            case 3: $("#comPicOne").fadeOut(500); $("#comPicTwo").fadeOut(500); $("#comPicFour").fadeOut(500); $("#comPicFive").fadeOut(500); break;
            case 4: $("#comPicOne").fadeOut(500); $("#comPicTwo").fadeOut(500); $("#comPicThree").fadeOut(500); $("#comPicFive").fadeOut(500); break;
            case 5: $("#comPicOne").fadeOut(500); $("#comPicTwo").fadeOut(500); $("#comPicThree").fadeOut(500); $("#comPicFour").fadeOut(500);  break;
        default: $("#comPicFour").fadeOut(500); $("#comPicFive").fadeOut(500); $("#comPicThree").fadeOut(500); $("#comPicTwo").fadeOut(500); $("#comPicOne").fadeOut(500); 
        alert("default in switch statement tripped. 'killResPic'.");
        }
    }




function viewBox(box, pic)
{     
    if(box == "res")
    {
        $("#resViewer").fadeIn(500);
        
        if(resPic > 1)
        {$("#resLeft").fadeIn(500); }
        if(resPic < 3)
        {$("#resRight").fadeIn(500); }
        
        switch(pic)
            { 
            case 1:
            $("#resLeft").fadeOut(500); 
                killResPic(pic);
                $("#resPicOne").fadeIn(500);
                resPic = pic;
                break;
            case 2:
                $("#resPicTwo").fadeIn(500);
                resPic = pic;
                killResPic(pic);
                break;
            case 3:
            $("#resRight").fadeOut(500); 
                $("#resPicThree").fadeIn(500);
                resPic = pic;
                killResPic(pic);
                break;
           case "kill":
           $("#resViewer").fadeOut(500); resPic = 0; break;
            default:
                alert("viewBox, residential, switched default return");
            }
            
    }
    if(box == "com")
    {
     $("#comViewer").fadeIn(500);
     
     if(comPic < 5)
     { $("#comRight").fadeIn(500); } //There was some trouble without these if someone were to go all the way right or left then shut
     if(comPic > 1)                  //the viewer, because the button would still be gone.
     { $("#comLeft").fadeIn(500);}
     switch(pic)
            { 
            case 1:
                $("#comLeft").fadeOut(500);
                killComPic(pic);
                $("#comPicOne").fadeIn(500);
                comPic = pic;
                break;
            case 2:
                killComPic(pic);
                $("#comPicTwo").fadeIn(500);
                comPic = pic;  
                break;
            case 3:
                killComPic(pic);
                $("#comPicThree").fadeIn(500);
                comPic = pic;
                break;
            case 4:
                killComPic(pic);
                $("#comPicFour").fadeIn(500);
                comPic = pic;  
                break;
            case 5:
                $("#comRight").fadeOut(500);
                killComPic(pic);
                $("#comPicFive").fadeIn(500);
                comPic = pic;
                break;
            case "kill":
                $("#comViewer").fadeOut(500); comPic = 0; break;
            default:
                alert("viewBox, commercial, switched default return");
            }
    }
    
}
function com(number)
{   comPic = number;
    viewBox('com', number); }

function res(numb)
{ resPic = numb;
    viewBox('res', numb); }

var resPic = 0;
var comPic = 0;
function viewButton(box, dir)
{
    if(box == "res")
        {
            switch(dir)
            {
                case "left":
                    $("#resRight").fadeIn(500); 
                    if(resPic > 1)
                        {
                            resPic = resPic - 1;
                            res(resPic);
                        }
                    break;
                 case "right":
                    $("#resLeft").fadeIn(500); 
                    if(resPic < 3)
                        {
                            resPic = resPic + 1;
                            res(resPic);
                        }
                 break;
                 default: alert("viewbutton, res default switch(mispell 'left' or 'right', perhaps)");
            }
        }
        if(box == "com")
        {
            switch(dir)
            {
                case "left":
                    $("#comRight").fadeIn(500); 
                    if(comPic > 1)
                        {
                            comPic = comPic - 1;
                            com(comPic);
                        }
                    break;
                 case "right":
                    $("#comLeft").fadeIn(500); 
                    if(comPic < 5)
                        {
                            comPic = comPic + 1;
                            com(comPic);
                        }
                 break;
                 default: alert("viewbutton, com default switch(mispell 'left' or 'right', perhaps)");
            }
        }
}



var length = 111;
function scroller()
{   
    var first = document.getElementById("testTierOne");
    length -= 1;
    var value = "" + length + "px";
    
    first.style.top = value;
    setTimeout('scrollOne()', 60);
    
}

function scrollOne()
{ 
    var first = document.getElementById("testTierOne");
    if(length > -918)
    { scroller(); }
    if(length <= -918)
    { length = 111; 
        first.style.top = "111px";}
} 

function calc(number)
    {var solution = number * 22;
        solution += "px";
        return solution; }
var currentFaq;        
function expandContract(name, cond)
{   
    if(currentFaq == name)
    { return; }
    currentFaq = name;
    
    var items = ["#faq1", "#faq2", "#faq3", "#faq4", "#faq5", "#faq6", "#faq7", "#faq8", "#faq9", 
    "#faq10", "#faq11" ];
    
    for(var i in items)
    {      
            $(items[i]).animate({'height':'22px'}, 500); 
    } 
        
    var pix = "";   
    
    switch(cond)
    {
        case 1:
            pix += calc(2);
            break;
        case 2:
            pix += calc(4);
            break;
        case 3:
            pix += calc(4);
            break;
        case 4:
            pix += calc(5);
            break;
        case 5:
            pix += calc(4);
            break;
        case 6:
            pix += calc(6);
            break;
        case 7:
            pix += calc(4);
            break;
        case 8:
            pix += calc(4);
            break;
        case 9:
            pix += calc(5);
            break;
        case 10:
            pix += calc(3);
            break;
        case 11:
            pix += calc(4);
            break;
        default:
            alert("problems in the faq height switch");  
    }
    
    $(name).animate({'height':pix}, 500); 
}
