//Fancybox
$(document).ready(function() {
	
	// Popimage: if the class is added to the image, add it to the parent anchor instead
	$("img.popimage").removeClass().parent('a').addClass('popimage');
	
	$(".newsletter").fancybox({
		'width'				: 400,
		'height'			: 80,
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'titleShow'			: 'false'
	});
	$(".map").fancybox({
		'width'				: 550,
		'height'			: 500,
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'titleShow'			: 'false'
	});
	$("a.popimage").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'image',
		'titleShow'			: 'false'
	});	
});

// Superfish dropdown initualisation
jQuery(function(){
	jQuery('ul#mainnav').superfish();
});


// Old popimage script converted to fancybxo
function popImage(imageURL,imageTitle){
	$("body").append("<a class='popImage' href="+imageURL+" title="+imageTitle+"></a>");
	$(".popImage").fancybox({
		'callbackOnClose':function(){
			$("#popImage").remove();
		}
	}).trigger('click');
};
