function haveQuicktime() {
	var haveQt = false;
	if (navigator.plugins) {
		for (i=0; i < navigator.plugins.length; i++ ) {
			if (navigator.plugins[i].name.indexOf("QuickTime") >= 0)
				haveQt = true;
		}
	}
	return haveQt;
}

function footerPos() {
	var container_height = document.getElementById("container").offsetHeight;
	document.getElementById("footer-wrapper").style.marginTop = container_height+"px";
	document.getElementById("footer-wrapper").style.display = "block";
}

function isEmail(s) {
	var isEmail_re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
	return String(s).search (isEmail_re) != -1;
}

$(function() {
	if ($('a[rel*=fancybox]').length) { $('a[rel*=fancybox]').fancybox({ overlayOpacity: .80, hideOnContentClick: false }); }
	if ($('.interview-clip a').length) { $('.interview-clip a').fancybox({ overlayOpacity: .80, frameWidth: 480, frameHeight: 286, hideOnContentClick: false }); }
	
	var email_text = 'ENTER YOUR EMAIL FOR UPDATES';
	$('#email-footer').click(function() { if ($(this).attr('value') == email_text) $(this).attr('value', '');
	}).blur(function() { if ($(this).attr('value') == '') $(this).attr('value', email_text);
	}).attr('value', email_text);
	
	if ($('#interviews').length) {
		if (!haveQuicktime()) {
			$.each($('object'), function() {
				var the_id = $(this).attr('id');
				$(this).css('display','none');
				$(this).before('<a href="http://www.apple.com/quicktime/download/">Install Quicktime</a>');
			});
		}
	}
	
	$('#footer-form').submit(function() {
		$('input#submit').attr('disabled','disabled');
		var target = $(this).attr('action');
		var email = $('input#email-footer').val();
		if ((email != email_text) && (email.replace(/^\s+|\s+$/g, '') != '' && isEmail(email))) {
			$.post(target,{ 'email': email }, function(data) {
				alert(data);
				$('input#submit').removeAttr('disabled');
			});	
		}
		return false;
	});
});