﻿var SamanthaBio = "<p class='people'>Samantha Kish is the newest addition to Granny Schmidt's. Over the past ten years Samantha has been making an impact in the culinary arts, including a few first place finishes in cake decorating competitions and several apperances as a judge.</p> " +
"<p class='people'> A graduate of  Johnson and Wales University (one of the nation's best culinary schools), Samantha has worked at many well established bakeries. But, we're happy to report that she's <i>never</i> allowed to leave <i>us</i> ! She loves to bake and decorate and this enthusiasm really shines through in her finished work.</p>" +
"<p class='people'> Most recently Samantha won the title of Top Pastry Chef at the 2009 March of Dimes Signature Chefs Auction.</p>";

var elvwText = "<div style='bottom:100%'><div id='elvwse' style='text-align:center; height:600px width:300px'><br />Granny Schmidt\'s is a proud member of <div style='font-style:italic'>Elegant Lehigh Valley Weddings<br>\& Special Events</div><a href='http://www.elvwse.com' target='_blank'><img src='images/ELVWSE-Logo-200.png' border='0' style='padding-top:10px;'/></a></div></div>";    

var windowHeight = 0;
var windowWidth = 0;
window.onresize = windowResizeHandler;
window.onscroll = windowResizeHandler;

function windowResizeHandler(e) {
    if (!e) e = window.event;
    var height = Geometry.getViewportHeight();
    // need to check whether window was actually re-sized because IE also fires this event when the document is re-sized
    if (height != windowHeight || e.type == "scroll") {
        windowHeight = height;
        var scroll = Geometry.getVerticalScroll();
        for (var film in Filmstrip.collection) {
            Filmstrip.collection[film].pageHeight = height + scroll;
            Filmstrip.collection[film].container.style.height = height + scroll + "px";
        }
        centerMainImage();  // need to run this for vertical and horizontal re-sizing
        sizeTextAreas();
    }

    var width = Geometry.getViewportWidth();
    if (width != windowWidth) {
        windowWidth = width;
        for (var film in Filmstrip.collection)
            Filmstrip.collection[film].keepInViewport();
        centerMainImage();
        sizeTextAreas();
    }
}

function centerMainImage() {
    mainContainer.style.left = Math.max(minTextWidth, (Geometry.getViewportWidth() - mainContainerWidth) / 2) + "px";
    mainContainer.style.top = Math.max(0, (Geometry.getViewportHeight() - mainContainerHeight) / 2) + "px";
}

function sizeTextAreas() {
    leftText.style.left = textMargin + "px";
    leftText.style.top = mainContainer.style.top;
    //    leftText.style.height = (Geometry.getViewportHeight() - parseInt(leftText.style.top)) + "px";
    leftText.style.height = mainContainerHeight + "px";
    leftText.style.width = parseInt(mainContainer.style.left) - textMargin * 2 + "px";
    rightText.style.left = parseInt(mainContainer.style.left) + mainContainerWidth + textMargin + "px";
    rightText.style.top = mainContainer.style.top;
    rightText.style.height = leftText.style.height;
    rightText.style.width = leftText.style.width;
    // kludge to keep elvwse link centered
    var e = document.getElementById("elvwse");
    if (e) {
        e.style.width = leftText.style.width;
        e.style.height = leftText.style.height;
    }
}

function clearTextAreas() {
    leftText.innerHTML = "&nbsp;";
    centerText.innerHTML = "";
    rightText.innerHTML = "";
    centerText.hide();
}

var mainContainerWidth = 518;
var mainContainerHeight = 560;
var mainContainer;
var screenWidth = 400;
var screenHeight = 540;
var screenViewWidth = 394;
var screenViewHeight = 534;
var leftText;
var rightText;
var centerText;
var centerTextBackground;
var minTextWidth = 100;
var textMargin = 20;

function calcFilmLeftEdge(filmNumber) {
    var areaWidth = (Geometry.getViewportWidth() - mainContainerWidth) / 2;
    var filmWidth = 140;
    switch (filmNumber) {
        case 1:
            return (areaWidth / 4) * 1 - filmWidth / 2;
            break;
        case 2:
            return (areaWidth / 4) * 3 - filmWidth / 2;
            break;
        case 3:
            return (areaWidth / 4) * 1 + areaWidth + mainContainerWidth - filmWidth / 2;
            break;
        case 4:
            return (areaWidth / 4) * 3 + areaWidth + mainContainerWidth - filmWidth / 2;
            break;
    }
}

function loadMainImage() {
    mainContainer = createElement("div",
        {
            id: "MainContainer"
        },
        {
            position: "absolute",
            width: mainContainerWidth,
            height: mainContainerHeight,
            zIndex: 74
        });
    document.body.appendChild(mainContainer);
    // run this here to set top and left attributes - other elements depend on these values
    centerMainImage();

    mainContainer.appendChild(createElement("img",
        {
            id: "Feature",
            src: "images/homepage image 400x540.jpg"    // Caption: "August 1940. Little girl at the Reitz farm near Falls Creek, Pennsylvania, washing eggs to be sold at Tri-County Farmers Co-op Market at Du Bois.  3&#188; inch safety negative by Jack Delano, Farm Security Administration."
        },
        {
            position: "absolute",
            left: "61px",
            top: "8px",
            zIndex: 72
        }));

    mainContainer.appendChild(createElement("img",
        {
            id: "mainFrame",
            src: "images/MainFrame.png"
        },
        {
            zIndex: 75,
            position: "absolute"
        }));

    mainContainer.appendChild(createElement("img",
        {
            id: "fallImage",
            src: "images/Petals/p1.jpg"
        },
        {
            position: "absolute",
            left: "470px",
            top: "-500",
            zIndex: "181",
            display: "none"
        }));

    mainContainer.appendChild(createElement("img",
        {
            id: "switch",
            src: "images/Switch Petal/SwitchbodyOnOverOff.png"
            //            onclick: switchClick()         // switch1.petalFallOff()
        },
        {
            position: "absolute",
            left: "470px",
            top: "500px",
            zIndex: "80",
            cursor: "pointer"
        }));

    mainContainer.appendChild(createElement("img",
        {
            id: "switchHandle",
            src: "images/Switch Petal/SwitchHandleUp.png",
            onmouseover:function() {tooltip.show('Click here to hide cake pictures');},
            onmouseout:function() {tooltip.hide();}
            //            onclick: switchClick()         // switch1.petalFallOff()
        },
        {
            position: "absolute",
            left: "470px",
            top: "500px",
            zIndex: "80",
            cursor: "pointer"
        }));

    document.body.appendChild(createElement("div",
        {
            id: "LeftText"
        },
        {
            position: "absolute",
            overflow: "auto",
            zIndex: "81"
        }));

    document.body.appendChild(createElement("div",
        {
            id: "RightText"
        },
        {
            position: "absolute",
            overflow: "auto",
            zIndex: "81"
        }));

    mainContainer.appendChild(createElement("div",
        {
            id: "CenterTextBackground"
        },
        {
            position: "absolute",
            left: "65px",
            top: "10px",
            width: screenViewWidth + "px",
            height: screenViewHeight + "px",
            zIndex: "81",
            backgroundColor: "#ffffff",
            filter: "alpha(opacity=0)",
            opacity: "0.0"
        }));

    document.getElementById("CenterTextBackground").appendChild(createElement("div",
        {
            id: "CenterText"
        },
        {
            position: "absolute",
            left: textMargin + "px",
            top: textMargin + "px",
            width: screenViewWidth - textMargin * 2 + "px",
            height: screenViewHeight - textMargin * 2 + "px",
            overflow: "auto",
            zIndex: "82"
        }));

    leftText = document.getElementById("LeftText");
    rightText = document.getElementById("RightText");
    centerText = document.getElementById("CenterText");
    centerTextBackground = document.getElementById("CenterTextBackground");
    centerText.show = function(text) {
        centerText.innerHTML = text;
        Fader.setOpacity100(centerTextBackground, 90)
    };
    centerText.hide = function() {
        centerText.innerHTML = "";
        Fader.setOpacity100(centerTextBackground, 0)
    };

    // order of these calls matters because sizeTextAreas() depends on values set by centerMainImage()
    centerMainImage();
    sizeTextAreas();
}

function fullyCompatibleBrowser() {
    if (BrowserDetect.browser == "Explorer" ||
        BrowserDetect.browser == "Chrome" ||
        BrowserDetect.browser == "Safari")
        return true;
    else
        return false;
}
   
