﻿/*****************************
Custom jQuery functions
*****************************/
var config = null;

(function($) {
    var effectDuration = 2500;
    var imageDelay = 6000;

    //centre vertically
    $("#container").css('top', (screen.availHeight - $(this).height()) / 2);

    //extension methods
    $.extend(String.prototype, {
        isMatch: function(regexPattern) {
            if (this.match(regexPattern))
                return true;

            return false;
        },
        endsWith: function(suffix) {
            if (!suffix || suffix.length == 0 || suffix.length > this.length)
                return false;

            var str = this.substring(this.length - suffix.length);
            return str.toLowerCase() == suffix.toLowerCase();
        }
    });

    $(function() {

        //load configuration
        $.ajax({
            cache: false,
            url: 'config.xml',
            dataType: 'xml',
            async: false,
            success: function(data, status) {
                //store config info
                config = data;
            },
            error: function(xhr, status, errorThrown) {
                alert(xhr.responseText);
            }
        });

        //page specific intitialization        
        var page = new $.Page(config, document.location.toString(), effectDuration, imageDelay);
        page.init();
    });
})(jQuery);