var wp_url = "http://lane7bowl.com/wp-content/"
var template_directory = "http://lane7bowl.com/wp-content/themes/lane7"

$(function() {
	// Adding Google Page Tracking
	var pageTracker = _gat._getTracker("UA-132767-18");
	pageTracker._trackPageview();

	label_maker() // Shiny labels help everyone
	fix_body() // Update the body height on resize
	add_email_value() // Set default values for the email form
	rendering_flash() // Load in our Flash cells
	flash_media_player() // For Jake's MP3 Interview
	
	$('ul.gallery li a').lightBox({
		imageLoading:	template_directory + '/images/lightbox-ico-loading.gif',
		imageBtnClose:	template_directory + '/images/lightbox-btn-close.gif',
		imageBtnPrev:	template_directory + '/images/lightbox-btn-prev.gif',
		imageBtnNext:	template_directory + '/images/lightbox-btn-next.gif',
		imageBlank:		template_directory + '/images/lightbox-blank.gif'
	})
	
	$('ul.gallery li').each(function(i) {
		if ((i % 3) == 0) $(this).css({ clear: 'left' })
	})

})

var label_maker = function() {
	$('ul').each(function() {
		$(this).find('li:first').addClass('first')
		$(this).find('li:last').addClass('last')
		$(this).find('li:even').addClass('odd')
		$(this).find('li:odd').addClass('even')
	})
	
	$('form').each(function() {
		$(this).find(':text').addClass('text')
		$(this).find(':submit, :button')
		  .addClass('button')
		  .addClass('submit')
		  .find(':submit')
	})
}

var fix_body = function() {
	var rejigger = function() {
		if ( $('.wrapper').height() > $('body').height() ) {
			$('body').height($('.wrapper').height())
		} else {
			$('body').css({ minHeight: '100%' })
		}
	}

	$(window).resize(function() { rejigger() })

	rejigger();
}

var add_email_value = function() {
	$('#ote-12all-box input:first')
	  .val('Please enter your email address')
	  .css({ color: '#9b9b9b' })
	  .focus(function() {
	  	$(this)
	  	  .val('')
		  .css({ color: '' })
	  })
}

var rendering_flash = function() {
	$('#renderings	')
	.css({ marginTop: '1em' })
	.flash({
		width: 545,
		height: 231,
		src: template_directory + '/flash/temp_page.swf'
	})
	
	$('.alt').css({
		position: 'absolute',
		top: '-5000em',
		left: '-5000em'
	})
}

var flash_media_player = function() {
	$('a[@href$="mp3"]').flash(
		{ src: template_directory + '/flash/mp3player.swf', height: 20, width: "50%" },
		{ version: 7 },
		function(htmlOptions) {
			$this = $(this);
			htmlOptions.flashvars.file = $this.attr('href');
			$this.after($.fn.flash.transform(htmlOptions));
		}
	);
}