$(document).ready(function(){

	//all hover and click logic for buttons
	$(".fg-button:not(.ui-state-disabled)")
	.hover(
		function(){ 
			$(this).addClass("ui-state-hover"); 
		},
		function(){ 
			$(this).removeClass("ui-state-hover"); 
		}
	)
	.mousedown(function(){
			$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
			if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
			else { $(this).addClass("ui-state-active"); }	
	})
	.mouseup(function(){
		if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button,  .fg-buttonset-multi .fg-button') ){
			$(this).removeClass("ui-state-active");
		}
	});
	
	$('#large_banner_images').cycle({
		fx: 'fade',
		speed: 1500,
		timeout: 8000,
		cleartype: 1
	});
	
	$('#news_ticker').cycle({ 
		fx:      'fade',
		pause:  1,
		timeout:  5000,
		cleartype:  0 // enable cleartype corrections 
	});
	
	$('#testimonial_container').cycle({ 
		fx:      'fade',
		pause:  1,
		timeout:  10000,
		cleartype:  1 // enable cleartype corrections 
	});
	
	$(".fancybox").fancybox({
		'width'				: 500,
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'overlayOpacity'	: 0.6,
		'overlayColor'		: '#000000'
	});
	
	$(".fancybox_welsh").fancybox({
		'width'				: 500,
		'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'overlayOpacity'	: 0.6,
		'overlayColor'		: '#000000',
		'onClosed'			:function() {
			window.location = "/change_language/?language=cymraeg&page_name=index";
		}
	});
	
});
