﻿var DocViewer = {
    status:0,

    move: function(dir, elem, itms, holder) {
        var marginLeft = parseInt($(elem).css('left'), 10);
        var width = $(itms).width();
        if (DocViewer.status == 0) {
            if (dir == 0) {
                if (marginLeft - width >= ($(itms, $(elem)).length - 1) * width * -1) {
                    DocViewer.status = 1;
                    $('.ArrowRight', $(holder)).removeClass('ArrowRightInactive');
                    if (marginLeft - width*2 < ($(itms, $(elem)).length - 1) * width * -1) {
                        $('.ArrowLeft', $(holder)).addClass('ArrowLeftInactive');
                    }
                    $(elem).animate({ 'left': (marginLeft - width) + 'px' }, 400, function () {
                        DocViewer.status = 0;
                    });
                }
            } else {
                if (marginLeft + width <= 0) {
                    DocViewer.status = 1;
                    $('.ArrowLeft', $(holder)).removeClass('ArrowLeftInactive');
                    if (marginLeft + width*2 > 0) {
                        $('.ArrowRight', $(holder)).addClass('ArrowRightInactive');        
                    }
                    $(elem).animate({ 'left': (marginLeft + width) + 'px' }, 400, function () {
                        DocViewer.status = 0;
                    });
                }
            }
        }
    },

    init: function(elem, itms, holder) {
        $('.ArrowLeft', $(holder)).addClass('ArrowLeftInactive');

        var width = $(itms).width();
        var len = $(itms, $(elem)).length;
        var marginLeft = parseInt($(elem).css('left'), 10);
        $(elem).animate({ 'left': (marginLeft - ($(itms, $(elem)).length - 1) * width) + 'px' }, 100);

    }
}

$(document).ready(function() {
    var zIndexNumber = 1000000;
    $('.main-menu').each(function () {
        $(this).css('zIndex', 10000);
    });
    if ($.browser.msie) {
        $('*').each(function() {
	        if ($(this).attr('id') != 'facebox' && !$(this).hasClass('fade-to-black') && !$(this).hasClass('ButtonSubmit')) {
	            $(this).css('zIndex', zIndexNumber);
	            zIndexNumber -= 1;
	        } else if ($(this).hasClass('ButtonSubmit')) {
               $(this).css('zIndex', zIndexNumber);
            }   
        });
        $('fieldset').css('zIndex', 1000000);
    }
});