$(function(){
	window.makeMailLinks()?makeMailLinks():null;
	window.movieLightbox?movieLightbox($('a[rel=movielightbox]')):null;
	$('html').addClass('js');
	window.highlightIncomplete?highlightIncomplete():null;
	});


	/* <span class="email">x (at) x.com</span> becomes <a href="x@x.com">x@x.com</a> 
* this is an anti-spam measure
*/
function makeMailLinks(){
		$('span.email').each(function(){
			var theAddress = $(this).text().replace(/ \(at\) /, "@");
			$(this).replaceWith($('<a href="mailto:'+theAddress+'">'+theAddress+'</a>'));
			});
	}

function movieLightbox(e){
	$(e).click(function(){
		$('body').append('<div id="overlay"></div><div class="lightboxcontainer"><div class="close"></div><div class="lightboxcontent"></div></div>');
		$('#overlay').height($(document).height()).show();
		$('.close,#overlay').click(function(){
			$('#overlay,.lightboxcontainer').remove();
			});
		var width = 720+20;
		var height = 404+20;
		$('.lightboxcontainer').css({
						"width": width+'px',
						"height": height+'px',
						"margin-left": "-"+parseInt(width)/2+'px',
						"margin-top": "-"+parseInt(height)/2+'px'
					});
					/* exception for position absolute (IE6) */
					if($('.lightboxcontainer').css('position')=='absolute'){
						$('.lightboxcontainer').css({"margin-top": 0,"top": (parseInt($(window).scrollTop())+30)+'px'});
						}
		$('.lightboxcontent').load($(this).attr('href'),{'lightbox':'true'});
		return false;
		});
	}
function highlightIncomplete(){
	$('form').submit(function(){
		$('.fail').removeClass('fail');
		$('input.required,textarea.required').each(function(){
			if($(this).val()==''){
				$(this).addClass('fail');
				}
			});
		
		
			if($('.fail').size()>0) {
					$('.warning').slideDown();
				return false;
				}else{
					$('.warning').slideUp();
					}
			/*return true;*/
		});
	}

