$(document).ready(function() {
	$("#AgreedToAllTerms").remove();
	
	$("a.fancybox").fancybox({
		'titlePosition': 'inside',
		'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
			if (currentArray.length == 1) {
				if (title !== undefined && title !== '' && title !== ' ') {
					return '<span id="fancybox-title-inside">' + title + '</span>';
				}
			} else {
				if (title === undefined || title === '' || title === ' ') {
					title = '';
				} else {
					title = ' - ' + title;
				}
				return '<span id="fancybox-title-inside">'
				 + '<strong>Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</strong>'
				 + title + '</span>';
			}
		}
	});
	$("a.fancyboxVideo").fancybox({
		'titlePosition': 'inside',
		'type': 'iframe',
		'scrolling': 'no',
		'width': 480,
		'height': 360
	});
	$("a.fancyboxVideo16x9").fancybox({
		'titlePosition': 'inside',
		'type': 'iframe',
		'scrolling': 'no',
		'width': 480,
		'height': 320
	});
	$("a.fancyboxVideoJukebox").fancybox({
		'titlePosition': 'inside',
		'type': 'iframe',
		'scrolling': 'no',
		'width': 680,
		'height': 360
	});
	$("a.youtube").click(function() {
		var urlVars = this.href.split("?");
		$.fancybox({
			'titlePosition': 'inside',
			'type': 'iframe',
			'scrolling': 'no',
			'href' : '/video/play.cfm?' + urlVars[1],
			'width': 640,
			'height': 385,
			'title': this.title
		});
		return false;
	});
	$("a.bioPopup").fancybox({
		'titlePosition': 'inside',
		'type': 'inline',
		'autoDimensions': false,
		'width': 480,
		'height': 320
	});
});

function searchFocus(inputBoxId) {
	var box = document.getElementById(inputBoxId);
	if (box.value == 'SEARCH') {
		box.value = '';
		box.style.color = '#000';
	} else if (box.value == '') {
		box.value = 'SEARCH';
		box.style.color = '#999';
	}
}

function showHide(elementID, displayType) {
	var element = document.getElementById(elementID);
	if (element.style.display == 'none') {
		element.style.display = displayType;
	} else {
		element.style.display = 'none';
	}
}

function hideBilling() {
	showHide('billingInformationSection', 'none');
	showHide('billToCardNumberSection', 'none');
	showHide('billToCardExpirationSection', 'none');
	showHide('billToNameOnCardSection', 'none');
	showHide('billToEmailSection', 'none');
	showHide('billingAddressSection', 'none');
}

function showBilling() {
	showHide('billingInformationSection', 'none');
	showHide('billToCardNumberSection', 'none');
	showHide('billToCardExpirationSection', 'none');
	showHide('billToNameOnCardSection', 'none');
	showHide('billToEmailSection', 'none');
	showHide('billingAddressSection', 'none');
	showHide('billingInformationSection', 'block');
	showHide('billToCardNumberSection', 'block');
	showHide('billToCardExpirationSection', 'block');
	showHide('billToNameOnCardSection', 'block');
	showHide('billToEmailSection', 'block');
	showHide('billingAddressSection', 'block');
}
