
/* Canon Imageware Microsite JS document */
if (typeof (Canon) == "undefined") {
    Canon = {};
}

var g_crsl = null;
var g_clckTrk = null;
var g_start = 1;
var varOpen = false;

if (typeof (Canon.Imageware) == "undefined") {
    Canon.Imageware = {
        Homepage: function() {
            $('#home-hd-crsl').cycle({
                //fx: 'fade',
                before: this.slideChange,
                //pager:'#home-hd-goto',
                delay: 1000,
                end: this.triggerCrsl,
                nowrap: 1,
                after: this.checkCycleState,
                pagerAnchorBuilder: this.hdCrslAnchrBldr,
                pagerClick: this.hdCrslNavClick,
                speed: 1000,
                timeout: 4000
            });
            $('#home-hd-goto li:first-child').removeClass('active activeSlide');
            $("#home-ft-crsl").jcarousel({
                scroll: 1,
                auto: 0,
                initCallback: this.homeFT_initCallback,
                buttonNextHTML: null,
                buttonPrevHTML: null
            });
        },

        inputFocus: function() {

            $('#aspnetForm input').focus(function() {
                $(this).addClass('focus');

            });

            $('#aspnetForm input').blur(function() {
                var charCount = $(this).val().length;

                if (charCount < 1) {
                    $(this).removeClass('focus');
                };
            });

            $('#aspnetForm input').each(function() {

                $(this).val('');

            });
        },

        DropDowns: function() {
            $('#super-nav li.top').hover(function() {
                $(this).addClass('hover');
            }, function() {
                $(this).removeClass('hover');
            });
        },


        homeFT_initCallback: function(carousel) {
            g_crsl = carousel;
            $('#home-ft-crsl-nxt').bind('click', function() {
                carousel.next();
                return false;
            });
            $('#home-ft-crsl-prv').bind('click', function() {
                carousel.prev();
                return false;
            });
        },
        slideChange: function() {
            // cycle before
            if ($('#splash-nav li').hasClass('active')) {
                if (g_clckTrk == 1) {
                    g_clckTrk = null;
                } else {
                    $('#splash-nav li.active').removeClass('active').next().addClass('active');
                }
            } else {
                $('#splash-nav li:first-child').addClass('active');
            };
        },
        checkCycleState: function(idx) {
            //cycle after
            if (!$('#splash-nav li').hasClass('active')) {
                $('#splash-nav li:first-child').addClass('active');
            }
        },
        triggerCrsl: function() {
            $('#home-hd-crsl').cycle(0);
            $('#splash-nav li:first-child').removeClass('active');
            $('#home-hd-crsl').cycle('stop');
            g_crsl.startAuto(4);
        },
        hdCrslAnchrBldr: function(idx) {
            return '#splash-nav li:eq(' + (idx) + ') a';
        },
        hdCrslNavClick: function(idx) {
            // click event
            $('#splash-nav li.active').removeClass('active');
            g_clckTrk = 1;
            $('#home-hd-goto li:eq(' + (idx) + ')').addClass('active activeSlide');
        },
        breadcrumbUpdater: function(text) {
            var og = $('#og-bc').text();
            $('#breadcrumb').text(og)
            $('#breadcrumb').append('&gt; ' + text);
        },
        Proserv: function() {

            $('#accord .pod:first').show();
            $('#accord h2:first').addClass('active');

            $('#toggler em').html('Open');
            $('#toggler').click(function() {
                $('#accord h2').removeClass('active');
                if (varOpen == false) {
                    $('#toggler em').html('Close');
                    $('#accord').children('.pod').slideDown();
                    $('#accord h2').addClass('active');
                    varOpen = true;
                } else {
                    $('#toggler em').html('Open');
                    $('#accord').children('.pod').slideUp();
                    $('#accord h2').removeClass('active');
                    varOpen = false;
                }
                return false;
            });

            $('#accord h2').click(function() {


                if ($(this).hasClass('active')) {
                    $('#accord h2').removeClass('active');
                } else {
                    $('#accord h2').removeClass('active');
                    $(this).addClass('active');
                };

                var id = $('h2.active a').attr('id');
                $('#accord').children('.pod').each(function() {

                    if ($(this).attr('id') == id) {
                        $(this).slideToggle();
                    } else {
                        $(this).slideUp();
                    }
                });



                return false;
            });

        },

        init: function() {
            jQuery.each(jQuery.browser, function(i) {
                if ($.browser.safari) {
                    $("#uniflow-tabs .tab-nav li.last").css("width", "167px !important");
                }
            });
        }
    };
};


