jQuery(function($) 
    {
        var TB = 
        {
            init:function()
            {
                this.productZoom();
                this.lightBox();
                this.zoom();
                this.archiveWidget();
                this.blogSlides();
                this.formRequired();
            },
			
            productZoom:function()
            {
                var options = 
                {
                    lens: false,
                    zoomWidth: 420,
                    zoomHeight: 420,
                    xOffset: -35,
                    yOffset: 0,
                    position: "left",
                    hideEffect:'fadeout',
                    fadeoutSpeed: 'slow'
                };
                $('#ProductImage a').jqzoom(options);
            },
		
            lightBox:function()
            {
                if($('body.ArticleHolderPage').length)
                {
                    $("a[rel='lightbox']").lightBox({
                        imageLoading: 'mysite/javascript/lightbox/images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
                        imageBtnPrev: 'mysite/javascript/lightbox/images/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
                        imageBtnNext: 'mysite/javascript/lightbox/images/lightbox-btn-next.gif', // (string) Path and the name of the next button image
                        imageBtnClose: 'mysite/javascript/lightbox/images/lightbox-btn-close.gif', // (string) Path and the name of the close btn
                        imageBlank: 'mysite/javascript/lightbox/images/lightbox-blank.gif'
                    });
                }
            },
		
            zoom:function()
            {
                if($('body.WideImagePage').length) {
                    $('a.magnify').magnify();
                }
            },
            
            archiveWidget: function(){
                if($('div.archiveWidget').length){
                    var data = [];
                    var htmlText = '<select><option value="">Select Month</option>';
                    $('div.archiveWidget li a').each(function(){
                        htmlText += '<option value="'+$(this).attr('href')+'">'+$(this).text()+'</option>';
                    });
                    htmlText += "</select>";
                    $(htmlText).insertAfter($('div.archiveWidget h2'));
                    $('div.archiveWidget ul').remove();
                    $('div.archiveWidget select').change(function(){
                        window.location.href = $(this).find('option:selected').val();
                    });                
                }
            },
            
            blogSlides: function(){
                if($('#blogSlides').length){
                    if($('#blogSlides img').length > 1){
                        $('<ul id="blogSlidesNav"></ul>').insertAfter('#blogSlides');
                        $('#blogSlides').cycle({
                            pause: 1,
                            pager: '#blogSlidesNav',
                            pagerAnchorBuilder: function(idx, slide){
                                return '<li><a href="#">'+idx+'</a></li>'; 
                            }
                        }
                        );
                    }
                }
            },
            
            formRequired: function(){
                if($('#postCommentForm').length){
                    $('#postCommentForm').each(function(){
                        if($(this).find('.requiredField').length){
                            $(this).addClass('hasRequiredFields');
                            $(this).find('div.Actions').before('<div class="reqInfo">Required information</div>');
                        }
                    });
                }
            }
        }
        TB.init();
    });
