﻿$(document).ready(function () {
	var url = window.location.hostname;
	var filter = 'a[href^="http"]:not([href*="' + url + '"])';
	filter = filter + ':not([href*="youtube.com"])';
	filter = filter + ', a[href*=".pdf"]';
	$(filter).each(function () { $(this).attr('target', '_blank'); });

	/* This is basic - uses default settings */
	$("a.fancybox").fancybox();

	$("a.fancybox-video").click(function () {
		$.fancybox({
			'padding': 10,
			'autoScale': false,
			'transitionIn': 'none',
			'transitionOut': 'none',
			'title': this.title,
			'width': 640,
			'height': 360,
			'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type': 'swf',
			'swf': {
				'wmode': 'transparent',
				'allowfullscreen': 'true'
			}
		});
		return false;
	});
});

function clickContainerTitle(objDiv, aObj){
	var descDiv = objDiv.children().eq(2);
	descDiv.slideToggle();
	$(aObj).toggleClass('open');
}

function resizeIframe() {
	var theIframe = $('iframe[name="search"]')
	theIframe.height(0);
	theIframe.each(function () {
		var loadHeight;
		if (this.contentDocument) {
			loadHeight = this.contentDocument.body.offsetHeight + 35;
		}
		else {
			loadHeight = this.contentWindow.document.body.scrollHeight;
		}
		$(this).height(loadHeight);
	});
}
