﻿// content.js
// ---------------------------

// ---------------------------
// ---------------------------
// VARIABLES
// ---------------------------
var arrContent = new Array;
arrContent[0] = "strHome";
arrContent[1] = "strPractice";
arrContent[2] = "strFacility";
arrContent[3] = "strFees";
arrContent[4] = "strCoaches";
arrContent[5] = "strFAQ";
arrContent[6] = "strMeets";
arrContent[7] = "strEvents";
arrContent[8] = "strCalendar";
arrContent[9] = "strLinks";
arrContent[10] = "strContact";
arrContent[11] = "strFollow";

var strHome = "<h4>SMRT Masters Swimming is a comprehensive year-round teaching and training program that helps adults 18 and older pursue their lifetime fitness goals and enhance their lives through swimming.";
strHome = strHome + "<br /><br />SMRT Masters is open to all who want to incorporate swimming into their fitness routines.  We are a diverse group:  men and women from their early 20s to mid-70s, teachers, salespeople, engineers, musicians, scientists, lawyers, writers, students, retirees and more.  Participants have a wide variety of swimming backgrounds, from virtually none to life-long involvement in competitive swimming.  Fitness swimmers, open water swimmers, triathletes and competitive pool swimmers are all welcome and benefit from the program.  Skill levels range from those new to the sport to world-class athletes.";
strHome = strHome + "<br /><br />Southern Marlins Racing Team is the City of Charleston’s competitive swim team for young people.  SMRT Masters is also a part of the City of Charleston Recreation Department and is affiliated with United States Masters Swimming.";
strHome = strHome + "<br /><br />New swimmers are welcome at any time.  Introduce yourself to the coach on deck.  The coach will provide introductions and useful information and will find an appropriate lane.  You are welcome to give it a try for free for up to two weeks.  If you want to continue after the trial period, complete the SMRT Masters registration form, pay your fees and dive in!";
strHome = strHome + "</h4";

var strPractice = "<h4><b>Practice Times</b>";
strPractice = strPractice + "<br /><br />Monday through Friday 5:45AM - 7:00AM";
strPractice = strPractice + "<br />Saturday 7:00AM - 8:00AM";
strPractice = strPractice + "<br /><br />Most practices are held at the City of Charleston <a href='javascript:changeContent(2);'>Martin Luther King, Jr. aquatic center</a>.  Please check the team calendar or contact us to verify the workout location.";
strPractice = strPractice + "</h4>";

var strFacility = "<h4><b>SMRT Training Facilities</b>";
strFacility = strFacility + "<br /><br /><b>Martin Luther King, Jr. (MLK) Aquatic Center</b>";
strFacility = strFacility + "<br />MLK is a 50 meter pool located in downtown Charleston, South Carolina.";
strFacility = strFacility + "<br />155 Jackson St.<br />Charleston , SC 29403<br />Phone (843) 724-7346";
strFacility = strFacility + "<hr />";
strFacility = strFacility + "<br /><b>W.L. Stephens Aquatic Center</b>";
strFacility = strFacility + "<br />W.L. Stephens is a 25 meter pool located in West Ashley";
strFacility = strFacility + "<br />780 West Oak Forest Dr<br />Charleston, SC 29407<br />Phone (843) 769-8261";
strFacility = strFacility + "</h4>";

var strFees = "<h4>There are three fees associated with the City of Charleston Master's Program.  The first is a City annual pool pass which gives you access to all City pools.  The second fee is a coaching fee that helps pay the salaries of our coaches.  The third fee is to US Masters Swimming.  Questions about fees should be directed to the SMRT Masters Coaches.";
strFees = strFees + "<br /><br /><b>City Pool Pass*</b>";
strFees = strFees + "<table cellpadding=3><tr><td>City of Charleston Resident</td><td>$80/year</td></tr><tr><td>Non-City Resident</td><td>$150/year</td></tr><tr><td>City Employee</td><td>$40/year</td></tr></table>";
strFees = strFees + "</h4>";
strFees = strFees + "<h6>*Fee Rates are 9/1 through 8/31 and can be prorated when joining mid-season.  Pass provides access to all City pools.</h6>";
strFees = strFees + "<br /><h4><b>Coaching fees</b>";
strFees = strFees + "<br />$15.00/month or $75.00/6 months (get 1 month free!)";
strFees = strFees + "<br /><br /><b>US Masters Swimming Membership</b>";
strFees = strFees + "<br />$37.00/year";
strFees = strFees + "</h4>";

var strCoaches = "<h4><table>";
strCoaches = strCoaches + "<tr><td><img src='images/coachBen.JPG'><b>Ben Pulskamp</b><br />Coach Ben joined the SMRT coaching staff in August, 2009.  He has 18 years of competitive swimming experience.  He spent 14 years on the Y-Spartaquatics swim team in Spartanburg, SC.  He led Spartanburg High School to four State Championships.  He graduated from University of North Carolina Wilmington after winning four CAA conference swimming championships and won UNCW’s most Outstanding Swimmer Award in 2004. He was team captain his senior year of high school, as well as his senior year in college.  While at the Universityof North Carolina Wilmington, he worked as a swim instructor for the UNCW Swim Camp.</td></tr>";
strCoaches = strCoaches + "<tr><td><img src='images/coachJim.JPG'><b>James Niergarth</b><br />Coach Jim joined the SMRT coaching staff in May/June 2010. He has 16 years of competitive swimming experience. He spent 10 of those years swimming for M.E. Lyons YMCA/Anderson Barracudas then switched over to the Cincinnati Marlins. He swam at Saint Xavier High School and Claremont McKenna College. He placed 3rd at conference championships in the 1650 all 4 years during his college career which helped his team to three 2nd place finishes and one 1st place finish his senior year. He is very excited to join the SMRT family.</td></tr>";
strCoaches = strCoaches + "</table>";

var strFAQ = "<h4><b>Frequently Asked Questions</b>";
strFAQ = strFAQ + "<br /><br /><b>What skills do I need?</b><br />Modest swim ability (even if only one stroke); stamina to swim at least 500 yards is recommended; and a desire to get better!";
strFAQ = strFAQ + "<hr />";
strFAQ = strFAQ + "<b>What equipment do I need?</b><br />A comfortable suit, goggles, cap if desired; swim fins and pull buoy recommended, though some are available at the pool.";
strFAQ = strFAQ + "<hr />";
strFAQ = strFAQ + "<b>Are there opportunities to compete?</b><br />Yes, in local, state, regional, national and international pool competitions; in open water swims, biathlons and triathlons, etc";
strFAQ = strFAQ + "<hr />";
strFAQ = strFAQ + "<b>Do I have to compete?</b><br />No.  Many SMRT Masters do not compete and it is not required or expected.";
strFAQ = strFAQ + "<hr />";
strFAQ = strFAQ + "<b>What are the workouts like?</b><br />Coaches design challenging workouts for different ability levels and goals.  Workouts are designed to build fitness, aerobic endurance and anaerobic speed, and to improve stroke skills and technique.  You will be swimming in a lane with others who have similar abilities and goals.";
strFAQ = strFAQ + "<hr />";
strFAQ = strFAQ + "<b>Sounds great - how do I get started?</b><br />Just come to practice, talk with the coach, and jump right in.";
strFAQ = strFAQ + "</h4>";

var strMeets = "<h4><b>Upcoming Swim Meets and Events</b>";
strMeets = strMeets + "<table cellpadding='5px'>";
strMeets = strMeets + "<tr><th>Date</th><th>Event</th></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>January 28-29, 2012</td><td><a href='http://www.usms.org/comp/event.php?MeetID=20120128SUNBLTY' target='_blank'>38th Annual Sunbelt Meet</a><br />SCY in Charlotte, NC</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>February 10-12, 2012</td><td><a href='http://www.dixiezone.org/Meets.htm' target='_blank'>SCY State Championship</a><br />SCY in North Myrtle Beach, SC</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>March 10, 2012</td><td><a href='http://www.dixiezone.org/Meets.htm' target='_blank'>SCY Relay Meet</a><br />SCY in Duncan, SC</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>May 19, 2012</td><td><a href='http://www.lowcountrysplash.com/' target='_blank'>Lowcountry Splash (2.3 miles) </a><br />Open Water Swim in Charleston, SC</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>April 26 - 29, 2012</td><td><a href='http://www.usms.org/comp/event.php?MeetID=20120426SCNATSY' target='_blank'>2012 U.S. Masters Swimming Spring National Championship</a><br />SCY Nationals at Greensboro Aquatic Center</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>June 23, 2012</td><td><a href='http://www.usms.org/comp/event.php?MeetID=20120623USOW5KO' target='_blank'>USMS 5K Open Water National Championships</a><br />Open Water Nationals in Noblesville, Indiana</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>July 5 - 8, 2012</td><td><a href='http://www.usms.org/comp/event.php?MeetID=20120705LCNATSL' target='_blank'>2012 U.S. Masters Swimming Summer National Championship</a><br />LCM National at Qwest Center, Omaha, NE</td><td></td></tr>";
strMeets = strMeets + "<tr class='trEvents'><td>August 4-5, 2012</td><td><a href='http://www.dixiezone.org/Meets.htm' target='_blank'>2012 LCM Dixie Zone & SC State Championship </a><br />LCM in Greenville, SC</td><td></td></tr>";
strMeets = strMeets + "</table>";
strMeets = strMeets + "</h4>";

var strEvents = "<h4><b>Upcoming Team Events</b>";
strEvents = strEvents + "</h4>";

var strCalendar = "<iframe src='https://www.google.com/calendar/embed?height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=tg9j73has2gj2llav473i4i6t0%40group.calendar.google.com&amp;color=%232952A3&amp;ctz=America%2FNew_York' style='border-width:0' width='800' height='600' frameborder='0' scrolling='no'></iframe>";

var strLinks = "<h4>";
strLinks = strLinks + "<a href='http://www.swimsmrt.com'>SMRT Age Group Team</a>";
strLinks = strLinks + "<br /><a href='http://www.southcarolinamastersswimming.org'>SC Masters Swimming</a>";
strLinks = strLinks + "<br /><a href='http://www.dixiezone.org'>US Masters Dixie Zone Swimming</a>";
strLinks = strLinks + "<br /><a href='http://www.usms.org'>US Masters Swimming</a>";
strLinks = strLinks + "<br /><a href='http://www.charlestontriathlonclub.com'>Charleston Triathlon Club</a>";
strLinks = strLinks + "<br /><a href='http://www.coastalcyclists.org'>Coastal Cyclists</a>";
strLinks = strLinks + "</h4>";

var strContact = "<table>";
strContact = strContact + "<tr class='trEvents'><td>Name:</td><td><input id='frmName' type='text' size='50'></td></tr>";
strContact = strContact + "<tr class='trEvents'><td>Email:</td><td><input id='frmEmail' type='text' size='50'></td></tr>";
strContact = strContact + "<tr class='trEvents'><td>Message:</td><td><textarea id='frmMsg' type='text' cols='50' rows='20'></textarea></td></tr>";
strContact = strContact + "<tr align='center'><td colspan='2'><input type='button' value='submit' class='frmButton' onclick='javascript:sendMsg();'></td></tr>";
strContact = strContact + "</table>";

var strFollow = "<h4>";
strFollow = strFollow + "<a href='http://groups.google.com/group/SMRTmasters' target='_blank'><img src='images/Google-Groups-48.png' title='Google Groups'><a>";
strFollow = strFollow + "<a href='http://www.facebook.com/group.php?gid=218937785660' target='_blank'><img src='images/facebook_icon.png' title='Facebook'></a>";
strFollow = strFollow + "</h4>";

// ---------------------------
// FUNCTIONS
// ---------------------------

function load() {
    document.getElementById("divContent").innerHTML = strHome;
}

function changeContent(theLink) {

    document.getElementById("divContent").innerHTML = eval(arrContent[theLink]);

}

function showBlog() {
    document.getElementById("divContent").innerHTML = "";
    var feed = new google.feeds.Feed("http://smrtmasters.blogspot.com/feeds/posts/default");
    feed.setNumEntries(2)
    feed.load(function (result) {
        if (!result.error) {
            var container = document.getElementById("divContent");
            //for (var i = 0; i < 2; i++) {
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
                var html = "<b>" + entry.title + "</b><br/>" + entry.publishedDate + "<br/>" + entry.content;
                div.innerHTML = html;
                container.appendChild(div);
            }
        }
    });
}

function sendMsg() {

    var options = "";
    if (document.getElementById("frmName").value=="") {
        alert("You must enter your name");
        return;
    }

    if (document.getElementById("frmEmail").value=="") {
        alert("You must enter an email address");
        return;
    }

    if (document.getElementById("frmMsg").value=="") {
        alert("You must enter a message for the coaches");
        return;
    }

    options = "frmName=" + document.getElementById("frmName").value + "&frmEmail=" + document.getElementById("frmEmail").value + "&frmMsg=" + escape(document.getElementById("frmMsg").value);

    var url = "php/sendmsg.php?" + options;

    xmlhttp.open("GET", url, true);
    xmlhttp.onreadystatechange = AJAXresponse;
    xmlhttp.send();

}


//------------------------------------------
// AJAX
//------------------------------------------

// set up the AJAX Request
function getXMLHTTPRequest() {
    var request = false;
    //Mozilla, Safari, etc
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
        if (request.overrideMimeType) {
            request.overrideMimeType('text/xml');
        }
        //IE
    } else if (window.ActiveXObject) {
        try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) { }
        }
    }
    if (!request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    return request;
}

var xmlhttp = getXMLHTTPRequest();

function AJAXresponse() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        //alert(xmlhttp.responseText);
        if (xmlhttp.responseText == 1) {
            document.getElementById("divContent").innerHTML = "Your message has been sent.  A SMRT coach will respond to your message as quickly as possible.  Thank you for contacting us - we hope to see you soon!";
            window.status = "Message sent";
        } else {
            window.status = "There was an error sending your message.";
        }
    } else {
        window.status = "Sending your message...";
    }
}

