jQuery.fn.mailme = function() {
    var at = / at /;
    var dot = / dot /g;
    this.each( function() {
        var addr = jQuery(this).text().replace(at,"@").replace(dot,".");
        var title = jQuery(this).attr('title')
        $(this)
            .after('<a href="mailto:'+addr+'" title="'+title+'">'+ addr +'</a>')
            .remove();
    });
};
$(document).ready(function() {
	window.addEventListener('SVGLoad', function() {
      // ready to work with SVG now
    }, false);						   
	$('#signUp a').click(function() {
		$('#signUpForm').slideToggle();
	});
	Cufon.replace('h1,.panel h4,.right,#contact p,.menu-conference-container a');
	$("#imgGal").fancybox({
			'width'				: 760,
			'height'			: 460,
			'autoScale'     	: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade'
	});
	
	$("a.fancybox").attr('rel', 'gallery').fancybox();
	
	$("#manual2").click(function() {
		$.fancybox([
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/1.jpg',
				'title'	: 'Athletics Track'
			},
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/2.jpg',
				'title'	: 'Climbing Wall'
			},
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/3.jpg',
				'title'	: 'Dance Studio'
			},
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/4.jpg',
				'title'	: 'Floodlit Tennis Courts'
			},
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/5.jpg',
				'title'	: 'Indoor Cricket'
			},
			{
				'href'	: '/wp-content/themes/sportspark/images/gallery/6.jpg',
				'title'	: 'Sportspark 50m Pool'
			}

		], {
			'padding'			: 40,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'fade',
			'type'              : 'image',
			'changeFade'        : 100
		});
	});
	
	$('#masthead').innerfade({ 
		speed: 'slow', 
		timeout: 10000, 
		containerheight: '377px' 
	});
	$('#sp').innerfade({ 
		speed: 'slow', 
		timeout: 10000, 
		containerheight: '58px' 
	});

	$('ul#menu-mainnav').superfish({
		animation: 
		{
			opacity:'show',
			height:'show'
		},
		autoArrows: false
	});
	
	$('span.mailme').mailme();
	
	$('#menu-info li a').hover(
		function(){
			$(this).fadeTo("slow",0.7);
		},
		function(){
			$(this).fadeTo("slow",1);             
		}
	);
	
	$('#fade').innerfade({ 
		speed: 'slow', 
		timeout: 4000, 
		containerheight: '230px' 
	});

});
    

