﻿function Initialize() {
    if (richmobilebrowsertest()) {
        window.location = "Mobile/Default.html";
    }

    AnimateDemosIn();
}



function richmobilebrowsertest() {

    var uaStr = navigator.userAgent.toLowerCase();

    // Check for webkit-based browsers. This will catch modern iPhone, iPod, and Android.
    if ((uaStr.indexOf("iphone") != -1 ||
        uaStr.indexOf("ipod") != -1 ||
        uaStr.indexOf("android") != -1) && uaStr.indexOf('applewebkit') != -1) {
        return true;
    }

    // Check for BlackBerry.
    if (uaStr.indexOf("blackberry") != -1) {
        // BlackBerry 6 or later should be running WebKit
        var verStr = /version\/(\d+)/.exec(uaStr);
        if (verStr != null) {
            var bbVer = parseInt(verStr[1]);
            if (bbVer >= 6 && uaStr.indexOf('applewebkit') != -1)
                return true;
        }
        return false;
    }

    // Check for Windows Phone 7 and IE version at least 9.
    if (uaStr.indexOf('windows phone os') != -1 && uaStr.indexOf('iemobile') != -1) {
        var ieStr = /iemobile\/(\d+)/.exec(uaStr);
        if (ieStr != null) {
            var ieVer = parseInt(ieStr[1]);
            if (ieVer >= 9) {
                return true;
            }
        }
        return false;
    }

    // Check for Opera mobile.
    if (uaStr.indexOf('opera mobi') != -1) {

        // Check the presto version to see if supports HTML5.
        var presto = /presto\/(\d+\.\d+)/.exec(uaStr);
        if (presto != null) {
            var prestoVer = parseFloat(presto[1]);
            if (prestoVer >= 2.4) // 2.4 has a good HTML5 base, indicates Opera 10
                return true;
        }
        return false;
    }

    // Check for Firefox mobile.
    if (uaStr.indexOf("fennec") != -1) {
        var fennec = /fennec\/(\d+\.\d+)/.exec(uaStr);
        if (fennec != null) {
            var fennecVer = parseFloat(fennec[1]);
            if (fennecVer >= 1.0)
                return true;
        }
    }

    // If we make it here, we haven't found a rich-tier mobile browser.
    return false;
}



function AnimateDemosIn() {
    $('.Demo').each(function (index) {
        $(this).addClass("AnimateIn");
        var amount = ((30 - index) * 0.02);
        this.style.msTransitionDelay = amount + "s";
        this.style.webkitTransitionDelay = amount + "s";
    });
}



