﻿window.onload = initPage;

var thisPic = 1;
var picCount = 0;
var picName = "";
var folderName = "";
var leftArrow = 37;
var rightArrow = 39;
var map;

//Everything that needs done at onload
function initPage() {

    addBusinessInfo();
    initVariables();
    initializeMap();
}




//put the page together
function addBusinessInfo() {
    var businessName;
    var address;
    var citystatezip;
    var phone;
    var businessUrlText;
    var businessUrl;
    var businessDescription;
    var pageTitle;

    //get the url for the page
    var theURL = window.location.href.toLowerCase();


    //topic found by looking at url for folder name
    if (theURL.indexOf("anniesattic") > 0) {
        businessName = "Annie's Attic";
        pageTitle = "Annie's Attic";
        address = "22021 7th Ave. South #3";
        citystatezip = "Des Moines, WA 98198";
        phone = "(206) 824-4006";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "Visit Annie's Attic in downtown Des Moines to buy or sell new and lightly used items for infants and children up to age 10. Find cribs, beds, toys, shoes, clothing, stuffed animals, car seats, baby equipment and more.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("tjstatuary") > 0) {
        businessName = "T-J Statuary";
        pageTitle = "T-J Statuary";
        address = "26620 Pacific Hwy. S.";
        citystatezip = "Kent, WA 98031";
        phone = "(253) 946-1974";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "T-J Statuary has a wide variety of yard statues, fountains, benches and bird baths. It is also a convenient place to get your winter's supply of firewood.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("valleyanimalhospital") > 0) {
        businessName = "A Valley Animal Hospital";
        pageTitle = "A Valley Animal Hospital";
        address = "3615 West Valley Hwy. North";
        citystatezip = "Auburn, WA 98001";
        phone = "(253) 833-6701";
        businessUrlText = "avalleyanimalhospital.biz";
        businessUrl = "http://avalleyanimalhospital.biz/";
        businessDescription = "Is your furry friend feeling under the weather? When your pet gets sick, you don’t want to take them just anywhere. You want a veterinary hospital that will treat them with the care and attention they need. At A Valley Animal Hospital, we provide loving care for dogs, cats, rabbits, ferrets, and pocket pets. We encourage owners to be involved in pet care. An informed owner is less anxious and more likely to follow directions for care. We also provide pet boarding for small pets up to 25 pounds.";
        businessDescription2 = "We understand that finding an animal hospital that provides proper veterinary care is often challenging. But if you take your pet to A Valley Animal Hospital, you'll feel safe knowing that your pet is in the hands of our knowledgeable and caring staff. Plus, we are conveniently located in Auburn, Washington and can service the South Sound area. ";
    }
    else if (theURL.indexOf("jimmysdeli") > 0) {
        businessName = "Jimmy's Deli Market & Teriyaki";
        pageTitle = "Jimmy's Deli Market & Teriyaki";
        address = "3615 W. Valley Hwy. North";
        citystatezip = "Auburn, WA 98001";
        phone = "(253) 833-0772";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "Fresh made sandwiches, hot teriyaki meals, wine, beer, sodas, candy, chips and more. It's the one stop store, and the only store in the area.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("auburngc") > 0) {
        businessName = "Auburn Golf Course";
        pageTitle = "Auburn Golf Course";
        address = "29630 Green River Rd SE";
        citystatezip = "Auburn, WA 98092";
        phone = "(253)833-2350";
        businessUrlText = "www.auburngolf.org/";
        businessUrl = "http://www.auburngolf.org/";
        businessDescription = "Originally built in 1948, Auburn Golf Course has a new club house and spent the last couple years reconstructing 9 fairways, 15 greens and 17 tee boxes.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("druidsglengc") > 0) {
        businessName = "Druids Glen Golf Course";
        pageTitle = "Druids Glen Golf Course";
        address = "29925 207th Ave. SE";
        citystatezip = "Covington, WA  98042";
        phone = "(253)638-1200";
        businessUrlText = "www.druidsglengolf.com";
        businessUrl = "http://www.druidsglengolf.com";
        businessDescription = "Druids Glen Golf Course is a beautiful and challenging course. This is one of those courses that once you play you will always remember.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("enumclawgc") > 0) {
        businessName = "Enumclaw Golf Course";
        pageTitle = "Enumclaw Golf Course";
        address = "45220 288th Ave SE";
        citystatezip = "Enumclaw, WA 98022";
        phone = "(360) 825-2827";
        businessUrlText = "enumclawgolfcourse.com/";
        businessUrl = "http://enumclawgolfcourse.com/";
        businessDescription = "The Enumclaw Golf Course is a modestly priced course just north of the slopes of Mt. Rainier. Early morning golfers may be greated by a variety of wildlife.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("riverbendgc") > 0) {
        businessName = "Riverbend Golf Course";
        pageTitle = "Riverbend Golf Course";
        address = "2019 W Meeker St.";
        citystatezip = "Kent, WA 98032";
        phone = "(253)854-3673";
        businessUrlText = "www.ci.kent.wa.us/riverbend";
        businessUrl = "http://www.ci.kent.wa.us/Riverbend/";
        businessDescription = "Divided by the Green River, Riverbend Golf Course is the most popular of all Washington golf courses.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("sumnermeadowsgc") > 0) {
        businessName = "Sumner Meadows Golf Course";
        pageTitle = "Sumner Meadows Golf Course";
        address = "14802 Golf Links Drive";
        citystatezip = "Sumner, WA 98390";
        phone = "(253)863-8198";
        businessUrlText = "www.golfsumnermeadows.com";
        businessUrl = "http://www.golfsumnermeadows.com";
        businessDescription = "Located along the White River, Sumner Meadows Golf Course features a Scottish links-style course.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("mamaskitchen") > 0) {
        businessName = "Mama's Mexican Kitchen";
        pageTitle = "Mama's Mexican Kitchen";
        address = "2234 2nd Ave.";
        citystatezip = "Seattle, WA 98121";
        phone = "(206)728-6262";
        businessUrlText = "www.mamas.com";
        businessUrl = "http://www.mamas.com/";
        businessDescription = "Come to Mama's Mexican Kitchen for big, tasty meals served fast by a friendly staff.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("greenvalleymeats") > 0) {
        businessName = "Green Valley Meats";
        pageTitle = "Green Valley Meats";
        address = "12565 S.E. Green Valley Rd.";
        citystatezip = "Auburn, WA 98092";
        phone = "(253)833-8131";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "Green Valley Meats is a meat-lovers paradise. They make their own jerky, pepperoni and sausage, and smoke meats in-house. You can also find buffalo and elk, along with freshly butchered beef, pork and chicken.";
        businessDescription2 = "It's not just a butcher shop though, it's also a mini mart, so stop by for a snack on your way to Flaming Geyser State Park.";
    }
    else if (theURL.indexOf("ipanema") > 0) {
        businessName = "Ipanema Brazilian Grill ";
        pageTitle = "Ipanema Brazilian Grill ";
        address = "1225 First Ave.";
        citystatezip = "Seattle, WA 98101";
        phone = "(206)957-8444";
        businessUrlText = "www.ipanemabraziliangrill.us/";
        businessUrl = "http://www.ipanemabraziliangrill.us/";
        businessDescription = "At Ipanema you'll be treated to an amazing feast of mesquite charcoal grilled steak, lamb, chicken and pork, and a fantastic selection of specialty salads and vegetables.";
        businessDescription2 = "This is all served rodízio style, which is an all you can eat feast where the passadores carve the meat at your table.";
    }
    else {
        return; //something went wrong
    }

    //add element text for topic
    document.getElementById('businessname').innerHTML = businessName;
    document.title = pageTitle;
    document.getElementById('address').innerHTML = address;
    document.getElementById('citystatezip').innerHTML = citystatezip;
    document.getElementById('phone').innerHTML = phone;
    if (businessUrlText != "") {
        document.getElementById('businessurl').innerHTML = businessUrlText;
        document.getElementById('businessurl').href = businessUrl;
    }
    document.getElementById('businessdescription').innerHTML = businessDescription;
    if (businessDescription2 != "") {
        document.getElementById('businessdescription2').innerHTML = businessDescription2;
    }


}




function initVariables() {

    var theURL = window.location;
    var theResult;
    var description;

    //get the url for the page
    var theURL = window.location.href.toLowerCase();
    //topic found by looking at url for folder name
    if (theURL.indexOf("anniesattic") > 0) {
        picName = "anniesattic_";
        folderName = "retail/anniesattic";
        picCount = 14;
    }
    else if (theURL.indexOf("tjstatuary") > 0) {
        picName = "tjstatuary_";
        folderName = "retail/tjstatuary";
        picCount = 11;
    }
    else if (theURL.indexOf("valleyanimalhospital") > 0) {
        picName = "valleyanimalhospital_";
        folderName = "services/valleyanimalhospital";
        picCount = 5;
    }
    else if (theURL.indexOf("jimmysdeli") > 0) {
        picName = "jimmysdeli_";
        folderName = "restaurants/jimmysdeli";
        picCount = 4;
    }
    else if (theURL.indexOf("auburngc") > 0) {
        picName = "AuburnGC_";
        folderName = "golfcourses/auburngc";
        picCount = 5;
    }
    else if (theURL.indexOf("druidsglengc") > 0) {
        picName = "GC_DruidsGlen_";
        folderName = "golfcourses/druidsglengc";
        picCount = 48;
    }
    else if (theURL.indexOf("enumclawgc") > 0) {
        picName = "GC_Enumclaw_";
        folderName = "golfcourses/enumclawgc";
        picCount = 7;
    }
    else if (theURL.indexOf("riverbendgc") > 0) {
        picName = "RiverBend_";
        folderName = "golfcourses/riverbendgc";
        picCount = 12;
    }
    else if (theURL.indexOf("sumnermeadowsgc") > 0) {
        picName = "Sumner_";
        folderName = "golfcourses/sumnermeadowsgc";
        picCount = 18;
    }
    else if (theURL.indexOf("mamaskitchen") > 0) {
        picName = "Mamas_";
        folderName = "restaurants/mamaskitchen";
        picCount = 14;
    }
    else if (theURL.indexOf("greenvalleymeats") > 0) {
        picName = "GreenValleyMeats_";
        folderName = "restaurants/greenvalleymeats";
        picCount = 16;
    }
    else if (theURL.indexOf("ipanema") > 0) {
        picName = "Ipanema_";
        folderName = "restaurants/ipanema";
        picCount = 12;
    }
    document.getElementById("myPicture").src = folderName + "/" + picName + "1.jpg";

}

function keyHit(evt) {
    var thisKey = (evt) ? evt.which : window.event.keyCode;

    if (thisKey == leftArrow) {
        chgSlide(-1);
    }
    else if (thisKey == rightArrow) {
        chgSlide(1);
    }
    return false;
}

function chgSlide(direction) {
    thisPic = thisPic + direction;

    if (thisPic > picCount) {
        thisPic = 1;
    }
    if (thisPic < 1) {
        thisPic = picCount;
    }
    document.getElementById("myPicture").src = folderName + "/" + picName + thisPic + ".jpg";
}

function createMarker(point, html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click",
    function() { marker.openInfoWindowHtml(html); });
    return marker;
}

function initializeMap() {
    var point;
    var marker;
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"))
        //get the url for the page
        var theURL = window.location.href.toLowerCase();

        //topic found by looking at url for folder name
        if (theURL.indexOf("anniesattic") > 0) {
            map.setCenter(new GLatLng(47.403828, -122.326422), 15);
            point = new GLatLng(47.403828, -122.326422);
            marker = createMarker(point, 'Annie\'s Attic')
        }
        else if (theURL.indexOf("tjstatuary") > 0) {
            map.setCenter(new GLatLng(47.362797, -122.306575), 15);
            point = new GLatLng(47.362797, -122.306575);
            marker = createMarker(point, 'T-J Statuary')
        }
        else if (theURL.indexOf("valleyanimalhospital") > 0) {
            map.setCenter(new GLatLng(47.339985, -122.249866), 15);
            point = new GLatLng(47.339985, -122.249866);
            marker = createMarker(point, 'A Valley Animal Hospital')
        }
        else if (theURL.indexOf("jimmysdeli") > 0) {
            map.setCenter(new GLatLng(47.340229, -122.249965), 15);
            point = new GLatLng(47.340229, -122.249965);
            marker = createMarker(point, 'Jimmy\'s Deli Market & Teriyaki')
        }
        else if (theURL.indexOf("auburngc") > 0) {
            map.setCenter(new GLatLng(47.336249, -122.207460), 15);
            point = new GLatLng(47.336249, -122.207460);
            marker = createMarker(point, 'Auburn Golf Course')
        }
        else if (theURL.indexOf("druidsglengc") > 0) {
            map.setCenter(new GLatLng(47.332462, -122.065437), 15);
            point = new GLatLng(47.332462, -122.065437);
            marker = createMarker(point, 'Druids Glen Golf Course')
        }
        else if (theURL.indexOf("enumclawgc") > 0) {
            map.setCenter(new GLatLng(47.197088, -121.958107), 15);
            point = new GLatLng(47.197088, -121.958107);
            marker = createMarker(point, 'Enumclaw Golf Course')
        }
        else if (theURL.indexOf("riverbendgc") > 0) {
            map.setCenter(new GLatLng(47.380812, -122.262820), 15);
            point = new GLatLng(47.380812, -122.262820);
            marker = createMarker(point, 'Riverbend Golf Course')
        }
        else if (theURL.indexOf("sumnermeadowsgc") > 0) {
            map.setCenter(new GLatLng(47.248229, -122.231383), 15);
            point = new GLatLng(47.248229, -122.231383);
            marker = createMarker(point, 'Sumner Meadows Golf Course')
        }
        else if (theURL.indexOf("mamaskitchen") > 0) {
            map.setCenter(new GLatLng(47.614054, -122.345359), 15);
            point = new GLatLng(47.614054, -122.345359);
            marker = createMarker(point, 'Mama\'s Mexican Kitchen')
        }
        else if (theURL.indexOf("greenvalleymeats") > 0) {
            map.setCenter(new GLatLng(47.296324, -122.174721), 15);
            point = new GLatLng(47.296324, -122.174721);
            marker = createMarker(point, 'Green Valley Meats')
        }
        else if (theURL.indexOf("ipanema") > 0) {
            map.setCenter(new GLatLng(47.606658, -122.338253), 15);
            point = new GLatLng(47.606658, -122.338253);
            marker = createMarker(point, 'Ipanema Brazilian Grill')
        }
        map.setMapType(G_HYBRID_MAP);
        map.enableGoogleBar();
        map.enableScrollWheelZoom();
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GOverviewMapControl());
        map.addOverlay(marker);
    }
}
