﻿
$(document).ready(function() {

    /** BEGIN - NAV JQUERY **/
    $('li.navlink').hover(
            function() {
                // show the submenu
                $('ul', this).slideDown(200);
            },
            function() {
                // hide the submenu
                $('ul', this).slideUp('slow');
            });

    $('.hidden').hide();
    /** END - NAV JQUERY **/

    /** BEGIN - LEAD FORMS **/
    $("#ctl00_ctl00_ContentPlace_BodyCopy_share_friend").click(function() {
        var checked_status = this.checked;
        if (checked_status == true) {
            $("#sharefriends").show();
        }
        else {
            $("#sharefriends").hide();
        }
    });
    $("#ctl00_ContentPlace_BodyCopy_share_friend").click(function() {
        var checked_status = this.checked;
        if (checked_status == true) {
            $("#sharefriends").show();
        }
        else {
            $("#sharefriends").hide();
        }
    });

    /** BEGIN - MAPS **/
    $("#mapContainer").css("display", "none");

    //trigger the map after a postal code
    $('#mapGO').click(function() {

        var postalCodeSent = $("#" + mapAddressID).val();
        var teenfitGenderFilter = $("#hgen").val();
        //alert (postalCodeSent);
        //find this function in the gMaps_forms.js
        showAddress(postalCodeSent);
        //set up the array 
        var detailsArray = "";

        result = $.getJSON(
		    "../WebServices/GetClubsByPostalCode.ashx",
		    { PostalCode: postalCodeSent, Gender: teenfitGenderFilter },

		    function(data, a, b) {
		        var options = "";
		        options += "<option value=\"\">Select a club...</option>";

		        for (var i = 0; i < data.Clubs.length; i++) {
		            options += "<option value=\"" + data.Clubs[i].Lat + "_" + data.Clubs[i].Long + "_" + data.Clubs[i].ClubNo + "\">" + data.Clubs[i].ClubName + "</option>";
		            placeClubMarker(data.Clubs[i].Lat, data.Clubs[i].Long, data.Clubs[i].ClubNo, data.Clubs[i].ClubName, data.Clubs[i].Address1, data.Clubs[i].City, data.Clubs[i].Prov, data.Clubs[i].Gender);
		            setSelectedClubData(i, data.Clubs[i].Address1, data.Clubs[i].City, data.Clubs[i].Prov, data.Clubs[i].Gender);
		            
		            //build an array so we can access these once they've clicked
		            //detailsArray[i] = data.Clubs[i].Email+"_"+data.Clubs[i].Address1+"_"+data.Clubs[i].Address2+"_"+data.Clubs[i].City+"_"+data.Clubs[i].Prov+"_"+data.Clubs[i].Postal+"_"+data.Clubs[i].Phone+"_"+data.Clubs[i].Fax+"_"+data.Clubs[i].Gender
		            //use any -- Email, Address1, Address2, City, Prov, Postal, Phone, Fax, Gender

		        }
		        $("#mapClub").html(options);
		        //alert (options);

		        $("select#mapClub option:first").attr("selected", "selected");
		    });

        //showAddress(postalCodeSent);
        $("#mapContainer").show();
    });
    /** END - LEAD FORM & MAPS **/

    /** BEGIN - TEEN FITNESS **/
    $('#submitOne').click(function() {
        $('#accordion').accordion("activate", 1);
    });
    $('#submitTwo').click(function() {
        $('#accordion').accordion("activate", 2);
    });
    $('#submitThree').click(function() {
        $('#accordion').accordion("activate", 3);
    });
    /** END - TEEN FITNESS **/
});
