﻿/*
*  Live Nation UK
*  http://www.livenation.co.uk/
*	Matthew French 04/11/09
*
*/

var StripeBox = {

	BuildAll: function() {

		$("#sbxOpen").attr('href', '#');
		$("#sbxOpen").click(function() {
			StripeBox.DisplayStripeBox();
		});

		$("#sbxClose").click(function() {
			StripeBox.RemoveStripeBox();
		});

	},

	AddStripe: function(param) {
		for (var j = 1; j < param + 1; j++) {
			$('#sbxStripe').append("<div id='sbx" + j + "' class='sbx'></div>");
		};
	},

	AnimateStripe: function(i, x) {
		var numRand = Math.floor(Math.random() * 10) * 10 + 515;
		$("#sbx" + i).animate({ width: numRand + 'px' }, 50, function() {
			if (i < x) {
				StripeBox.AnimateStripe(i + 1, x);
			} else if (i == x) {
				$("#sbxHolder").css({ display: "block" });
			};
		});
	},

	RemoveStripeBox: function() {
		$('#sbxHolder').css({ display: "none" });
		$('#sbxStripe').remove("");
		$('#sbxFade').remove("");
	},

	DisplayStripeBox: function() {
		var docHeight = $("#wrapperHolder").height();		

		$('#sbxHolder').after("<div id='sbxStripe'></div><div id='sbxFade'></div>");
		$("#sbxFade").css('height', docHeight + 100);

		$("#sbxFade").fadeIn('fast', function() {
			$("#sbxStripe").css({ display: "block" });
			$(".sbx").css({ display: "block" });
			StripeBox.AddStripe(8);
			StripeBox.AnimateStripe(1, 8);
		});
	}
};

$(document).ready(function() {
    StripeBox.BuildAll();
});	