/* Author: Sten Van den Bergh
 * Project: Valuendo
 * Glue
 */

$(document).ready(function() {
	// Handler for .ready() called.
  
	// External links
	$("a[href^='http:']:not([href*='" + window.location.host + "'])").each(function() {
		if( !$(this).hasClass('fancybox') )
		{
			$(this).click(function()
			{
			    window.open(this.href); // pop a new window
			    return false; // return false to keep the actual link click from actuating
			});
		}
	});
	
	// Form Validation
	$("#freeform").validate({
		errorPlacement: function(error, element) {
			element.parent().append(error);
		}
	});
	
	// Fancybox
	$("a[rel=fancy_group]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	// jQuery UI Tabs
	$( "#tabs" ).tabs();
	
});
