
jQuery.flash = {
	change: function(i)
	{
		$('#home .menu a').removeClass('active');
		$('#home .menu a').eq(i - 1).addClass('active');
	}
};


$().ready(function() {
	var data = ["http:\/\/www.ruthless-toothless.com\/admin\/..\/assets\/media\/SKETCHPADS2.jpg","http:\/\/www.ruthless-toothless.com\/admin\/..\/assets\/media\/NewArrivals-skatedecks3.jpg","http:\/\/www.ruthless-toothless.com\/admin\/..\/assets\/media\/Lovebug2.jpg","http:\/\/www.ruthless-toothless.com\/admin\/..\/assets\/media\/posterpage3.jpg","http:\/\/www.ruthless-toothless.com\/admin\/..\/assets\/media\/Phone4.jpg"];
	
	$('#home .gallery').gallery({ data: data });

	/*
	var flash;

	flash = new SWFObject("http://www.ruthless-toothless.com/assets/swf/home.swf", 'home-flash', 995, 445, '8', '#000000');
	flash.addParam('allowScriptAccess', 'always');
	flash.addParam('allowFullScreen', 'true');
	flash.addParam('wmode', 'transparent');
	flash.addVariable('data', data);
	flash.write($('#home .flash')[0]);
	*/

	var i = 1;

	$('#home .products').scrollable({ auto: true, count: 2 });
	
	
	if ($.flashVersion()[0] >= 7) {
		$('#home .videos ul li a').attr('href', 'javascript:void(0)').attr('target', '_self').overlay({
			speed: 0,
			target: '#videos-overlay',
			top: 75,
			effect: 'apple',
			closeOnClick: false,
			closeSpeed: 0,
			onBeforeLoad: function() {
				window.scroll(0, 0);
				$('#home .products').scrollable('pause');
			},
			onClose: function() {
				$('#home .products').scrollable('play');
			},
			onLoad: function() { 
				var id = this.getTrigger().attr('rel');
				var flash;
	
				flash = new SWFObject("http://vimeo.com/moogaloop.swf?clip_id=" + id +"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=59a5d1&amp;fullscreen=1", 'home-flash', 640, 360, '8', '#000000');
				flash.addParam('allowScriptAccess', 'always');
				flash.addParam('allowFullScreen', 'true');
				flash.write($('#videos-overlay .video')[0]);
			}
		});
	}
	
	$('#home .newsletter form').validate({
		submit: function(valid) {
			if (!valid) return;
			
			var $input = $('#home .newsletter input');
			
			$.ajax({
				type: 'POST',
				url: '{path}',
				data: 'email=' + $input.val(),
				success: function() {
					alert('Thanks for subscribing.');
					$input.val($input.attr('title'));
				}
			});
		}
	});
});