/* L I N K   A R R A Y */
function lclink( str, href, tip ) {
    this.str = str;
    this.href = href;
    this.tip = tip;
}

// Fill in the array below to manage the left sash links
//     str = The text to display in the link
//     href = The url the link should go to
//     lvl = Either 1 or 2. Major headings are 1 and minor headings are 2.

var myLinkArray = new Array();
myLinkArray[myLinkArray.length] = new lclink("Welcome", "index.html", "Return to the Home Page");
myLinkArray[myLinkArray.length] = new lclink("About Us", "aboutus.html", "");
myLinkArray[myLinkArray.length] = new lclink("Windows", "windows.html", "");
//myLinkArray[myLinkArray.length] = new lclink(" - Styles", "windowstyles.html", "Click to see a gallery of Window Styles");
myLinkArray[myLinkArray.length] = new lclink("Doors", "doors.html", "");
//myLinkArray[myLinkArray.length] = new lclink(" - Styles", "doorstyles.html", "Click to see a gallery of Door Styles");
myLinkArray[myLinkArray.length] = new lclink("Patio Doors", "patiodoors.html", "");
//myLinkArray[myLinkArray.length] = new lclink(" - Styles", "patiodoorstyles.html", "Click to see a gallery of Patio Door Styles");
myLinkArray[myLinkArray.length] = new lclink("Storm Doors", "stormdoors.html", "");
//myLinkArray[myLinkArray.length] = new lclink(" - Styles", "stormdoorstyles.html", "Click to see a gallery of Storm Door Styles");
myLinkArray[myLinkArray.length] = new lclink("Siding", "siding.html", "");
myLinkArray[myLinkArray.length] = new lclink("Sunrooms", "sunrooms.html", "");
myLinkArray[myLinkArray.length] = new lclink("Accessories", "accessories.html", "");
myLinkArray[myLinkArray.length] = new lclink("Locations", "locations.html", "");
myLinkArray[myLinkArray.length] = new lclink("Request Info", "requestinfo.html", "");
myLinkArray[myLinkArray.length] = new lclink("TV Commercial", "docs/WindowsDirect.wmv", "See our Television Commercial");

/* M A K E   T H E   P A G E */

// As long as this is just HTML text, it can simply be written into the stream using document.write()
function makeTopBanner() {
    // main table
    document.write("\n<table border=\"0\" id=\"main\" cellpadding=\"0\" cellspacing=\"0\" width=\"770\" align=\"center\">");
    document.write("\n<col width=\"196\">");
    document.write("\n<col width=\"574\">");
    document.write("\n<tr valign=\"top\"><td colspan=\"2\" class=\"pageBlock\">");
    // main logo
    document.write("\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"770\">");
    document.write("\n<tr>");
    document.write("\n<td align=\"left\" id=\"bannerBlock\" style=\"background-image: url(images/top6.jpg); background-color: red;\">");
    // writing on top of the logo
    document.write("\n<table id=\"hours\" cellpadding=\"0\" cellspacing=\"0\">");
    document.write("\n<col width=\"110\">");
    document.write("\n<col width=\"450\">");
    document.write("\n<col width=\"150\">");
    document.write("\n<tr>");
    document.write("\n<td>(540) 362-1567</td>");
    document.write("\n<td>Monday -Friday 8am - 5pm</td>");
    document.write("\n<td id=\"emailDiv\"><a href=\"mailto:windowsdirectinc@aol.com\">windowsdirectinc@aol.com</a></td>");
    document.write("\n</tr>");
    document.write("\n<tr>");
    document.write("\n<td>(434) 528-5910</td>");
    document.write("\n<td>Saturdays By Appointment</td>");
    document.write("\n</tr>");
    document.write("\n</table>");
    document.write("\n<div id=\"tagline\">Our Service Following The Sale Is What Counts</div>");

    document.write("\n</td>");
    document.write("\n</tr>");
    document.write("\n<tr>");
    document.write("\n<td>&nbsp;</td>");
    document.write("\n</tr>");
    document.write("\n</table>");
    document.write("\n</td></tr>");
    // left sash links
    document.write("\n<tr valign=\"top\"><td class=\"pageBlock\">");
    document.write("\n<div id=\"sashLinks\"></div>");
    document.write("\n</td><td class=\"pageBlock\"><div style=\"margin-top:8px;\">");

}

function makeBottomBanner() {
    document.write("\n</div></td></tr>");
    document.write("</table>");
}

/* S A S H   L I N K S */
// Since the sash links rely on the link array, they processed AFTER the poage finishes loading.
// If you don't do this, you risk javascript errors because the array might not be "ready" when you try to use it.
// The link building code is called by the onload method of the BODY tag

function preparePage() {
    if ( document.getElementById("sashLinks") != null ) {
        makeSashLinks();
    }
    fixAbsoluteItems();
}

function makeSashLinks() {
    var fname = document.location.pathname.substr( document.location.pathname.lastIndexOf("/")+1 );
    var str = "";
    for (var i = 0 ; i < myLinkArray.length ; i++ ) {
        if (fname != myLinkArray[i].href) {
            str += "<a href='" + myLinkArray[i].href + "' class='rollover2'>"
            str += "<div class='link1' "
            str += " title='" + myLinkArray[i].tip + "' "
            str += " onMouseOver=\"W2_roll( this, 'over' )\""
            str += " onMouseOut=\"W2_roll( this, 'out' )\">"
            str += myLinkArray[i].str
            str += "</div>"
            str += "</a>"
        } else {
            str += "<div class='link1'>"
            str += myLinkArray[i].str
            str += "</div>"
        }
    }
    document.getElementById("sashLinks").innerHTML = "<br>" + str;
}

function fixAbsoluteItems() {
    var pageWidth = document.body.scrollWidth - 785;
    pageWidth = pageWidth / 2
    pageWidth = Math.round( pageWidth )
    if (pageWidth >= 0) {

        //Doors
        if ( document.getElementById("gardendoor") != null ) {
            document.getElementById("gardendoor").style.left = 10 + pageWidth;
        }
        if ( document.getElementById("doors5") != null ) {
            document.getElementById("doors5").style.left = -3 + pageWidth;
        }
        if ( document.getElementById("doors") != null ) {
            document.getElementById("doors").style.left = 15 + pageWidth;
        }
        if ( document.getElementById("doors3") != null ) {
            document.getElementById("doors3").style.left = 235 + pageWidth;
        }
        if ( document.getElementById("doors4") != null ) {
            document.getElementById("doors4").style.left = 455 + pageWidth;
        }

    }
}

/* R O L L O V E R S */
// Walter Barry - 2007 - Rollover using CSS and DHTML - no images required
// Simply change the visual properties of the calling element as the mouse passes over the element

function W2_roll( obj, val ) {
    if ( val == "over" ) {
        obj.style.backgroundImage = "url(images/button2.jpg)";
    }
    if ( val == "out" ) {
        obj.style.backgroundImage = "url(images/button.jpg)";
    }
}

