﻿(function($) {
    jQuery.fn.myMethod = function() {
        alert('Nothing happens.' + this.length + ' elements.');
    }
    jQuery.fn.myMethod2 = function() {
        alert('2 happens.' + this.length + ' elements.');
    }
    jQuery.fn.Book2 = function(options) {
        var defaults = {
            speed: 5,
            opacity: 0.1,
            top: 100,
            index: -1

        };
        var opts = jQuery.extend(defaults, options);
        var $originalElement = $(this);

        $originalElement

     .css('z-index', opts.index)
     .animate({

         opacity: opts.opacity,
         left: '+=' + opts.speed,
         height: 'toggle',
         top: opts.top

     }), 5000, function() {
         // Animation complete.
     };
    }

    //ajax function

    jQuery.fn.ajaxLoadZone = function(options) {

        var settings = {
            url: '#',
            type: 'POST',
            dataType: 'JSON',
            data: '#',
            contentType: '"application/json; charset=utf-8'
        };
        var opts = jQuery.extend(settings, options);
        var $theElemnet = $(this);
        return this.click(function(event) {
            $.ajax({
                url: opts.url,
                type: opts.type,
                data: opts.data,
                dataType: opts.dataType,
                contentType: opts.contentType,
                success: function(data) {
                    $('<div></div>')
            .css({
                position: 'absolute',
                left: event.pageX,
                top: event.pageY,
                cursor: 'pointer',
                display: 'none'
            })
            .html(data)
            .addClass("error")
            .click(function() {
                $(this).fadeOut(1500, function() { $(this).remove(); });
            })
            .appendTo('body')
            .fadeIn();
                }
            });
            return false;
        });

    }
})(jQuery);

(function() {
    jQuery.fn.centerScreen = function(isGlobal, loaded) {
        var obj = this;
        var st = $(document).scrollTop();
        var w;
        if (!isGlobal) w = $('#Wrapper').width()
        else w = $(window).width()

        if (!loaded) {
            obj.css('top', st + $(window).height() / 2 - this.height() / 2);
            obj.css('left', w / 2 - this.width() / 2);
            $(window).resize(function()
            { obj.centerScreen(isGlobal, !loaded); });
        } else {
            obj.stop();
            obj.animate({ top: st + $(window).height() / 2 - this.height() / 2, left: w / 2 - this.width() / 2 }, 200, 'linear');
        }
    }
})(jQuery);

function ___getPageSize() {
    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    // for small pages with total height less then height of the viewport
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    //   alert("test" + arrayPageSize);
    return arrayPageSize;
};
function ___getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScroll, yScroll);
    return arrayPageScroll;
};