// Flash Text Replacement
$(document).ready(function(){
	$('h1').flash(
		{ 
			src: 'http://www.flycompany.com.au/interface/flash/aller.swf', 
			wmode: 'transparent',
			flashvars: { 
				css: [
					'* { color: #1c9500; }'
				].join(' ')
			}
		},
		{ version: 7 },
		function(htmlOptions) {
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<span>'+this.innerHTML+'</span>';
			var $alt = $(this.firstChild);
			htmlOptions.height = $alt.height();
			htmlOptions.width = $alt.width();
			$alt.addClass('alt');
			$(this)
				.addClass('flash-replaced')
				.prepend($.fn.flash.transform(htmlOptions));						
		}
	);
	$('h2').flash(
		{ 
			src: 'http://www.flycompany.com.au/interface/flash/aller.swf', 
			wmode: 'transparent',
			flashvars: { 
				css: [
					'* { color: #1c9500; }'
				].join(' ')
			}
		},
		{ version: 7 },
		function(htmlOptions) {
			htmlOptions.flashvars.txt = this.innerHTML;
			this.innerHTML = '<span>'+this.innerHTML+'</span>';
			var $alt = $(this.firstChild);
			htmlOptions.height = $alt.height();
			htmlOptions.width = $alt.width();
			$alt.addClass('alt');
			$(this)
				.addClass('flash-replaced')
				.prepend($.fn.flash.transform(htmlOptions));						
		}
	);

});


// Banner Cycle
$(function() {
	$('.banner').cycle({
		timeout: 6000,
		speed: 1000
	});
});


// Testimonials Cycle
$(function() {
	$('#mini-testimonials').cycle({
		timeout: 5000,
		speed: 500
	});
});


// Form Validation
var varBE="";

function validateForm()
{
	//Don't show required
	if (!document.flycoform.fullname.value=='' || document.flycoform.fullname.value.indexOf(' ') > 1){document.getElementById('requiredfullname').style.display='none';}
	if (!document.flycoform.email.value=='' || document.flycoform.email.value.indexOf('@') > 1 || document.flycoform.email.value.indexOf('.com') > 1){document.getElementById('requiredemail').style.display='none';}
	if (!document.flycoform.address.value==''){document.getElementById('requiredaddress').style.display='none';}
	if (!document.flycoform.townsuburb.value==''){document.getElementById('requiredtownsuburb').style.display='none';}
	if (!document.flycoform.phone.value==''){document.getElementById('requiredphone').style.display='none';}
	if (!varBE==''){document.getElementById('requiredbookingenquiring').style.display='none';}
	if (!document.flycoform.message.value==''){document.getElementById('requiredmessage').style.display='none';}

	//Show required
	if (document.flycoform.fullname.value=='' || document.flycoform.fullname.value.indexOf(' ') < 1){document.getElementById('requiredfullname').style.display='block'; return false;}
	else if (document.flycoform.email.value=='' || document.flycoform.email.value.indexOf('@') < 1 || document.flycoform.email.value.indexOf('.com') < 1){document.getElementById('requiredemail').style.display='block'; return false;}
	else if (document.flycoform.address.value==''){document.getElementById('requiredaddress').style.display='block'; return false;}
	else if (document.flycoform.townsuburb.value==''){document.getElementById('requiredtownsuburb').style.display='block'; return false;}
	else if (document.flycoform.phone.value==''){document.getElementById('requiredphone').style.display='block'; return false;}
	else if (varBE==''){document.getElementById('requiredbookingenquiring').style.display='block'; return false;}
	else if (document.flycoform.message.value==''){document.getElementById('requiredmessage').style.display='block'; return false;}
	else {return true;}
};
