// JavaScript Document

function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}




var bgimg;
var init = function() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  bgimg = document.getElementById('bg').getElementsByTagName('img')[0];
  if (!bgimg) return;
  bgimg.onload = resizeBg;
  bgimg.src = 'images/finch-about.jpg';
  if (window.addEventListener) window.addEventListener('resize', resizeBg, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBg);
  else window.onresize = resizeBg;
}
var resizeBg = function() {
  var w = self.innerWidth || document.documentElement.clientWidth;
  var h = self.innerHeight || document.documentElement.clientHeight;
  if (bgimg.width !== w) {
    bgimg.parentNode.style.left = '0';
    bgimg.parentNode.style.top = '0';
    bgimg.height = bgimg.parentNode.height = (w / bgimg.width) * bgimg.height;
    bgimg.width = bgimg.parentNode.width = w;
  }
  if (bgimg.height < h) {
    bgimg.width = bgimg.parentNode.width = (h / bgimg.height) * bgimg.width;
    bgimg.height = bgimg.parentNode.height = h;
    bgimg.parentNode.style.left = '-' + ((bgimg.width - w) / 2) + 'px';
  }
  else if (bgimg.height > h) {
    bgimg.parentNode.style.top = '-' + ((bgimg.height - h) / 2) + 'px';
  }
}

if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

/*@cc_on @*/
/*@if (@_win32 || @_win64)
  document.write('<script id="ie_onload" defer src="javascript:void(0);"></script>');
  document.getElementById('ie_onload').onreadystatechange = checkState;
  function checkState() {
    if (this.readyState && this.readyState != 'complete') return;
    else init();
  }
    
/*@end @*/

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}



var bgcimg;
var init = function() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  bgcimg = document.getElementById('bgc').getElementsByTagName('img')[0];
  if (!bgcimg) return;
  bgcimg.onload = resizeBgc;
  bgcimg.src = 'images/finch-contact.jpg';
  if (window.addEventListener) window.addEventListener('resize', resizeBgc, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBgc);
  else window.onresize = resizeBgc;
}
var resizeBgc = function() {
  var w = self.innerWidth || document.documentElement.clientWidth;
  var h = self.innerHeight || document.documentElement.clientHeight;
  if (bgcimg.width !== w) {
    bgcimg.parentNode.style.left = '0';
    bgcimg.parentNode.style.top = '0';
    bgcimg.height = bgcimg.parentNode.height = (w / bgcimg.width) * bgcimg.height;
    bgcimg.width = bgcimg.parentNode.width = w;
  }
  if (bgcimg.height < h) {
    bgcimg.width = bgcimg.parentNode.width = (h / bgcimg.height) * bgcimg.width;
    bgcimg.height = bgcimg.parentNode.height = h;
    bgcimg.parentNode.style.left = '-' + ((bgcimg.width - w) / 2) + 'px';
  }
  else if (bgcimg.height > h) {
    bgcimg.parentNode.style.top = '-' + ((bgcimg.height - h) / 2) + 'px';
  }
}

if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

/*@cc_on @*/
/*@if (@_win32 || @_win64)
  document.write('<script id="ie_onload" defer src="javascript:void(0);"></script>');
  document.getElementById('ie_onload').onreadystatechange = checkState;
  function checkState() {
    if (this.readyState && this.readyState != 'complete') return;
    else init();
  }
    
/*@end @*/

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}



var bgwimg;
var init = function() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  bgwimg = document.getElementById('bgw').getElementsByTagName('img')[0];
  if (!bgwimg) return;
  bgwimg.onload = resizeBgw;
  bgwimg.src = 'images/finch-work.jpg';
  if (window.addEventListener) window.addEventListener('resize', resizeBgw, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBgw);
  else window.onresize = resizeBgw;
}
var resizeBgw = function() {
  var w = self.innerWidth || document.documentElement.clientWidth;
  var h = self.innerHeight || document.documentElement.clientHeight;
  if (bgwimg.width !== w) {
    bgwimg.parentNode.style.left = '0';
    bgwimg.parentNode.style.top = '0';
    bgwimg.height = bgwimg.parentNode.height = (w / bgwimg.width) * bgwimg.height;
    bgwimg.width = bgwimg.parentNode.width = w;
  }
  if (bgwimg.height < h) {
    bgwimg.width = bgwimg.parentNode.width = (h / bgwimg.height) * bgwimg.width;
    bgwimg.height = bgwimg.parentNode.height = h;
    bgwimg.parentNode.style.left = '-' + ((bgwimg.width - w) / 2) + 'px';
  }
  else if (bgwimg.height > h) {
    bgwimg.parentNode.style.top = '-' + ((bgwimg.height - h) / 2) + 'px';
  }
}

if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

/*@cc_on @*/
/*@if (@_win32 || @_win64)
  document.write('<script id="ie_onload" defer src="javascript:void(0);"></script>');
  document.getElementById('ie_onload').onreadystatechange = checkState;
  function checkState() {
    if (this.readyState && this.readyState != 'complete') return;
    else init();
  }
    
/*@end @*/

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}




var bgpimg;
var init = function() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  bgpimg = document.getElementById('bgp').getElementsByTagName('img')[0];
  if (!bgpimg) return;
  bgpimg.onload = resizeBgp;
  bgpimg.src = 'images/finch-placer.jpg';
  if (window.addEventListener) window.addEventListener('resize', resizeBgp, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBgp);
  else window.onresize = resizeBgp;
}
var resizeBgp = function() {
  var w = self.innerWidth || document.documentElement.clientWidth;
  var h = self.innerHeight || document.documentElement.clientHeight;
  if (bgpimg.width !== w) {
    bgpimg.parentNode.style.left = '0';
    bgpimg.parentNode.style.top = '0';
    bgpimg.height = bgpimg.parentNode.height = (w / bgpimg.width) * bgpimg.height;
    bgpimg.width = bgpimg.parentNode.width = w;
  }
  if (bgpimg.height < h) {
    bgpimg.width = bgpimg.parentNode.width = (h / bgpimg.height) * bgpimg.width;
    bgpimg.height = bgpimg.parentNode.height = h;
    bgpimg.parentNode.style.left = '-' + ((bgpimg.width - w) / 2) + 'px';
  }
  else if (bgpimg.height > h) {
    bgpimg.parentNode.style.top = '-' + ((bgpimg.height - h) / 2) + 'px';
  }
}

if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

/*@cc_on @*/
/*@if (@_win32 || @_win64)
  document.write('<script id="ie_onload" defer src="javascript:void(0);"></script>');
  document.getElementById('ie_onload').onreadystatechange = checkState;
  function checkState() {
    if (this.readyState && this.readyState != 'complete') return;
    else init();
  }
    
/*@end @*/

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}



var bghimg;
var init = function() {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  bghimg = document.getElementById('bgh').getElementsByTagName('img')[0];
  if (!bghimg) return;
  bghimg.onload = resizeBgh;
  bghimg.src = 'images/shark.jpg';
  if (window.addEventListener) window.addEventListener('resize', resizeBgh, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBgh);
  else window.onresize = resizeBgh;
}
var resizeBgh = function() {
  var w = self.innerWidth || document.documentElement.clientWidth;
  var h = self.innerHeight || document.documentElement.clientHeight;
  if (bghimg.width !== w) {
    bghimg.parentNode.style.left = '0';
    bghimg.parentNode.style.top = '0';
    bghimg.height = bghimg.parentNode.height = (w / bghimg.width) * bghimg.height;
    bghimg.width = bghimg.parentNode.width = w;
  }
  if (bghimg.height < h) {
    bghimg.width = bghimg.parentNode.width = (h / bghimg.height) * bghimg.width;
    bghimg.height = bghimg.parentNode.height = h;
    bghimg.parentNode.style.left = '-' + ((bghimg.width - w) / 2) + 'px';
  }
  else if (bghimg.height > h) {
    bghimg.parentNode.style.top = '-' + ((bghimg.height - h) / 2) + 'px';
  }
}

if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

/*@cc_on @*/
/*@if (@_win32 || @_win64)
  document.write('<script id="ie_onload" defer src="javascript:void(0);"></script>');
  document.getElementById('ie_onload').onreadystatechange = checkState;
  function checkState() {
    if (this.readyState && this.readyState != 'complete') return;
    else init();
  }
    
/*@end @*/

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}



// <![CDATA[ FORMS
function validate(form){
                 email = form.email_address.value
		invalidChars = "/:,;"
		
	
if(email == "")
		{
			alert("Please provide your email address.");
			return false;
		}


		if(email.indexOf(" ") != -1)
		{
			alert("We could not send your message. Please make sure there are no spaces in or after your email address.");
			return false;
		}

		if(email != "")
		{
			

		for(i=0; i<invalidChars.length; i++)
		{
			badChar = invalidChars.charAt(i);
			if(email.indexOf(badChar,0) != -1)
			{
				alert("We could not send your message because you have invalid characters in your email address.");
				return false;
			}
		}
		atPos = email.indexOf("@",1)
		if(atPos == -1)
		{
			alert("We could not send your message because you provided an invalid email address.");
			return false;
		}

		if(email.indexOf("@", atPos+1) != -1)
		{
			alert("We could not send your message because you provided an invalid email address.");
			return false;
		}

		periodPos = email.indexOf(".",atPos);
		if(periodPos == -1)
		{
			alert("We could not send your message because you provided an invalid email address.");
			return false;
		}

		if(periodPos+3>email.length)
		{
			alert("We could not send your message because you provided an invalid email address.");
			return false;
		}
		}	

		
				
		return true;
}
// ]]>
