﻿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();
}

//get the video file name from the url
function getVideoFileName() {
    //get the url for the page
    var theURL = window.location.href.toLowerCase();
    //topic found by looking at url for folder name
    if (theURL.indexOf("eastindiagrill") > 0) {
        return 'restaurants/eastindiagrill/eastindiagrill';
    }
    else if (theURL.indexOf("helena") > 0) {
        return 'retail/helena/helena';
    }
    else if (theURL.indexOf("ultimatehobbies") > 0) {
        return 'retail/ultimatehobbies/ultimatehobbies';
    }
    else if (theURL.indexOf("jcmarbleexpo") > 0) {
        return 'retail/jcmarbleexpo/jcmarbleexpo';
    }
   else if (theURL.indexOf("corkycellars") > 0) {
        return 'retail/corkycellars/corkycellarswqna';
    }
    else if (theURL.indexOf("xiuxiantea") > 0) {
        return 'restaurants/xiuxiantea/xiuxiantea';
    }   
    else if (theURL.indexOf("forbesfurniture") > 0) {
        return 'retail/forbesfurniture/forbesfurniture';
    }
    else if (theURL.indexOf("thaichili") > 0) {
        return 'restaurants/thaichili/thaichili';
    }
    else if (theURL.indexOf("goldendynasty") > 0) {
        return 'restaurants/goldendynasty/goldendynasty';
    }
    else if (theURL.indexOf("littledavidssubs") > 0) {
        return 'restaurants/littledavidssubs/littledavidssubs';
    }
    else if (theURL.indexOf("pacislandgrill") > 0) {
        return 'restaurants/pacislandgrill/pacislandgrill';
    }
    else if (theURL.indexOf("hangarcafe") > 0) {
        return 'restaurants/hangarcafe/hangarcafe';
    }
    else if (theURL.indexOf("99bottles") > 0) {
        return 'restaurants/99bottles/99bottles';
    }
}


//put the page together
function addBusinessInfo() {
    var businessName;
    var address;
    var citystatezip;
    var phone;
    var businessUrlText;
    var businessUrl;
    var businessDescription = "";
    var businessDescription2 = "";
    var businessDescription3 = "";
    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("eastindiagrill") > 0) {
        businessName = "East India Grill";
        pageTitle = "East India Grill Video";
        address = "31845 Gateway Center Blvd. S.";
        citystatezip = "Federal Way, WA 98003";
        phone = "(253) 529-9292";
        businessUrlText = "www.eastindiagrillwa.com";
        businessUrl = "http://www.eastindiagrillwa.com";
        businessDescription = "Rack of lamb, Tandoori chicken, marinated seafood, all cooked in an authentic Tandoor, a round clay oven. You haven't tasted the best in Indian cuisine until you've eaten at the East India Grill.";
        businessDescription2 = "Menu items include Mixed Grill, Seafood Grill, Rack of Lamb, Saffron Lamb Medallions, Tandoori Prawns, Chicken Tikka, Shrimp Biryani, Ginger Prawn Mussels, Halibut Marsala and much much more. Visit the East India Grill website to see the full menu.";
    }
    else if (theURL.indexOf("helena") > 0) {
        businessName = "Helena Catholic Book & Gift";
        pageTitle = "Helena Catholic Book & Gift Video";
        address = "30390 Pacific Hwy. S.";
        citystatezip = "Federal Way, WA 98003";
        phone = "(253) 839-4094";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "Whether you need a gift for a child's first communion, an inspirational book, or a cross for your bedroom wall, Helena will help you find the perfect one. Find Bibles, books, CDs, statues, rosaries and more.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("ultimatehobbies") > 0) {
        businessName = "Ultimate Hobbies";
        pageTitle = "Ultimate Hobbies Video";
        address = "131 E. Main Street";
        citystatezip = "Auburn, WA 98002";
        phone = "(253) 939-2515";
        businessUrlText = "www.ulthobby.com";
        businessUrl = "http://www.ulthobby.com";
        businessDescription = "Ultimate Hobbies is the area's premier destination for radio controlled airplanes, helicopters, boats, cars and off road racers.";
        businessDescription2 = "This is the place to shop for that hobbiest in your life, whether they be a youngster or a seasoned hobbiest you'll find planes, trains and automobiles here with over 4600 plastic models and hundreds and hundreds of mechanized models available.";
    }
    else if (theURL.indexOf("jcmarbleexpo") > 0) {
        businessName = "JC Marble Expo";
        pageTitle = "JC Marble Expo Video";
        address = "25447 Pacific Hwy. S.";
        citystatezip = "Des Moines, WA 98198";
        phone = "(253) 529-1116";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "JC Marble Expo has marble and granite countertops, cabinets, and the Kentwood collection of solid hardwood flooring available for your home improvement project.";
        businessDescription2 = "";
    }
    else if (theURL.indexOf("corkycellars") > 0) {
        businessName = "Corky Cellars";
        pageTitle = "Corky Cellars Video";
        address = "22511 Marine View Drive";
        citystatezip = "Des Moines, WA 98198";
        phone = "(206) 824-9462";
        businessUrlText = "www.corkycellars.com";
        businessUrl = "http://www.corkycellars.com";
        businessDescription = "Corky Cellars is more than just a neighborhood wine shop, it is a place for friends to talk wine and explore the world of the fermented grape.";
        businessDescription2 = "Come in for the complimentary wine tastings, and check out Ric's Picks for fabulous wines under $20, and Dianne's crabby corner.";
        
    }
    else if (theURL.indexOf("xiuxiantea") > 0) {
        businessName = "Xiu Xian Tea";
        pageTitle = "Xiu Xian Tea Video";
        address = "308 Washington Ave. South";
        citystatezip = "Kent, WA 98032";
        phone = "(253) 859-9445";
        businessUrlText = "www.xiuxiantea.com";
        businessUrl = "http://www.xiuxiantea.com";
        businessDescription = "Come to Xiu Xian Tea for authentic Chinese loose leaf tea, stay for the tea ceremony events where you can sit and enjoy free samples.";
        businessDescription2 = "Mako, Robert and their friendly, knowledgable staff will guide you through the world of teas, and they will let you try before you buy.";
        
    }
    else if (theURL.indexOf("forbesfurniture") > 0) {
        businessName = "Forbes Furniture";
        pageTitle = "Forbes Furniture Video";
        address = "1001 Central Ave. North";
        citystatezip = "Kent, WA 98032";
        phone = "(253) 850-9796 ";
        businessUrlText = "www.forbesfurniture.com";
        businessUrl = "http://www.forbesfurniture.com";
        businessDescription = "Forbes Furniture carries high quality, and locally made Therapedic mattresses and solid wood furniture, both finished and unfinished.";
        businessDescription2 = "Whether you want a ready to take home piece or a fully customized and unique furniture set, see Eric and he can help you get exactly what you are looking for.";
    }
    else if (theURL.indexOf("thaichili") > 0) {
        businessName = "Thai Chili";
        pageTitle = "Thai Chili Video";
        address = "120 Washington Ave. North";
        citystatezip = "Kent, WA 98032";
        phone = "(253) 850-5887";
        businessUrlText = "www.mythaichili.com";
        businessUrl = "http://www.mythaichili.com";
        businessDescription = "Thai Chili is a hidden gem in Kent Washington that offers traditional Thai cuisine from a family that has owned and operated restaurants in Thailand.";
        businessDescription2 = "This is an award winning restaurant, and not surprisingly has an abundance of glowing reviews from its patrons.";
        
    }
    else if (theURL.indexOf("goldendynasty") > 0) {
        businessName = "Golden Dynasty Chinese Restaurant";
        pageTitle = "Golden Dynasty Video";
        address = "126 Washington Ave. North";
        citystatezip = "Kent, WA 98032";
        phone = "(253) 859-7025";
        businessUrlText = "";
        businessUrl = "";
        businessDescription = "Golden Dynasty Chinese Restaurant serves authentic, healthy cuisine that is 100% MSG free. Then menu is extensive and includes such favorites as Honey Walnut Shrimp, General Tso's Chicken, Kung Pao 3 Favors, Rainbow Shrimp or Scallop, and Crispy Duck.";
        businessDescription2 = "Dine in, take out, or have them cater your party or banquet.";
        
    }
    else if (theURL.indexOf("littledavidssubs") > 0) {
        businessName = "Little David's Sub Shop";
        pageTitle = "Little David's Sub Shop Video";
        address = "136 Washington Ave. North";
        citystatezip = "Kent, WA 98032";
        phone = "(253) 854-3450";
        businessUrlText = "www.LittleDavidsSubShop.com";
        businessUrl = "http://www.littledavidssubshop.com";
        businessDescription = "Whether you live and work close by or you only get to town occasionally, Little David's Sub Shop is the destination for amazingly delicious sandwiches. Danny and Kelly have searched the country and brought the most sought after subs to add to their menu. At Little David's Sub Shop you'll find the Chicago Combo, New York Italian Sausage, The Boston, the Windy City Special and more.";
        businessDescription2 = "Little David's Sub Shop is also a great place to cater your business luncheon. They can fully customize your order with economical bag lunches or executive box lunches or you can get one of their traditional or specialty sandwich platters.";
        
    }
    else if (theURL.indexOf("pacislandgrill") > 0) {
        businessName = "Pac Island Grill";
        pageTitle = "Pac Island Grill Video";
        address = "2013 S. 320th St. Suite H";
        citystatezip = "Federal Way, WA 98003";
        phone = "(253) 529-8667";
        businessUrlText = "www.hawaiianstylebbq.net";
        businessUrl = "http://www.hawaiianstylebbq.net";
        businessDescription = "Craving the flava of the islands? Look no further than the Pac Island Grill. In the Hawaiian culture ohana means family, and in this family run restaurant you will feel a part of their ohana.";
        businessDescription2 = "Pac Island Grill can also provide that special touch of Aloha for that catered event, whether it be a corporate event or a wedding party for 250 people. They can even provide Hawaiian bands and Hula dancers!";
        businessDescription3 = "";
    }
    else if (theURL.indexOf("hangarcafe") > 0) {
        businessName = "Hangar Cafe";
        pageTitle = "Hangar Cafe Video";
        address = "6261 13th Ave. S.";
        citystatezip = "Seattle, WA 98108";
        phone = "(206) 762-0204";
        businessUrlText = "www.thehangarcafe.com";
        businessUrl = "http://www.thehangarcafe.com";
        businessDescription = "Just north of Boeing field is a small cafe tucked away off 13th Avenue and South Albro Place. When you step inside you'll find a warm and cozy atmosphere and a friendly and cheerful staff.";
        businessDescription2 = "Now for the delicious part, the crepes. Here they can turn crepes into a meal, or satisfy your sweet tooth, and they won the Best of Western Washington award for best crepes so you know they are awesome. They also have great waffles, and for lunch try one of their sandwich and salad plates.";
        businessDescription3 = "";
    }
    else if (theURL.indexOf("99bottles") > 0) {
        businessName = "99 Bottles";
        pageTitle = "99 Bottles Video";
        address = "35002 Pacific Hwy S. A102";
        citystatezip = "Federal Way, WA 98003";
        phone = "(253) 838-2558";
        businessUrlText = "www.99bottles.net";
        businessUrl = "http://www.99bottles.net";
        businessDescription = "99 Bottles beer store has 1000 beers, plus hard ciders and meads.";
        businessDescription2 = "Stop in and mix a brewpack! Choose from American microbrews, beer from over 20 Washington breweries, and world beer imports from Belgium, England, Germany, and more than 40 other countries. There's also brewery t-shirts and hats, proper beer glasses, and beer store gift cards.";
        businessDescription3 = "";
    }
    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;
    }
    if (businessDescription3 != "") {
        document.getElementById('businessdescription3').innerHTML = businessDescription3;
    }


}




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("eastindiagrill") > 0) {
        picName = "eastindiagrill_";
        folderName = "restaurants/eastindiagrill";
        picCount = 7;
    }
    else if (theURL.indexOf("helena") > 0) {
        picName = "helena_";
        folderName = "retail/helena";
        picCount = 15;
    }
    else if (theURL.indexOf("ultimatehobbies") > 0) {
        picName = "ulthobbies_";
        folderName = "retail/ultimatehobbies";
        picCount = 24;
    }
    else if (theURL.indexOf("jcmarbleexpo") > 0) {
        picName = "jcmarbleexpo_";
        folderName = "retail/jcmarbleexpo";
        picCount = 22;
    }
    else if (theURL.indexOf("corkycellars") > 0) {
        picName = "corkycellars_";
        folderName = "retail/corkycellars";
        picCount = 26;
    }
    else if (theURL.indexOf("xiuxiantea") > 0) {
        picName = "xiuxiantea_";
        folderName = "restaurants/xiuxiantea";
        picCount = 16;
    }
    else if (theURL.indexOf("forbesfurniture") > 0) {
        picName = "forbesfurniture_";
        folderName = "retail/forbesfurniture";
        picCount = 56;
    }
    else if (theURL.indexOf("thaichili") > 0) {
        picName = "thaichili_";
        folderName = "restaurants/thaichili";
        picCount = 18;
    }
    else if (theURL.indexOf("goldendynasty") > 0) {
        picName = "goldendynasty_";
        folderName = "restaurants/goldendynasty";
        picCount = 11;
    }
    else if (theURL.indexOf("littledavidssubs") > 0) {
        picName = "littledavids_";
        folderName = "restaurants/littledavidssubs";
        picCount = 11;
    }
    else if (theURL.indexOf("pacislandgrill") > 0) {
        picName = "pacislandgrill_";
        folderName = "restaurants/pacislandgrill";
        picCount = 15;
    }
    else if (theURL.indexOf("hangarcafe") > 0) {
        picName = "hangarcafe_";
        folderName = "restaurants/hangarcafe";
        picCount = 11;
    }
    else if (theURL.indexOf("99bottles") > 0) {
        picName = "99bottles_";
        folderName = "restaurants/99bottles";
        picCount = 7;
    }
    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("eastindiagrill") > 0) {
            map.setCenter(new GLatLng(47.316855, -122.300660), 15);
            point = new GLatLng(47.316855, -122.300660);
            marker = createMarker(point, 'East India Grill')
        }
        else if (theURL.indexOf("helena") > 0) {
            map.setCenter(new GLatLng(47.329856, -122.311691), 15);
            point = new GLatLng(47.329856, -122.311691);
            marker = createMarker(point, 'Helena Catholic Book & Gifts')
        }
        else if (theURL.indexOf("allwoodfurniture") > 0) {
            map.setCenter(new GLatLng(47.360665, -122.307603), 15);
            point = new GLatLng(47.360665, -122.307603);
            marker = createMarker(point, 'All Wood Furniture')
        }
        else if (theURL.indexOf("ultimatehobbies") > 0) {
            map.setCenter(new GLatLng(47.307555, -122.227359), 15);
            point = new GLatLng(47.307555, -122.227359);
            marker = createMarker(point, 'Ultimate Hobbies')
        }
        else if (theURL.indexOf("jcmarbleexpo") > 0) {
            map.setCenter(new GLatLng(47.373050, -122.301939), 15);
            point = new GLatLng(47.373050, -122.301939);
            marker = createMarker(point, 'JC Marble Expo')
        }
        else if (theURL.indexOf("corkycellars") > 0) {
            map.setCenter(new GLatLng(47.399995, -122.324899), 15);
            point = new GLatLng(47.399995, -122.324899);
            marker = createMarker(point, 'Corky Cellars')
        }
        else if (theURL.indexOf("xiuxiantea") > 0) {
            map.setCenter(new GLatLng(47.379413, -122.245892), 15);
            point = new GLatLng(47.379413, -122.245892);
            marker = createMarker(point, 'Xiu Xian Tea')
        }
        else if (theURL.indexOf("forbesfurniture") > 0) {
            map.setCenter(new GLatLng(47.391816, -122.230706), 15);
            point = new GLatLng(47.391816, -122.230706);
            marker = createMarker(point, 'Forbes Furniture')
        }
        else if (theURL.indexOf("thaichili") > 0) {
            map.setCenter(new GLatLng(47.381896, -122.246275), 15);
            point = new GLatLng(47.381896, -122.246275);
            marker = createMarker(point, 'Thai Chili')
        }
        else if (theURL.indexOf("goldendynasty") > 0) {
            map.setCenter(new GLatLng(47.381949, -122.246249), 15);
            point = new GLatLng(47.381949, -122.246249);
            marker = createMarker(point, 'Golden Dynasty Chinese Restaurant')
        }
        else if (theURL.indexOf("littledavidssubs") > 0) {
            map.setCenter(new GLatLng(47.381957, -122.246690), 15);
            point = new GLatLng(47.381957, -122.246690);
            marker = createMarker(point, 'Little David\'s Sub Shop')
        }
        else if (theURL.indexOf("pacislandgrill") > 0) {
            map.setCenter(new GLatLng(47.317247, -122.307364), 15);
            point = new GLatLng(47.317247, -122.307364);
            marker = createMarker(point, 'Pac Island Grill')
        }
        else if (theURL.indexOf("hangarcafe") > 0) {
            map.setCenter(new GLatLng(47.546729, -122.316381), 15);
            point = new GLatLng(47.546729, -122.316381);
            marker = createMarker(point, 'Hangar Cafe')
        }
        else if (theURL.indexOf("99bottles") > 0) {
            map.setCenter(new GLatLng(47.288154, -122.318082), 15);
            point = new GLatLng(47.288154, -122.318082);
            marker = createMarker(point, '99 Bottles')
        }
        map.setMapType(G_HYBRID_MAP);
        map.enableGoogleBar();
        map.enableScrollWheelZoom();
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.addControl(new GOverviewMapControl());
        map.addOverlay(marker);
    }
}
