//-- Sesame Design Global JavaScript --//
//-- Created January 25th 2010 --//
//-- Updated 05/25/2010 --/
//----------------------------------------//
//-- All plugin/jquery function additions should be added in the below format, within the 'globalLib' var, then initialized after the jQuery $(function(){
//
//          ,COMMON_NAME_OF_LIBRARY_ITEM_TO_BE_INITIALIZED :
//          {
//              init : function()
//              {
//                  YOUR CODE HERE
//              }
//          } -----Add comma here only if you add more rules; the last rule should not have a comma here

var globalLib =
{
//Google Analytics
//---------------------------------------------------------------------------------
    analytics :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://2.scripts.sesamehost.com/scripts/jGoogleAnalytics.min.js',
                name: 'jGoogleAnalytics',
                success: function() {
                    //Google Analytics
                    $.jGoogleAnalytics(
                        'UA-19440266-1', // Your GA tracker code
                        {
                            anchorClick: true, // adds click tracking to *all* anchors
                            domainName: 'mattfreemanortho.com', // e.g. 'domain.com'
                            pageViewsEnabled: true // can be disabled e.g. if only tracking e.g. click events
                        }
                    );
                }
            });
        }//end init
    }//end analytics

//preload css images
//---------------------------------------------------------------------------------
    ,cssImage_preload :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://15.scripts.sesamehost.com/scripts/jquery.preloadCssImages.min.js',
                name: 'preloadCssImages',
                success: function(){
                    $.preloadCssImages();
                }
            });

        }//end init
    }//end image preloader

//Form Validation
//---------------------------------------------------------------------------------
    ,form_validation :
    {
        init : function()
        {
            //Hide all items with class of "hidden-content"
            $('.hidden-content').css('display', 'none');

            //Sequential numbering of comment form li's
            $(".sequential-list li").each( function(i) {
                i = i+1;
                $(this).prepend('<span class="comment-number">' + i + '. </span>');
            });

            //toggle hidden fields on Appointment Request Form
            //New Patient Toggle...
            $("input[name^='Current_Patient']").click( function() {
                 if ($("input[name^='Current_Patient']:checked").val() == 'No')
                    //not current patient, ask where they found us
                    $('.hidden-content').fadeIn('slow');
                else
                    //current patient, hide content
                    $('.hidden-content').fadeOut();
                        if($('#found-other').css('display') != 'none') {
                            $('#found-other').fadeOut();
                        }
            });
            //Where did you hear about us toggle
            $('#Found').change(function() {
                var selected = $('#Found option:selected');
                if(selected.val() == 'Other') {
                    $('#found-other').fadeIn('slow');
                } else {
                    $('#found-other').fadeOut();
                }
            });

            //Comment form "May We Contact You" toggle
            $("input[name^='Contact_Me']").click( function() {
                 if ($("input[name^='Contact_Me']:checked").val() == 'Yes')
                    //not current patient, ask where they found us
                    $('.hidden-content')
                        .fadeIn('slow');
                else
                    //current patient, hide content
                    $('.hidden-content').fadeOut().find('input').val("");
            });

            //Referral form "Radiographs Sent" toggle
            $("input[name^='Radiographs_Sent']").click( function() {
                 if ($("input[name^='Radiographs_Sent']:checked").val() == 'Yes')
                    //not current patient, ask where they found us
                    $('.hidden-content')
                        .fadeIn('slow');
                else
                    //current patient, hide content
                    $('.hidden-content').fadeOut().find('input').val("");;
            });

            //clear form fields with "clearme" class when clicked
            $('.clearme').one("focus", function() {
                    $(this).val("");
            });

            //add red asterisk to label of required fields
            $('label.required').each(function(i) {
                $(this).append('<em> * </em>');
            });


            //Form validation
            //---------------------------------------------------------------------------------
            $.xLazyLoader({
                js: ['http://20.scripts.sesamehost.com/scripts/jquery.validate.js',
                    'http://13.scripts.sesamehost.com/scripts/jquery.maskedinput-1.2.2.min.js'],
                name: 'validate',
                success: function(){
                    //masked input
                    $(".date-mask").mask("99/99/9999");
                    $(".phone-mask").mask("(999) 999-9999");

                    //additional validation methods
                    $.validator.addMethod("phone", function(phone_number, element) {
                        phone_number = phone_number.replace(/\s+/g, "");
                        return this.optional(element) || phone_number.length > 9 &&
                            phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
                    }, "Please specify a valid phone number");

                    //validator
                    $("#bd form.validate").each(function() {
                        $(this).validate({errorElement: "div",
                            errorClass: "error",
                            validClass: "success",
                            success: function(label) {label.text("ok!").addClass("success");},
                            rules: {
                                First_Name:                     {required:true,minlength:2},
                                Last_Name:                      {required:true,minlength:2},
                                Doctor_First_Name:              {required:true,minlength:2},
                                Doctor_Last_Name:               {required:true,minlength:2},
                                Patient_First_Name:             {required:true,minlength:2},
                                Patient_Last_Name:              {required:true,minlength:2},
                                Patient_Email:                  {required:true,email:true},
                                Referred_Patient_First_Name:    {required:true,minlength:2},
                                Referred_Patient_Last_Name:     {required:true,minlength:2},
                                Doctor_Patient_Referring:       {required:true,minlength:2},
                                Doctor_Email:                   {required:true,email:true},
                                Appointment_Email:              {required:true,email:true},
                                Daytime_Phone:                  {required:true,phone:true},
                                Alternate_Phone:                {phone:true},
                                Patient_Phone:                  {required:true,phone:true},
                                Message:                        {required:true,minlength:12},
                                Would_Like_To:                  {required:true},
                                Patient_Name:                   {required:"#Contact_Me_Yes:checked",minlength:5},
                                Email:                          {required:"#Contact_Me_Yes:checked",email:true},
                                txtNumber:                      {required:true,minlength: 5}
                            }
                        });
                    });
                }
            });
        }//end form init()

    }//end form validation


//PrettyPhoto modal windows
//---------------------------------------------------------------------------------
    ,modal_windows :
    {
        init : function()
        {
            /*gets plugin then runs function*/
            $.xLazyLoader({
                js: 'http://16.scripts.sesamehost.com/scripts/jquery.prettyPhoto.2.5.6.js',
                css: 'css/prettyPhoto.css',
                name: 'prettyPhoto',
                success: function(){
                    $("a[rel^='prettyPhoto']").prettyPhoto({
                        animationSpeed: 'normal',       /* fast/slow/normal */
                        default_width: 900,
                        default_height: 700,
                        opacity: 0.65,                  /* Value betwee 0 and 1 */
                        showTitle: false,               /* true/false */
                        allowresize: true,              /* true/false */
                        counter_separator_label: '/',   /* The separator for the gallery counter 1 "of" 2 */
                        theme: 'facebook',          /* light_rounded / dark_rounded / light_square / dark_square / facebook */
                        hideflash: false,               /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
                        wmode: 'opaque',                /* Set the flash wmode attribute */
                        autoplay: true,                 /* Automatically start videos: True/False */
                        modal: false                    /* If set to true, only the close button will close the window */
                    });
                }
            });

        }//end modal init
    }//end modal windows

// Standard Flash and video Modules
//-------------------------------------------------------------------------------
    ,flash_functions :
    {
        init : function()
        {
            /* setup dynamic loading */
            $.xLazyLoader({
                js: 'http://8.scripts.sesamehost.com/scripts/jquery.flash_1.3.js',
                name: 'flash',
                success: function(){
                    // Define the default configuation values
                    // followed by individual module configuration.
                    // Values for individual modules will override the defaults

                    var flashModules = {

                        defaults: {
                            'width': 500,
                            'height': 300,
                            'src': 'http://media.sesamehost.com/flash/',//default location of all Sesame flash mods
                            'wmode': 'transparent',
                            'flashvars': {
                                'autoPlay': 'false', // change value to 'true'to play on start
                                'thisColor': '0x' + '639CCE' // change global hex color (default=639CCE)
                            },
                            'express': 'flash/playerProductInstall.swf',
                            'version':'9'
                        },

                    modules: [
                      // Define the configuration values for each flash module.
                      // Change item values in any 'flashvars' section to false to omit,
                      // Add any value to override the default value in flashModuleDefaults.

                      {name: 'homepage',
                        config: {
                            'src':'flash/',//uses local location; default is media.sesamehost.com
                            'width':540,
                            'height':227
                        }
                      },
                      {name: 'braces-diagram', config: {'height': 375}},
                      {name: 'brace-painter', config: {'height': 430, 'wmode':'opaque'}},


                      {name: 'brushing-and-flossing-ortho',
                        config: {
                          'flashvars': {
                            'brushing': 'true',
                            'flossing': 'true'
                          }
                        }
                      },
                      {name: 'brushing-and-flossing-dental',
                        config: {
                          'flashvars': {
                            'brushing': 'true',
                            'flossing': 'true'
                          }
                        }
                      },

                      {name: 'color-your-retainer',
                        config: {
                            'width': 300,
                            'height': 300,
                            'flashvars': {
                                'autoPlay': 'true'
                            }
                        }
                      },

                      {name: 'common-treatments',
                        config: {
                          'flashvars': {
                            'crowding': 'true',
                            'openbite': 'true',
                            'deepOverbite': 'true',
                            'missing': 'true',
                            'underbite': 'true',
                            'spacing': 'true',
                            'overbite': 'true',
                            'nonBraces': 'true',
                            'phaseI': 'true'
                          }
                        }
                      },

                      {name: 'damon-system-comparison', config: {'width':250, 'height':165, 'wmode':'opaque'}},

                      //old emergency care module
                      {name: 'emergency-care',
                        config: {
                          'flashvars': {
                            'pokingWire': 'true',
                            'bracket': 'true',
                            'looseWire': 'true',
                            'appliance': 'true',
                            'headgear': 'true',
                            'soreness': 'true'
                          }
                        }
                      },

                      // Individual Emergency Care Animations //-----------------------------------------------
                      {name: 'general-soreness', config: {'width': 200, 'height': 150}},
                      {name: 'headgear', config: {'width': 200, 'height': 150}},
                      {name: 'loose-appliance', config: {'width': 200, 'height': 150}},
                      {name: 'loose-bracket', config: {'width': 200, 'height': 150}},
                      {name: 'loose-wire', config: {'width': 200, 'height': 150}},
                      {name: 'poking-wire', config: {'width': 200, 'height': 150}},
                      // End of animations

                      {name: 'ibraces-logo', config: {'width':200, 'height':135, 'wmode':'opaque'}},

                      {name: 'know-your-teeth',
                        config: {'width':500, 'height':400}},

                      {name: 'office-tour',
                        config: {'width':500, 'height':375, 'wmode':'opaque',
                          'flashvars': {
                            'caption01': '',
                            'caption02': 'Entry way',
                            'caption03': 'Reception area',
                            'caption04': 'Coffee tables and chairs',
                            'caption05': 'Coffee bar',
                            'caption06': 'Family waiting room',
                            'caption07': 'Adult waiting room',
                            'caption08': 'Game room',
                            'caption09': 'Exam and consultation room',
                            'caption10': 'Records room',
                            'caption11': 'X-ray room',
                            'caption12': 'Sterilization area',
                            'caption13': 'Brushing area',
                            'caption14': 'Open treatment bay',
                            'caption15': '',
                            'caption16': ''
                          }
                        }
                      },

                      {name: 'palatal-expander', config: {'width': 200, 'height': 150}},
                      {name: 'patient-care',
                        config: {
                            'src':'flash/',//uses local location; default is media.sesamehost.com
                            'height': 375
                        }
                      },

                        {name: 'smile-gallery',
                        config: {
                          'flashvars': {
                            'bonding': "true",
                            'bridges': "true",
                            'crowns': "true",
                            'fillings': "true",
                            'implants': "true",
                            'invisalign': "true",
                            'veneers': "true",
                            'whitening': "true"
                          }
                        }
                      },

                      {name: 'types-of-appliances',
                        config: {
                          'flashvars': {
                            'elastics': 'true',
                            'headgear': 'true',
                            'herbst': 'true',
                            'palatal': 'true',
                            'positioners': 'true',
                            'separators': 'true'
                          }
                        }
                      },

                      {name: 'types-of-braces',
                        config: {
                          'flashvars': {
                            'metal': 'true',
                            'gold': 'true',
                            'ceramic': 'true',
                            'invisible': 'true',
                            'lingual': 'true'
                          }
                        }
                      }
                    ]
                    };

                    // Loop through the defined modules
                    // and do flash replacement for any that are on the current page
                    for (var j = flashModules.modules.length - 1; j >= 0; j--){
                        var module = flashModules.modules[j];
                        // combine default config settings with individual module config settings
                        var modConfig = $.extend({}, flashModules.defaults, module.config);
                        // combine default flashvars with module flashvars
                        modConfig.flashvars = $.extend(flashModules.defaults.flashvars, module.config.flashvars);
                        modConfig.src = modConfig.src + module.name + '.swf';
                        $('#flash-' + module.name).flash(modConfig);
                    }

                    // Flash Video functions
                    //-------------------------------------------------------------------------------

                    var flashVideos = {

                        defaults: {
                          // Define the configuation values applied to each module.
                          // Each module in flashModules can override these values.

                          'src': 'video/flvPlayer.swf',
                          'dir': 'http://media.sesamehost.com/video/',//location of video files
                          'img_dir': 'http://media.sesamehost.com/video/',//location of image files
                          'width': 320,
                          'height': 266,
                          'wmode': 'transparent',
                          'menu': false,
                          'allowFullScreen': true,
                          flashvars: {
                            'autoStart': 'false', // change value to true to play on start
                            'showScaleModes': 'false', //set to false to disable scale modes menu
                            'smoothVideo': 'true' //set to false to disable video smoothing
                          }
                        },

                        videos: [
                            {name: 'the-damon-system',config:{'width': 240, 'height': 206}},
                            {name: 'the-damon-system-2',config:{'width': 400, 'height': 330}},
                            {name: 'in-ovation',config:{}},
                            {name: 'opalescence', config: {'width': 400, 'height': 251}},
                            {name: 'invisalign',
                                config: {
                                    //dir: '',//leave blank to override location of video
                                    //img_dir: 'video/',//override location of image file
                                    'width': 360
                                }
                            },
                            {name: 'suresmile', config: {'height': 206}},
                            {name: 'suresmile-robot',
                                config: {
                                    'height': 242,
                                    flashvars:
                                    {
                                        startImage: 'none', autoStart: 'true'
                                    }
                                }
                            },
                            {name: 'invisalign', config: {'width': 360, 'height': 266}},
                            //invisalign pro pack
                            {name: 'invisalign-best-friends', config: {}},
                            {name: 'invisalign-news-travels-fast', config: {}},
                            {name: 'invisalign-lobby', config:{'width': 320, 'height': 266}}
                        ]
                    };
                    for (var j=0; j < flashVideos.videos.length; j++) {
                        var video = flashVideos.videos[j];
                        // combine default config settings with module config settings
                        var vidConfig = $.extend({}, flashVideos.defaults, video.config);
                        // combine default flashvars with module flashvars
                        vidConfig.flashvars = $.extend({}, flashVideos.defaults.flashvars, video.config.flashvars);
                        vidConfig.flashvars.flvToPlay = vidConfig.dir + video.name + '.flv';
                        vidConfig.flashvars.startImage = vidConfig.img_dir + video.name + '.jpg';
                        $('#video-' + video.name).flash(vidConfig, flashVideos.defaults.pluginOptions);
                    };
                }
            });

        }//end flash init
    }//end flash functions


// Game room
//-------------------------------------------------------------------------------
    ,games :
    {
        init : function()
        {
            //Partial Sliding (Only show some of background)
            $('ul#sesame-games li').hover(function(){
                $(".cover", this).stop().animate({top:'36px'},{queue:false,duration:160});
            }, function() {
                $(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
            });
        }//end games init
    }//end games


//Basic HTML and utility functions
//---------------------------------------------------------------------------------
    ,html_functions :
    {
        init : function()
        {
            // Some effects rely on an element to be initially hidden,
            // but we only hide them if the user has javascript
            $('.jshide').addClass('hide');

            //prepend "More in this Section" to sub_nav
            //$('p.sub_nav').prepend('<strong>More in this section: </strong>');

            // Open external links in new windows
            $('a[href^="http://"], a[href^="https://"]')
                .not('[href*="orthosesame.com"],[href*="sesameinteractive.com"],[href*="mattfreemanortho.com/blog"],[href*="mattfreemanortho.com"], a[href$=".doc"], a[href$=".pdf"]')
                .addClass('external').attr('target', '_blank');

            // Open pdf links in new windows + add icon
            $('a[href$=".pdf"]').attr('target', '_blank').not('[class*="noicon"]').append('<span/>').addClass('pdf');

            // Open M$ doc links in new windows + add icon
            $('a[href$=".doc"]').attr('target', '_blank').not('[class*="noicon"]').append('<span/>').addClass('doc');

            // add icons to links which open in prettyPhoto
            $("a[rel^='prettyPhoto[flash]']").parent('li').append('<span/>').addClass('video-link');


            //Ordered List Style
            $('ol.alpha, ol.numeric').addClass('js');
            $("ol li").each(function (i) {
                $(this).wrapInner('<span/>');
            });

            //fancy Q & A
            $('ul.q-and-a li').each( function() {
                $(this).find('h2,h4,h3').prepend('<span>Q: </span>');
                $(this).find('div').prepend('<span>A: </span>');
            });

            //Toggle functions
            //---------------------------------------------------------------------------------
            // Show only when javascript is available
            $('#toggle-links').css('display','block');

            //hide lists first!
            $('#toggle-content dl').hide();

            //toggle
            function toggleInfoContent(id){
                if($(id).css('display') != 'none'){
                  $(id).fadeOut('fast');
                  $('.back-to-top').addClass('hide');
                }else{
                  $('#toggle-content dl').fadeOut('fast');
                  $(id).fadeIn('slow');
                  $('.back-to-top').removeClass('hide');
                }
            }
            $("#toggle-links").bind('click', function(e) {
                var target = e.target, // e.target grabs the node that triggered the event.
                $target = $(target);  // wraps the node in a jQuery object
                var id = $target.attr('href')
                if (target.nodeName === 'A') {
                    toggleInfoContent(id);
                }
                //commented because links to resources  not accessible
                //return false;
            });

            // Emergency Care toggle //----------------------------------
            //hide items first!
            $('#toggle-emergency div p').hide();
            //toggle
            function toggleEmergency(id){
                if($(id).css('display') != 'none'){
                    $(id).animate({opacity: 'toggle'}).parent().animate({width: '80px',height: '60px'});
                }else{
                    $(id).animate({opacity: 'toggle'}).parent().animate({width: '200px',height: '150px'});
                }
            }
            $("a.toggle-div").bind('click', function(e) {
                var target = e.target, // e.target grabs the node that triggered the event.
                $target = $(target);  // wraps the node in a jQuery object
                var id = $target.attr('href')
                if (target.nodeName === 'A') {
                    toggleEmergency(id);
                }
                return false;
            });
            //end toggle functions



            //Back to top
            if ($('#content').height() > $(window).height()) {
                $('.back-to-top').removeClass('hide');
            }

            //pt/dr login tooltip functions
            //$('#pt-login-form a, #dr-login-form a').bind('mouseover', function(e){
            //  var target = e.target, // e.target grabs the node that triggered the event.
            //      $target = $(target);  // wraps the node in a jQuery object
            //      $target.animate({opacity: '.65'}, 400).bind('mouseout', function() {
            //          $target.animate({opacity: '1'}, 400);
            //      });
            //});

            //fade sidebar callouts
            $('#sidebar-alt img').hover( function() {
                $(this).animate({opacity: '.65'}, 400);
            }, function() {
                $(this).animate({opacity: '1'},400);
            });
        }//end HTML init
    }//end HTML functions


// slideshows
//-------------------------------------------------------------------------------
    ,gallery_view_tour :
    {
        init : function()
        {
            // jQuery GalleryView Office Tour //----------------------------------------------
            $.xLazyLoader({
                js: ['http://11.scripts.sesamehost.com/scripts/jquery.galleryview-2.0.js',
                    'http://7.scripts.sesamehost.com/scripts/jquery.easing.1.3.js',
                    'http://19.scripts.sesamehost.com/scripts/jquery.timers-1.1.2.js'],
                name: 'galleryView',
                success: function(){
                    //customize me
                    $('#gallery').galleryView({
                        panel_width: 460,
                        panel_height: 350,
                        frame_width: 80,
                        frame_height: 60,
                        transition_speed: 600,
                        easing: 'easeInOutBack',
                        transition_interval: 0,
                        nav_theme: 'dark'
                    });
                    //end
                }
        });

        }//end slideshow init
    }//end gallery view tour

// jQuery Cycle Office Tour //----------------------------------------------------
    ,cycle_tour :
    {
        init : function()
        {
            // jQuery cycle slideshow
            $.xLazyLoader({
                js: 'http://6.scripts.sesamehost.com/scripts/jquery.cycle.2.81.all.min.js',
                name: 'cycleTour',
                success: function(){
                    // jQuery Cycle Plugin
                    $('ul.slideshow').cycle({
                        pause: true,
                        wmode: 'transparent'
                    });

                    // Duplicate the following block of code to add extra office tours
                    $('#cycle-office-tour') // Give this ID a unique name if more than one office tour is needed on a page
                    .before('<div class="office-tour-nav" id="office-1">') // Ditto for this ID
                    .cycle({
                        cleartype: true, // true if clearType corrections should be applied (for IE)
                        cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
                        speed: 500, // This controls speed of transition
                        timeout: 5000, // This controls delay between slides. Set to 0 if more than one office tour on a page, so they don't auto-play
                        pager:  '#office-1',
                        before: function() {
                            $('#caption span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page
                        },
                        after: function(curr, next, opts) {
                            var alt = $(next).find('img').attr('alt'); // This grabs the image alt text
                            $('#caption span').html(alt).fadeIn(); // This puts alt text into the caption span
                        }
                    });
                }
            });

        }//end init
    }//end cycle tour

// jQuery Cycle Slideshow (homepage) //----------------------------------------------------
    ,cycle_slideshow :
    {
        init : function()
        {
            // jQuery cycle slideshow
            $.xLazyLoader({
                js: 'http://6.scripts.sesamehost.com/scripts/jquery.cycle.2.81.all.min.js',
                name: 'cycleSlideshow',
                success: function(){
                    //Home Page Slideshow
                    var $ss = $('#slideshow-home');

                    // add slides to slideshow (images 2-8)
                    for (var i = 1; i < 4; i++)
                        $ss.append('<img src="images/photos/slide'+i+'.png" width="730" height="365" alt="slide" />');

                    // start the slideshow
                    $('#slideshow-home img:first').fadeIn(1000, function() {
                        $ss.cycle({
                            random: 0,
                            fx:     'fade',
                            speed:   '1000',
                            timeout: 7000
                        });
                    });
                }
            });
        }//end slideshow init
    }//end cycle slideshow


// jQuery Cycle Before and After //-------------------------------------------------
    ,cycle_before_after :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://6.scripts.sesamehost.com/scripts/jquery.cycle.2.81.all.min.js',
                name: 'cycleBeforeAfter',
                success: function(){
                    //customize me
                    $('#before-after-cycle') // Give this ID a unique name if more than one office tour is needed on a page
                    .before('<div class="before-after-nav">') // Ditto for this ID
                    .cycle({
                        cleartype: true, // true if clearType corrections should be applied (for IE)
                        cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
                        speed: 500, // This controls speed of transition
                        timeout: 0, // This controls delay between slides. Set to 0 if more than one office tour on a page, so they don't auto-play
                        pager:  '.before-after-nav',
                        before: function() {
                            $('.cycle-detail span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page
                        },
                        after: function(curr, next, opts) {
                            var cycle_alt = $(next).find('img').attr('alt'); // This grabs the image alt text
                            $('.cycle-detail span').html(cycle_alt).fadeIn(); // This puts alt text into the caption span
                        }
                    });
                    //end
                }
            });
        }//end init
    }//end cycle before/after

// jQuery Before After Slider //-------------------------------------------------------
    ,slider_before_after :
    {
        init : function()
        {
            $.xLazyLoader({
                js: ['http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js',
                    'http://6.scripts.sesamehost.com/scripts/jquery.cycle.2.81.all.min.js',
                    'http://3.scripts.sesamehost.com/scripts/jquery.beforeafter.js'],
                name: 'sliderBeforeAfter',
                success: function(){
                    //customize me
                    $('.before-after-slider').beforeAfter({
                        animateIntro : false,
                        showFullLinks : false
                    });

                    // Cycle plugin added to above Slider
                    $('#slider-cycle')
                    .before('<div class="slider-nav">')
                    .cycle({
                        cleartype: true, // true if clearType corrections should be applied (for IE)
                        cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
                        speed: 500, // This controls speed of transition
                        timeout: 0, // This controls delay between slides. Set to 0 if more than one office tour on a page, so they don't auto-play
                        pager:  '.slider-nav',
                        before: function() {
                            $('.slider-detail span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page
                        },
                        after: function(curr, next, opt) {
                            var slider_alt = $(next).children('.before-after-slider').children('div').siblings().find('img').attr('alt'); // This grabs the image alt text
                            $('.slider-detail span').html(slider_alt).fadeIn(); // This puts alt text into the caption span
                        }
                    });
                    //end
                }
            });
        }//end init
    }// end slider before after


// IE6 Duct Tape
//-------------------------------------------------------------------------------
    ,ie_functions :
    {
        init : function()
        {
            //detects if browser is IE by checking leadingWhitespace property.
            //See: http://docs.jquery.com/Utilities/jQuery.support
            var fancyHover = $.support.leadingWhitespace;
            if(fancyHover == false)
            {//browser is IE, use script
                $('#nav ul li, #utility-nav ul li').bind('mouseenter mouseleave', function(){
                    $(this).toggleClass('sfhover');
                });
                //PNG fix for IE6
                //$.xLazyLoader({
                //  js: 'http://6.scripts.sesamehost.com/scripts/jquery.pngFix1.2.js',
                //  name: 'pngFix',
                //  success: function() {
                //      $(document).pngFix();
                //  }
                //});

                //click to close behavior
                if($('.ie-alert-link').length > 0) {
                    $.xLazyLoader({
                        js: 'http://5.scripts.sesamehost.com/scripts/jquery.cookie.js',
                        name: 'cookie',
                        success: function() {
                            var COOKIE_NAME = 'ie_alert';
                            var options = { path: '', expires: 14 };

                            $('.ie-alert-link').click(function() {
                                $('#ie_alert').slideToggle("slow");
                                $.cookie(COOKIE_NAME, 'noshow', options);
                            });
                            //set cookie handler
                            var alertBox = $.cookie(COOKIE_NAME);
                            //if cookie val "noshow" then hide message - user has already seen this message!
                            if(alertBox) {
                                $('#ie_alert').css('display', 'none');
                            }else{
                                $('#ie_alert').css('display', 'block');
                            }
                        }
                    });
                }
                //-- /end ie6 warning
            }//end if/else
        }//end ie init
    }//end ie_functions


// Image Replacement
//-------------------------------------------------------------------------------
    // Cufon & FontAvailable Image Replacement Headings
    // uses @font-face CSS rules first
    ,cufon :
    {
        init : function()
        {
            //Cufon + jQuery
            //--- requires in <head>:
            //--- <script src="http://9.scripts.sesamehost.com/scripts/jquery.fontavailable-1.1.min.js" type="text/javascript"></script>
            if (!$.fontAvailable('TrajanProRegular')) {
                // load the cufon library
                $.xLazyLoader({
                    js: ['http://10.scripts.sesamehost.com/scripts/cufon-yui.js',
                        'scripts/Trajan_Pro_400-Trajan_Pro_700.font.js'],
                    name: 'cufon',
                    success: function(){
                        Cufon.replace('#bd h1.headline',{
                            fontFamily:'TrajanProRegular'
                        });
                    }
                });
            }
            //ADD YOUR CUSTOM TEXT REPLACEMENT METHODS HERE
        }//end init
    }//end image replacement

    //Testimonial Rotator
    ,slides :
    {
        init : function()
        {
            $('#testimonials .slide');
            setInterval(function(){
                $('#testimonials .slide').filter(':visible').fadeOut(9000,function(){
                    if($(this).next('li.slide').size()){
                        $(this).next().fadeIn(9000);
                    }
                    else{
                        $('#testimonials .slide').eq(0).fadeIn(9000);
                    }
                });
            },1000);

        }
    }

    // jcIR Image Replacement Headings
    //-------------------------------------------------------------------------------
    ,jcir :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://22.scripts.sesamehost.com/scripts/jquery.jcIR.js',
                //IE can't handle this so its commented out
                //img: 'images/pixel.gif',
                name: 'jcIR',
                success: function() {
                    //jcIR
                    //check if images are enabled then run replacement
                    $('.jcIR').jcIR({
                        image_dir: 'headings',//no slashes
                        image_ext: '.jpg',//file extention of replacement image
                        elem_width: '600',//width of element being replaced
                        elem_height: '50'//height of element being replaced
                    });
                }//end success
            });
        }//end init
    }//end jcIR

// Navigation
//-------------------------------------------------------------------------------
    ,navigation :
    {
        init : function()
        {
            //superfish menus
            $.xLazyLoader({
                js: 'http://21.scripts.sesamehost.com/scripts/superfish.js',
                name: 'superfish',
                success: function() {
                    $('#nav>ul, #utility-nav>ul, #logins>ul').superfish({
                        hoverClass:     'sfhover',                          //class used by IE for hover effects
                        delay:          500,                                //one second delay on mouseout
                        animation:      {opacity:'show',height:'show'},     //fade-in and slide-down animation
                        autoArrows:     false,                              //disable generation of arrow mark-up
                        disableHI:      true                                // set to true to disable hoverIntent detection
                    });
                }
            });
        }//end init
    }//end navigation

// Anti-spam email obfuscator
//-------------------------------------------------------------------------------
    ,anti_spam :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://12.scripts.sesamehost.com/scripts/jquery.emailProt.js',
                name: 'anti_spam',
                success: function() {
                    //Insert empty <a> tag with the following attributes:
                    // * class="email"
                    // * rel="example|domain.com" where pipe char '|' replaces '@'
                    // * title="Email Us", this is the text shown after the email link is created by js
                    $('a.email').emailProt();
                }
            });
        }//end init
    }//end anti-spam

// Tool Tips
//-------------------------------------------------------------------------------
    ,tooltips :
    {
        init : function()
        {
            $.xLazyLoader({
                js: 'http://17.scripts.sesamehost.com/scripts/jquery.qtip-1.0.0-rc3.min.js',
                name: 'qtip',
                success: function(){

                    //qtip DR login styles
                    $.fn.qtip.styles.logins = { // Last part is the name of the style
                        width: 306,
                        background: '#fffef3',//customize me - background color of tip
                        button: {
                                'color': 'white',//customize me - color of text in title bar
                                'font-weight': 'bold'
                        },
                        color: '#3c0600',//customize me
                        textAlign: 'left',
                        title:
                        {
                            'background': '#3c0600'//customize me - background of title bar
                        },
                        border: {
                          width: 3,//customize me - width of border
                          radius: 5,//customize me - rounded corner radius
                          color: '#832117'//customize me - color of border
                        },
                        tip: 'topRight',
                        name: 'dark' // Inherit the rest of the attributes from the preset dark style
                    }
                    //DR login
                    var drLoginForm = $('#dr-login-form');
                    var drLoginTitle = 'Dental Sesame Doctor Login';
                    $('#doctor-login').click(function(e){e.preventDefault();}).each(function(){
                        $(this).qtip({
                            content:
                            {
                                title:
                                {
                                    text: drLoginTitle,
                                    button: 'Close'
                                },
                                text: drLoginForm
                            },
                            show: {
                                when: 'click',
                                solo: true
                            },
                            hide: {
                                when: 'click',
                                fixed: true
                            },
                            style: 'logins',
                                position: {
                                    corner: {
                                        target: 'bottomLeft',
                                        tooltip: 'topRight'
                                    }
                                }

                        })
                    });

                }
            });
        }//end init
    }//end tooltips

    //YOUR CUSTOM FUNCTIONS START HERE


    //AND END HERE

}//end globalLib


//JQuery Setup
$(function(){


//--initialize all required library items
    // LINE: 14
    globalLib.analytics.init();

    // LINE: 40 - unused
    //globalLib.cssImage_preload.init();

    // LINE: 500
    globalLib.html_functions.init();

    // LINE: 727
    globalLib.ie_functions.init();

    // LINE: 833
    globalLib.cufon.init();

    // LINE: 833
    globalLib.slides.init();

    // LINE 825
    //globalLib.tooltips.init();

    // LINE: 885
    globalLib.navigation.init();

//--YOUR CUSTOM INITIALIZERS GO HERE
//--Add them like this:
//--globalLib.YOURFUNCTIONNAME.init();


//--initialize on-demand library items
    if($("div[id^='flash-']", "div[id^='video']")){//load flash functions
        globalLib.flash_functions.init();
    }
    // jcIR
    if($('.jcIR').length > 0) {//load jcIR Image Replacement
        globalLib.jcir.init();
    }
    // Anti-Spam
    if($('a.email').length > 0) {//load Anti-Spam Obfusicator
        globalLib.anti_spam.init();
    }
    //slideshows
    if($('ul#gallery').length > 0) {//load galleryView slideshow
        //
        globalLib.gallery_view_tour.init();
    }

    if($('#slideshow-home').length > 0) {//load cycle slideshow
        //
        globalLib.cycle_slideshow.init();
    }

    if($('#cycle-office-tour').length > 0) {//load cycle office tour
        //
        globalLib.cycle_tour.init();
    }

    if($('#before-after-cycle').length > 0) {//load cycle before after
        //
        globalLib.cycle_before_after.init();
    }

    if($('#slider-cycle').length > 0){//load slider before after
        //
        globalLib.slider_before_after.init();
    }//end slideshows

    if($('form').length > 0) {//load form functions
        // LINE: 57
        globalLib.form_validation.init();
    }

    if($("a[rel^='prettyPhoto']").length > 0){//load prettyPhoto function
        // LINE: 192
        globalLib.modal_windows.init();
    }

    if($('ul#sesame-games').length > 0 ) {//load game code
        // LINE: 484
        globalLib.games.init();
    }
});//end document.ready
