function checkEmail(strng) {
	var error = "";
	var emailFilter=/^.+@.+\..{2,6}$/;
	if (!(emailFilter.test(strng))) {
		return false;
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\] ']/
	if (strng.match(illegalChars)) {
		return false;
	}
	return true;
}
function formVal(thefields,emailfields) {
	thereturn = true;
	if (thefields!='') {
		
		fparts = thefields.split(",");
		for (i = 0; i < fparts.length; i++) {
			if (document.getElementById(fparts[i]).value=='') {
				document.getElementById(fparts[i]).style.borderColor='#ff0000';
				document.getElementById(fparts[i]).style.background='#ffeeee';
				thereturn = false;
			}else{
				document.getElementById(fparts[i]).style.borderColor='#999999';
				document.getElementById(fparts[i]).style.background='#ffffff';
			}
		}
		
	}
	
	if (emailfields!='') {
		
		fparts = emailfields.split(",");
		for (i = 0; i < fparts.length; i++) {
			if (!checkEmail(document.getElementById(fparts[i]).value)) {
				document.getElementById(fparts[i]).style.borderColor='#ff0000';
				document.getElementById(fparts[i]).style.background='#ffeeee';
				thereturn = false;
			}else{
				document.getElementById(fparts[i]).style.borderColor='#999999';
				document.getElementById(fparts[i]).style.background='#ffffff';
			}
		}
	}
	
	if (thereturn==false) { alert('You must complete all required fields'); }
	return thereturn;
}

function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 	} 
} 

try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

window.onload = externalLinks;

jQuery(document).ready(function($) {
	$('body').supersleight();
	
	$("a.FBInlinexxx").fancybox({
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'centerOnScroll': true,
		'overlayShow': false
	});
	
	$('a.FBInline').click(function() {
		window.parent.$.fancybox({ 'href' : this.href, 'overlayColor' : 'black' , 'overlayOpacity' : '0.7' });
		return false;
	});

	
});

	function animateBackground()
	{
			$('#bgFader-inner').cycle({
				fx:     'fade',
				speed:  '3000',
				timeout: 8000
			});
	}

	function animateQuotes()
	{
			$('#quotesContainer').cycle({
				fx:     'fade',
				speed:  '3000',
				timeout: 8000
			});
			$('#quotesContainer').fadeIn(2000);
	}

Cufon.replace('h1', { fontFamily: 'MyriadLight' });
Cufon.replace('h2', { fontFamily: 'MyriadLight' });
Cufon.replace('h3', { fontFamily: 'MyriadLight' });
Cufon.replace('.quote', { fontFamily: 'Garamond' });
