$(document).ready(function () {
	
	$("#dropdown").css("opacity","0"); 

    $("a.block").click(function () {

		//set vars based on which block was clicked
		
		if ($(this).hasClass("pos1"))
		{
			var startTop = "0px";
			var startLeft = "0px";
			var animateTop = "0px";
			var animateLeft = "0px";

		}
		
		else if ($(this).hasClass("pos2"))
		{

			var animateTop = "0px";
			var animateLeft = "-330px";

		}
		
		else if ($(this).hasClass("pos3"))
		{
			var startTop = "0px";
			var startLeft = "-660px";
			var startRight = "0px";
			var animateTop = "0px";
			var animateLeft = "-660px";

		}

		else if ($(this).hasClass("pos4"))
		{
			var startTop = "0";
			var startLeft = "0px";
			var animateTop = "-330px";
			var animateLeft = "0px";
		}
		
		else if ($(this).hasClass("pos5"))
		{
			var animateTop = "-330px";
			var animateLeft = "-330px";
		}
		
		else if ($(this).hasClass("pos6"))
		{
			var startRight = "0px";
			var animateTop = "-330px";
			var animateLeft = "-660px";
		}
		
		else if ($(this).hasClass("pos7"))
		{
			var animateTop = "-660px";
			var animateLeft = "0px";
		}
		
		else if ($(this).hasClass("pos8"))
		{
			var animateTop = "-660px";
			var animateLeft = "-330px";
		}
		
		else if ($(this).hasClass("pos9"))
		{
			var startRight = "0px";
			var animateTop = "-660px";
			var animateLeft = "-660px";

		}				
		
        var request = $(this).attr('href');
        if (!$(this).next("div").hasClass("active")) {

            $(this).next("div").addClass("active").fadeTo("fast", 1).css({
                cursor: "auto",
                position: "absolute",
                top: "0px",
                left: "0px",
				right: startRight,
				"z-index": "99",
                "background-color": "#000"
            }).animate({
				left:animateLeft,
				top:animateTop,
                width: "960",
                height: "960"
            }, function () {
                $(this).children("div.ajaxygoeshere").load(request + " .mainContent", function () {
                	
                    $(this).delay(3000).fadeTo("fast", 1);

                }),
			 $(this).children("span.close").fadeTo("fast", 1);

            });
            return false;
        } else {
            return false;
        }
    });
	
	/*******************************CLOSE SCRIPT****************************************/
	
	    $("span.close").click(function () {
			
		$(this).prev().children(".ajaxygoeshere .mainContent").fadeTo("fast", 0).css({
                        display: "none;"
                    });
        $(this).parent().removeClass("active").css({
            cursor: "pointer",
            position: "absolute",
			"z-index": "60"
        }).animate({
            width: "300",
            height: "300",
			left: "0",
			top: "0"
        }).fadeTo("fast", 0);
		
		setTimeout(function(){
      $('.contentHolder').css({"z-index": "1"});
},500);

        return false;
    });

    /*******************************TOP BAR SCIPT*******************************/

    $("a.closethis").click(

    function () {
        $(this).parent().parent().animate({
            "height": "1px",
            "opacity": "0",
            "paddingTop": "0px",
            "paddingBottom": "0px",
            "marginBottom": "145px"
        }, "fast");
    });

    $("a.showthat").click(

    function () {
        $("a.closethis").parent().parent().animate({
            "height": "278px",
            "opacity": "1",
            "paddingTop": "30px",
            "paddingBottom": "0px",
            "marginBottom": "0px" //CHANGED FOR COMING SOON PAGE
        }, "fast");
    });

    /*******************************PIXELATE SCRIPT************************************/

    var pixelations = {
        'pos1': [{
            shape: 'diamond',
            resolution: 48,
            size: 50
        },
        {
            shape: 'diamond',
            resolution: 48,
            offset: 24
        },
        {
            shape: 'circle',
            resolution: 8,
            size: 6
        }],
        'pos2': [{
            resolution: 32
        },
        {
            shape: 'circle',
            resolution: 32,
            offset: 15
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 26,
            offset: 13
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 18,
            offset: 10
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 12,
            offset: 8
        }],
        'pos3': [{
            resolution: 48
        },
        {
            shape: 'diamond',
            resolution: 48,
            offset: 12,
            alpha: 0.5
        },
        {
            shape: 'diamond',
            resolution: 48,
            offset: 36,
            alpha: 0.5
        },
        {
            shape: 'circle',
            resolution: 16,
            size: 8,
            offset: 4,
            alpha: 0.5
        }],
        'pos4': [{
            shape: 'circle',
            resolution: 32,
            size: 6,
            offset: 8
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 9,
            offset: 16
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 12,
            offset: 24
        },
        {
            shape: 'circle',
            resolution: 32,
            size: 9,
            offset: 0
        }],
        'pos5': [{
            shape: 'diamond',
            resolution: 24,
            size: 25
        },
        {
            shape: 'diamond',
            resolution: 24,
            offset: 12
        },
        {
            resolution: 24,
            alpha: 0.5
        }],
        'pos6': [{
            shape: 'square',
            resolution: 32
        },
        {
            shape: 'circle',
            resolution: 32,
            offset: 16
        },
        {
            shape: 'circle',
            resolution: 32,
            offset: 0,
            alpha: 0.5
        },
        {
            shape: 'circle',
            resolution: 16,
            size: 9,
            offset: 0,
            alpha: 0.5
        }],
        'pos7': [{
            shape: 'circle',
            resolution: 24
        },
        {
            shape: 'circle',
            resolution: 24,
            size: 9,
            offset: 12
        }],
        'pos8': [{
            shape: 'square',
            resolution: 48,
            offset: 24
        },
        {
            shape: 'circle',
            resolution: 48,
            offset: 0
        },
        {
            shape: 'diamond',
            resolution: 16,
            size: 15,
            offset: 0,
            alpha: 0.6
        },
        {
            shape: 'diamond',
            resolution: 16,
            size: 15,
            offset: 8,
            alpha: 0.6
        }],
        'pos9': [{
            shape: 'square',
            resolution: 48
        },
        {
            shape: 'diamond',
            resolution: 12,
            size: 8
        },
        {
            shape: 'diamond',
            resolution: 12,
            size: 8,
            offset: 6
        }, ]
    };

    var docReady = function () {

        for (var key in pixelations) {
            var img = document.getElementById(key),
                options = pixelations[key];
            if (img) {
                img.closePixelate([{
                    shape: 'square',
                    resolution: 14
                }])
            }
        }
    };

    window.addEventListener('DOMContentLoaded', docReady, false);
	
	$("a.block").hover(
	function() {
		$(this).children("canvas").stop().fadeTo("fast", 1);
		
	},
	function () {
				$(this).children("canvas").stop().fadeTo("fast", 0);
	});

});
