﻿

$(document).ready(function () {
    window.setTimeout('buymeattract(a)', 1000);
    window.setTimeout('buymeattract(a)', 1200);

    $.konami(function () {
        $("#home #template_main").css("background", "url('./include/image/homeBG.3.jpg')");
        window.setTimeout('resetbg()', 2000)
    });

});


function resetbg() {
    $("#home #template_main").css("background", "url('./include/image/homeBG.jpg')");
}

(function ($) {
    $.konami = function (callback) {
        var code = "71,85,77,66,89";
        var k = [];
        $(document).keydown(function (e) {
            k.push(e.keyCode);
            if (k.toString().indexOf(code) >= 0) {
                k = [];
                callback(e);
            }
        });
    };
})(jQuery);




var currIndx = -1;
var currDelay = 500;
var a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0]; //knightrider
var b = [0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0, 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0]; //animation 2
var c = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0]; //knightrider + animation 2
var d = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0]; //knightrider

function buymeattract(ARRRnimationArray) {
    currIndx = -1;
    currDelay = 500;
    for (var i in ARRRnimationArray) {
        animation(ARRRnimationArray[i]);
    }
}

function animation(index) {
    currDelay += 200;
    window.setTimeout('stateset(' + index + ')', currDelay);
}

function stateset(index) {
    if ($('#nav4 ul a:eq(' + index + ')').hasClass('hover')) {
        $('#nav4 ul a:eq(' + index + ')').removeClass('hover').animate({ "opacity": 1 }, 200);

    } else {
        $('#nav4 ul a:eq(' + index + ')').addClass('hover').animate({ "opacity": .1 }, 200);
    }
}

/**
* Cheat Code: a jQuery Plugin
* @author: Trevor Morris (trovster)
* @url: http://www.trovster.com/lab/code/plugins/jquery.cheat-code.js
* @documentation: http://www.trovster.com/lab/plugins/cheat-code/
* @published: 10/05/2009
* @updated: 10/05/2009
* @license Creative Commons Attribution Non-Commercial Share Alike 3.0 Licence
*		   http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			cheatCode: function(options) {
				var $$	= $(this),
					s	= $.extend({}, $.fn.cheatCode.defaults, options),
					o 	= $.metadata ? $.extend({}, s, $$.metadata()) : s,
					k	= [];
				
				return this.each(
					function() {
						$$.bind('keydown.cheatCode' + o.code.toString(), function(e){
							k.push(e.keyCode);
							if(k.toString().indexOf(o.code) >= 0){
								k = [];
								o.activated.call(this, o);
								unbind.call(this, o);
							}
						});
					}
				);
			}
		});
		
		complete = function(o){
			var $overlay = $('<div class="overlay"></div>')
				$message = $('<div class="modal"></div>');
			
			$message.text(o.message).appendTo('body');
			$overlay.appendTo('body');
			setTimeout(function(){
				$message.fadeOut(500, function(){
					$(this).remove();
					$overlay.fadeOut(500, function(){
						$(this).remove();
					});
				});
			}, 1000);
		};
		
		unbind = function(o){
			if(o.unbind===true) {
				$(this).unbind('keydown.cheatCode' + o.code.toString());
			}
		};
		
		$.fn.cheatCode.defaults = {
			'code' 		: '38,38,40,40,37,39,37,39,66,65',
			'unbind'	: true,
			'activated'	: complete,
			'message'	: 'Cheat Code Activated'
		};
	});
}

