﻿$(document).ready(function() {
    //PHYSICIAN LOCATOR
    $('#zip').focus(function() {
        if ($('#zip').val() == 'enter zip code') {
            $('#zip').val('')
        }
    })

    $('#zip').blur(function() {
        if ($('#zip').val() == '') {
            $('#zip').val('enter zip code')
        }
    })

    //NAV ACTIVE STATE
    $("#Navigation a").filter(function() {
        //Take the current URL and split it into chunks at each slash
        var currentURL = window.location.toString().split("/");

        if ($(this).attr("href") == currentURL[currentURL.length - 1]) {
            return true;
        }

        var navURL = $('meta[name=NavigationURL]').attr("content");

        return $(this).attr("href") == navURL;

    }).addClass("ActiveNav");

    $("#PhysicianNavigation a").filter(function() {
        //Take the current URL and split it into chunks at each slash
        var currentURL = window.location.toString().split("/");

        if ($(this).attr("href") == currentURL[currentURL.length - 1]) {
            return true;
        }

        var navURL = $('meta[name=NavigationURL]').attr("content");

        return $(this).attr("href") == navURL;

    }).addClass("ActiveNav");

    //PATIENT STORIES IMAGE SWAP
    $('.ImagePreview').click(function() {
        // get the ID of the image to fade in
        var smallImageID = $(this).attr("id").replace('Small', '');

        $('#PatientMainImage').fadeOut(300, function() {
            // when the fade out is done, fade in the new image
            $("#PatientMainImage").attr({ src: 'images/' + smallImageID + '.jpg' }).fadeIn(300);
        });

        //update "active" small image
        if ($('.SmallImages img.ActiveBorder').length > 0) {
            $('.SmallImages img.ActiveBorder').removeClass('ActiveBorder');
        }
        $(this).addClass('ActiveBorder');
    });

    //PATIENT STORIES ACTIVE SIDE NAV
    $(".PatientNav a").filter(function() {
        //Take the current URL and split it into chunks at each slash
        var currentURL = window.location.toString().split("/");

        if ($(this).attr("href") == currentURL[currentURL.length - 1]) {
            return true;
        }
    }).addClass("Active");

    //EVOLUTION SCIENCE TOOLTIP
    $('.ToolTip').mouseenter(function() {
        var targetID = $(this).attr("id");

        switch (targetID) {
            case 'ToolTip1':
                $('#ToolTipText').attr('innerHTML', '<p>Top Stem Segment</p><ul><li>Plasma Coated</li><li>12, 14, 16mm diameter</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow1.png');
                break;
            case 'ToolTip2':
                $('#ToolTipText').attr('innerHTML', '<p>Modular Mid-Stem Segments</p><ul><li>Plasma Coated</li><li>12, 14, 16, & 18mm diameter</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow2.png');
                break;
            case 'ToolTip3':
                $('#ToolTipText').attr('innerHTML', '<p>Stem Base Segment</p><ul><li>Plasma Coated</li><li>16 & 18mm diameters</li><li>Morse taper connection</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow3.png');
                break;
            case 'ToolTip4':
                $('#ToolTipText').attr('innerHTML', '<p>Tibial Bases</p><ul><li>5 anatomical sizes (L&R)</li><li>Plasma Coated undersurface</li><li>Morse taper connection</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow4.png');
                break;
            case 'ToolTip5':
                $('#ToolTipText').attr('innerHTML', '<p>Polyethylene Inserts</p><ul><li>EtO Sterilized</li><li>Available in 7 – 15mm thick</li><li>“Plus” sizes for size interchangeability</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow5.png');
                break;
            case 'ToolTip6':
                $('#ToolTipText').attr('innerHTML', '<p>Talar Domes</p><ul><li>5 anatomical sizes</li><li>Plasma Coated undersurface</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow6.png');
                break;
            case 'ToolTip7':
                $('#ToolTipText').attr('innerHTML', '<p>Talar Stem</p><ul><li>Plasma Coated</li><li>10 & 14mm lengths</li><li>Morse taper connection</li></ul>');
                $('#ToolTipShadowSRC').attr('src', 'images/ToolTipShadow7.png');
                break;
        }
    });
});
