
/*
Number of coulds, max size of could, min size of cloud, width of container
Container width is auto populated via a variable
example: insertClouds(30, 500, 100, containerWidth);


function resetCloud() {
    $(".cloud").each(function() {
        if ($(this).offset().left <= $(this).attr("data-width")) {
            $(this).css({
                left: $("body").outerWidth() + $(this).outerWidth()
            });
            animateCloud($(this));
        }
    });
}
function animateCloud(cloud) {
    var speed = 0;
    speed = Math.ceil((50000-30000)*Math.random()) + (30001);
    $(cloud).delay((speed / 10)).animate({
        left: -$(cloud).attr("data-width")
    }, speed, 'linear', function() {
        resetCloud($("body").outerWidth())
    });    
}
function insertClouds(num, max, min, container) {
    num -= 1;
    for (i=0;i<=num;i++) {
        var cloud = $("<div class='cloud'></div>").appendTo("body");
        var width = Math.floor((max-min)*Math.random()) + (min + 1);
        var topOffset = Math.floor((350-20)*Math.random()) + (21);
        var leftOffset = Math.floor((container-0)*Math.random()) + (1);
        var image = Math.floor((4-1)*Math.random()) + (2);
        $(cloud).css({
            //height: width * 0.65,
            //width: width,
            "background-image": "url('../images/clouds/cloud-" + image + ".png')",
            top: topOffset,
            left: leftOffset,
            "z-index": i
        });
        $(cloud).attr("data-width", width);
        $(cloud).attr("data-position", leftOffset);
        animateCloud($(cloud));
    }
}
*/

function animateEyes() {
    var color = $("#eyes").css("background-color");
    if (color == "rgb(153, 0, 0)") {
        $("#eyes").animate({
            "background-color": "#c00"
        },900);    
    } else {
        $("#eyes").animate({
            "background-color": "#900"
        },900);
    }
}

function static() {
	$("#static").removeClass();
	var style = new Array('static0', 'static1', 'static2', 'static3');
	var position = Math.floor((4-0)*Math.random());
	$("#static").addClass(style[position]);
}

	$(document).ready(function () {
				body = $('body');
				body.localScroll({
					duration: 300
				});
			$.localScroll.hash();
		
		
		//var containerWidth = $("body").outerWidth();
		//insertClouds(8, 500, 0, containerWidth);
		
		
		$("#mouth, nav a[href=#mouth]").click(function() {
			$("#enter").delay(300).fadeTo(400,0);
			$("#enteragain").css("opacity", "0").hide();
			$("#mouth").delay(600).animate({
				height : 4500
			},
			{
				duration: 400, 
				specialEasing: {
					height: 'easeOutBounce'
				}
			});
			$("#upper").animate({
				top : 0
			},
			{
				duration: 150, 
				specialEasing: {
					height: 'easeOutBounce'
				}
			});
			$("#mouth #submission, #mouth #finalists").delay(900).fadeTo(300,1);
		});
		
		$("#close").click(function(){
			$("#enteragain").delay(600).show().fadeTo(600,1);
			$("#mouth").animate({
				height : 238
			},
			{
				duration: 400, 
				specialEasing: {
					height: 'easeOutBounce'
				}
			});
			$("#upper").animate({
				top : 0
			},
			{
				duration: 150, 
				specialEasing: {
					height: 'easeOutBounce'
				}
			});
			$("#mouth #submission, #mouth #finalists").fadeTo(300,0);
			return false;
		});
		$(".c li a").click(function() {
			$("#mouth").delay(1000).trigger("click");
		});
		setInterval ( "static()", 250 );
		setInterval ("animateEyes()",1000);
	});
