// JavaScript Document
$(document).ready(function(){
	
	//LavaLamp menu
	lavaLampMenu();
	
	//Faq toggle
	faq();
	
	//Homepage banner rotation
	bannerCycle();
	
	//Videos in modal window
	video();

});

//LavaLamp effect for main menu
function lavaLampMenu() {
	$("#menu").lavaLamp({
        fx: "backout",
        speed: 700
    });
}

//Homepage banner rotation
function bannerCycle() {
	$('#homeBanners').cycle({
		fx: 'fade', pause: 0, speed: 2000, timeout: 10000, cleartype: true, cleartypeNoBg: true
	});
	
	$('#homeTestQuotes').cycle({
		fx: 'fade', pause: 0, random: 1, pause: 1, timeout: 8000, cleartype: true, cleartypeNoBg: true
	});
}

//FAQ toggle
function faq(){
	$(".As").hide();
	$(".Qs").click(function (){
		$(this).parent().find(".As").toggle("fast");	
	});
}

function video(){
	try {
		$("#video").overlay({
		    top: 0, left: 0, // custom position 
	        // when overlay is closed, delete the player 
        	onClose: function() { 
	            $("#video").unload();
        	    $("#video").text(""); //dummy text to make this thing work in IE (sigh) 
	        }, 
		    api: true // we want to use the programming API   
		}).load(); // load it immediately after the construction 
	} catch (e) {}
	
	try {
		$("a[rel]").overlay({
		    top: 0, left: 0, // custom position
	        // when overlay is closed, delete the player
        	onLoad: function() {
        		$("#videoClick").load();
	        },
        	onClose: function() {
	            $("#videoClick").unload();
        	    //$("#videoClick").text(""); //dummy text to make this thing work in IE (sigh) 
	        }, 
		    api: true // we want to use the programming API 
		})
	} catch(e) {}
}