// content.js

// ---------------------------------
//
// ---------------------------------

var arrMonths = new Array();
arrMonths[1] = "January";
arrMonths[2] = "February";
arrMonths[3] = "March";
arrMonths[4] = "April";
arrMonths[5] = "May";
arrMonths[6] = "June";
arrMonths[7] = "July";
arrMonths[8] = "August";
arrMonths[9] = "September";
arrMonths[10] = "October";
arrMonths[11] = "November";
arrMonths[12] = "December";


// ---------------------------------
//
// ---------------------------------

var arrContent = new Array();

var strHome = "<h2>back by popular demand...<h2><h1><b>FREE</b> social group runs ARE BACK!</h1><h3>All levels welcome and encouraged!  View the <a href='javascript:showCalendar();'>Calendar </a> for times and locations or <a href='javascript:changeContent(5);'>contact me</a> for more details.</h3>"
strHome += "<br /><input type='button' value='Register Now!' class='frmButton' onclick='javascript:changeContent(5);'>"
strHome += "<br/><br/><table cellspacing='20'><tr><td><img src='images/mandi.jpg' style='float:left;margin:0px 10px 0px 0px;'><h1>I had lost 30 lbs, over 30 inches and went from a size 18 to a size 8!</h1><h3>I have been a customer of Pura Vida Fitness for close to 2 years. After having my third child I had gained some unnecessary weight and behaviors.  ";
strHome += "A friend of mine gave me a gift certificate for 2 personal training sessions at Pura Vida for use at my convenience. I am so happy I chose to call. I used my 2 sessions and was hooked! Over the course of 1 year training with Lisa, I had lost 30 lbs, over 30 inches and went from a size 18 to a size ";
strHome += "8! I also accomplished many personal fitness goals I had only ever dreamed about. In Dec 2010, I ran the Kiawah Half Marathon and completed my goal of running non-stop in 2:25 min and Lisa was by my side the whole time. Then in May 2011, I completed the Flying Pig Marathon, followed by the Air Force Marathon in September. Currently I am ";
strHome += "training for my #3!!!<br/></br/>";
strHome += "Lisa keeps me moving forward!!! With her guidance, my body and my mind are forever changed. My confidence is higher, lifestyle is healthier and my kids have a great role model in their life.<br/><br/>- Mandi</h3></td></tr>";
strHome += "<tr><td><img src='images/Desiree.jpg' width=259 height=194 style='float:left;margin:0px 10px 0px 0px;'>";
strHome += "<h3>When I first started training with Lisa, I could hardly run a mile and I was overweight. After a year, I lost 40 lbs. and was able to finish a half marathon. I just turned 30 and I am easily in the best shape of my life. I couldn't have done it without Lisa at Pura Vida Fitness.<br /><br />-Desiree</h3></td></tr>";
strHome += "</table>";
arrContent[0] = strHome;

var strTraining = "<h1>Personal Training</h1><br/>";
//strTraining = strTraining + "*Package Deals:<br/>4 sessions/1 session per week = $200 per month ($50/ea)<br/>8 sessions/2 sessions per week = $384 ($48/ea)<br/>12 sessions/3 sessions per week = $552 ($46/ea)<br/>16 sessions/4 sessions per week = $704 ($44/ea)<br/><br/>";
//strTraining = strTraining + "Virtual Trainer: $600 per month<br/><br/>";
//strTraining = strTraining + "*24 hour cancellation fee applies<br/>*All session packages expire 40 days from 1st session</h3>";
strTraining += "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'><input type='hidden' name='cmd' value='_s-xclick'><input type='hidden' name='hosted_button_id' value='XSA65URS3SHCU'><table><tr><td><input type='hidden' name='on0' value='Personal Training Packages'>Personal Training Packages</td></tr><tr><td><select name='os0'> <option value='4 Sessions'>4 Sessions $200.00 USD</option> <option value='8 Sessions'>8 Sessions $384.00 USD</option> <option value='12 Sessions'>12 Sessions $552.00 USD</option> <option value='16 Sessions'>16 Sessions $704.00 USD</option></select> </td></tr></table><input type='hidden' name='currency_code' value='USD'><input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif' border='0' name='submit' alt='PayPal - The safer, easier way to pay online!'><img alt='' border='0' src='https://www.paypalobjects.com/en_US/i/scr/pixel.gif' width='1' height='1'></form";
arrContent[1] = strTraining;

var strBootCamp = "<h1>Boot Camps</h1><br/><h3><u>Boot Camp Schedule beginning March 1st:</u><br/>Tuesday/Thursday/Friday 6:00AM (West Ashley)<br/>Monday/Wednesday/Thursday 5:30PM (Mount Pleasant)<br/><br/><u>Rate:</u> $80.00 per month<br/><br/><u>Locations:</u><br/>West Ashley location: 1250 Wappoo Road Charleston, SC 29407<br/>Mount Pleasant location: Mount Pleasant Waterfront Park, Harry Hallman Blvd</h3>";
strBootCamp += "<div id='divMap' style='width:300px;height300px;'></div>";
arrContent[2] = strBootCamp;

var strFAQ = "<h1>Frequently Asked Questions</h1><br />";
strFAQ += "<h3><b>Q: What kind of workout can I expect?</b><br />A: This is a high intensity class mixing cardio, plyometrics, body weight resistance exercises, calisthenics, games, challenges and FUN!<br /><br /></h3>";
strFAQ += "<h3><b>Q: What if I am a beginning or out of shape?</b><br />A: This class is designed for all level of fitness. The more fit you become the more you will be able to finish. There are always all individuals of levels of fitness in the classso you will not be alone.<br /><br /></h3>";
strFAQ += "<h3><b>Q: How much is it?</b><br />A: $80 per month. You will receive a 10% discount if you sign up for Automated Recurring Billing. This is easy to end and only a 15 day notice is required.<br /><br /></h3>";
strFAQ += "<h3><b>Q: How can I get started?</b><br />A: You can register through the Boot Camp section of the website or from the Calendar.<br /><br /></h3>";
strFAQ += "<h3><b>Q: What should I bring?</b><br />A: Water. A towel and/or mat are optional.<br /><br /></h3>";
strFAQ += "<h3><b>Q: What should I wear?</b><br />A: Comfortable clothes that allow movement and are weather appropriate. A good pair of running shoes is highly recommended.<br /><br /></h3>";
strFAQ += "<h3><b>Q: How do I get there?</b><br />A: There is a map of both boot camps on the Calendar.<br /><br /></h3>";
strFAQ += "<h3><b>Q: Where do we meet?</b><br />A: West Ashley indoor class meets inside Charleston Krav Maga building. Mount Pleasant outdoor class meets at the Waterfront Park by the flower bed (unless it rains... see rain location below).<br /><br /></h3>";
strFAQ += "<h3><b>Q: What if it rains?</b><br />A: We have class rain or shine. In Mount Pleasant we meet in the parking lot across the street from the lot next to the park. We work out under the Bridge which shelters us from rain. For our safety, class will be cancelled if it is lightning.<br /><br /></h3>";
strFAQ += "<h3><b>Q: What if I miss a class or need to be out of town?</b><br />A: Unfortunately, it is a monthly class which begins on your first day and ends 30 days after regardless of attendance. This strategy tends to help members stay accountable and attend as often as possible.<br /><br /></h3>";
arrContent[3] = strFAQ;

var strStore = "<h1>Store Coming Soon!</h1>";
arrContent[4] = strStore;

var strContact = "<h1>Contact me!</h1>";
strContact = strContact + "<table><tr><td><h3>Name:</h3></td><td><input type='text' id='txtName' class='frmButton' size='40'></tr>";
strContact = strContact + "<tr><td><h3>Email:</h3></td><td><input type='text' id='txtEmail' class='frmButton' size='40'></td></tr>";
strContact = strContact + "<tr><td><h3>Phone:</h3></td><td><input type='text' id='txtPhone' class='frmButton' size='40'></td></tr>";
strContact = strContact + "<tr><td><h3>Message:</h3></td><td><textarea id='txtMsg' class='frmButton' cols='40' rows='5'></textarea></td></tr>";
//strContact += "<tr align='center'><td><h3>Security Image: </h3></td><td style='text-align:left;'><img src='http://www.pvstyle.com/captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5' /></td></tr>";
//strContact += "<tr align='center'><td><h3>Security Code: </h3></td><td style='text-align:left;'><input id='security_code' name='security_code' type='text' class='frmButton' /><br /></td></tr>";
strContact += "<tr><td colspan='2' align='center'><input type='button' value='Send Message' class='frmButton' onclick='javascript:sendMsg()'; style='margin:10px;'></td></tr>";
strContact += "</table>";
strContact += "<h3><b>Lisa Lewerke</b><br />Owner<br />ACE Certified Personal Trainer<br />Certified Crossfit Level 1<br />ph 843.697.9808</h3>";
arrContent[5] = strContact;

function Load() {

    document.getElementById("divMain").innerHTML = arrContent[0];
    var curMonth = 0;

    var strBlogMenu = "<h2><b>Trainer Lisa's Blog</b></h2>";
    var feed = new google.feeds.Feed("http://personaltrainerlisa.blogspot.com/feeds/posts/default");
    feed.load(function (result) {
        if (!result.error) {
            var container = document.getElementById("divBlogNav");
            for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var entryDate = new Date(entry.publishedDate);
                var theMonth = entryDate.getMonth() + 1;

                var theDate = theMonth + "/" + entryDate.getDate() + "/" + entryDate.getFullYear();
                theContent = theDate + "<br/><br/>" + entry.content;

                if (curMonth == theMonth) {

                } else {
                    strBlogMenu = strBlogMenu + "<h3>" + arrMonths[theMonth] + " " + entryDate.getFullYear() + "</h3>";
                }
                strBlogMenu = strBlogMenu + "<h3 class='blogTitle'><a href='javascript:showBlogItem(theContent);'>" + entry.title + "</a></h3>";
                var div = document.createElement("div");

                div.innerHTML = strBlogMenu;
                container.appendChild(div);
                curMonth = theMonth;
            }
        }
    });

    var myOptions = {
        center: new google.maps.LatLng(-34.397, 150.644),
        zoom: 8,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("divMap"),
            myOptions);

}

function showBlogItem(content) {
    document.getElementById('divMain').innerHTML = "<h3>" + content + "</h3>";
}

function showCalendar() {

    var calWidth = window.screen.availWidth * .4;
    var calHeight = calWidth * .75;
    
    document.getElementById('divMain').innerHTML = "<iframe src='https://www.google.com/calendar/embed?title=Pura%20Vida%20Fitness%20Boot%20Campt%20%26%20Event%20Calendar&amp;height=600&amp;wkst=1&amp;bgcolor=%23FFFFFF&amp;src=jpecs77n9a7r2022ecni4o2ooc%40group.calendar.google.com&amp;color=%23B1440E&amp;ctz=America%2FNew_York' style=' border-width:0 ' width='" + calWidth + "' height='" + calHeight + "' frameborder='0' scrolling='no'></iframe>"

}

function changeContent(page) {
    document.getElementById("divMain").innerHTML = arrContent[page];
}

function register() {

}

function sendMsg() {

    var options = "";

    // validating the form
    if (document.getElementById("txtName").value == "") {
        alert("You must enter your name");
        return;
    }

    if (document.getElementById("txtEmail").value == "") {
        if (document.getElementById("txtPhone").value == "") {
            alert("You must enter an email address or a phone number");
            return;
        }
    }

    if (document.getElementById("txtMsg").value == "") {
        alert("You must enter a message.");
        return;
    }

    options = "frmName=" + document.getElementById("txtName").value + "&frmEmail=" + document.getElementById("txtEmail").value + "&frmPhone=" + document.getElementById("txtPhone").value + "&frmMsg=" + escape(document.getElementById("txtMsg").value);

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

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

}

function AJAXresponse() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        //alert(xmlhttp.responseText);
        if (xmlhttp.responseText == 1) {
            document.getElementById("divMain").innerHTML = "Your message has been sent.  I will respond to your message as quickly as possible.  Thank you for your interest in PuraVida!";
            window.status = "Message sent";
            
        } else {
            //if (xmlhttp.responseText == 2) {
                //alert("Sorry, you have provided an invalid security code.");
            //} else {
                window.status = "I'm sorry but there was an error sending your message.  Please email me directly at lisa@PuraVidaFitnessSC.com or call 843-697-9808.";
            //}
        }
    } else {
        window.status = "Sending your message...";
    }
    window.status = "Done";
}

//------------------------------------------
// 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();
