
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}


// Splash Slideshow

if (window.location.pathname == '/') {
	var slideshowSpeed = 4000;
} else {
	var slideshowSpeed = 7000;
}

function slideshow() {
	if (document.getElementById('slideshow')) {
		$('#slideshow').cycle({
			fx:      'fade', 
			speed:    1200, 
			timeout:  slideshowSpeed,
			pause:   0
		});
		
		$('#slideshow.paused')
			.each(function () {
				pausePlay();
			})
		;
	}
}

function popupImages() {
	$("a.popup").fancybox({
		'hideOnContentClick'	: false,
		'overlayShow'			: true,
		'overlayColor'			: '#000000',
		'overlayOpacity'		: 0.8

	});
}

function popupVideos() {

	$(".openvideo").fancybox({
			'overlayShow'		: true,
			'overlayOpacity'        : 0.7,
			'padding'		: 6,
			//'zoomSpeedIn'		: 800,
			//'zoomSpeedOut'	: 500,
			'imageScale'            : false,
			'zoomOpacity'           : false,
			'frameWidth'		: 748,
			'hideOnContentClick'	: false,
			'frameHeight'           : 531
			//'easingIn'		: 'easeInExpo',
			//'easingOut'		: 'easeOutExpo'
	});
}
 
 
// Build form elements

function accessibility() {
	$('.jsSubmit').show();
	$('.nojsSubmit').hide();
	
	$('.jsRemove').hide();
}


// Email address obfuscator

function mangle() {
	if (!document.getElementsByTagName && !document.createElement &&
		!document.createTextNode) return;
	var nodes = document.getElementsByTagName("span");
	for(var i=nodes.length-1;i>=0;i--) {
		if (nodes[i].className=="fixEmail") {
			var at = / at /;
			var dot = / dot /g;
			var node = document.createElement("a");
			var address = nodes[i].firstChild.nodeValue;

			address = address.replace(at, "@");
			address = address.replace(dot, ".");

			node.setAttribute("href", "mailto:"+address);
			node.appendChild(document.createTextNode(address));
			
			var prnt = nodes[i].parentNode;
			for(var j=0;j<prnt.childNodes.length;j++)
				if (prnt.childNodes[j] == nodes[i]) {
					if (!prnt.replaceChild) return;
					prnt.replaceChild(node, prnt.childNodes[j]);
					break;
				}
		}
	}
}


$(document).ready(function() {
	window.setTimeout(function() { slideshow() },500);
	popupImages();
	popupVideos();
	accessibility();
	mangle();
});


