﻿/*
* login-JS ~ 
* :: Now with support for touch events and multiple instances for 
* :: those situations that call for multiple easter eggs!
* Code: http://login-js.googlecode.com/
* Examples: http://www.snaptortoise.com/login-js
* Copyright (c) 2009 George Mandis (georgemandis.com, snaptortoise.com)
* Version: 1.3.2 (7/02/2010)
* Licensed under the GNU General Public License v3
* http://www.gnu.org/copyleft/gpl.html
* Tested in: Safari 4+, Google Chrome 4+, Firefox 3+, IE7+ and Mobile Safari 2.2.1
*/

var login = function() {
    var login = {
        addEvent: function(obj, type, fn, ref_obj) {
            if (obj.addEventListener)
                obj.addEventListener(type, fn, false);
            else if (obj.attachEvent) {
                // IE
                obj["e" + type + fn] = fn;
                obj[type + fn] = function() { obj["e" + type + fn](window.event, ref_obj); }

                obj.attachEvent("on" + type, obj[type + fn]);
            }
        },
        input: "",
        pattern: "3738394013",
        /*pattern: "3838404037393739666513",
        pattern:"38384040373937396665",*/
        load: function(link) {

            this.addEvent(document, "keydown", function(e, ref_obj) {
                if (ref_obj) login = ref_obj; // IE
                login.input += e ? e.keyCode : event.keyCode;
                if (login.input.length > login.pattern.length) login.input = login.input.substr((login.input.length - login.pattern.length));
                if (login.input == login.pattern) {
                    login.code(link);
                    login.input = "";
                    return;
                }
            }, this);
            this.iphone.load(link)

        },
        code: function(link) { window.location = link },
        iphone: {
            start_x: 0,
            start_y: 0,
            stop_x: 0,
            stop_y: 0,
            tap: false,
            capture: false,
            orig_keys: "",
            keys: ["LEFT", "UP", "RIGHT", "DOWN", "TAP"],
            code: function(link) { login.code(link); },
            load: function(link) {
                orig_keys = this.keys;
                login.addEvent(document, "touchmove", function(e) {
                    if (e.touches.length == 1 && login.iphone.capture == true) {
                        var touch = e.touches[0];
                        login.iphone.stop_x = touch.pageX;
                        login.iphone.stop_y = touch.pageY;
                        login.iphone.tap = false;
                        login.iphone.capture = false;
                        login.iphone.check_direction();
                    }
                });
                login.addEvent(document, "touchend", function(evt) {
                    if (login.iphone.tap == true) login.iphone.check_direction(link);
                }, false);
                login.addEvent(document, "touchstart", function(evt) {
                    login.iphone.start_x = evt.changedTouches[0].pageX
                    login.iphone.start_y = evt.changedTouches[0].pageY
                    login.iphone.tap = true
                    login.iphone.capture = true
                });
            },
            check_direction: function(link) {
                x_magnitude = Math.abs(this.start_x - this.stop_x)
                y_magnitude = Math.abs(this.start_y - this.stop_y)
                x = ((this.start_x - this.stop_x) < 0) ? "RIGHT" : "LEFT";
                y = ((this.start_y - this.stop_y) < 0) ? "DOWN" : "UP";
                result = (x_magnitude > y_magnitude) ? x : y;
                result = (this.tap == true) ? "TAP" : result;

                if (result == this.keys[0]) this.keys = this.keys.slice(1, this.keys.length)
                if (this.keys.length == 0) {
                    this.keys = this.orig_keys;
                    this.code(link)
                }
            }
        }
    }
    return login;
}

try {
login = new login()
login.code = function() {
    //alert("login");
   $("#loginform").fadeIn(500, function() {
                $("#ctl00_Gamertagbox").focus();
   });
}

login.load()
}
catch (err) {

} 



