$(document).ready(function(){

	initpage();

	
});

function initpage(){

	//hide anything with class=hidden
	$('.hidden').hide();
	
	$('a.hider').click(function(e) {
	
		$(this).parent.parent.hide();
	
	});
	
	$("#glider").glide({
		speed: 1500,
		auto: true,
		continuous: true
	});
	
	//mark all facebox links as such
	$('a[rel*=facebox]').facebox();
	
	$('.pagelauncher').click(function(e) {
	
		e.preventDefault();
		
		var u = $(this).attr('href');
		
		fb(u);
		
	});
	
	$('#glider img').captify({

		// speed of the mouseover effect
		speedOver: 'fast',
		// speed of the mouseout effect
		speedOut: 'normal',
		// how long to delay the hiding of the caption after mouseout (ms)
		hideDelay: 500,	
		// 'fade', 'slide', 'always-on'
		animation: 'always-on',		
		// text/html to be placed at the beginning of every caption
		prefix: '',		
		// opacity of the caption on mouse over
		opacity: '0.7',					
		// the name of the CSS class to apply to the caption box
		className: 'caption-bottom',	
		// position of the caption (top or bottom)
		position: 'bottom',
		// caption span % of the image
		spanWidth: '100%'
	});
	
}

$(document).bind("reveal.facebox", function(){

	$('.contactform').submit(function() { 
	
		var options = { 
			target:        '#contactresponse', 
			success:       closeFacebox
		}; 

        $(this).ajaxSubmit(options);

        return false; 
		
    });

}); 

function closeFacebox(){

	$.facebox.close();
	
	initpage();
	
}

function fb(url) {

	$.facebox(function($) {
	
	$.get(url, function(data) { $.facebox(data) })
	
	})
	
} 

