/* ---------------------------------------------------- */
/* JQuery												*/
/* ---------------------------------------------------- */
$jQuery(document).ready(function() 
{
	/*############################################################################
	Preload any images needed
	############################################################################ */
	$jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } }
	$jQuery.preloadImages("images/skype-on.gif", "images/linkedin-on.gif", "images/facebook-on.gif", "images/twitter-on.gif", "images/chat-on.gif", "images/black_arrow_big.png" );
	
	/*############################################################################
	Fancybox popup image system - any link with the class 'popup'
	############################################################################ */
	$jQuery("a.popup, a.popup-highlight").fancybox({
		'transitionIn'		:	'fade',
		'transitionOut'		:	'fade',
		'speedIn'			:	750, 
		'speedOut'			:	450, 
		'overlayShow'		:	true,
		'overlayColor'		:	'#000000',
		'overlayOpacity'	:	0.7,
		'autoScale'			:	false,
		'width'				:	930,
		'height'			:	400,
		'scrolling'			:	'no',
		'margin'			:	0,
		'padding'			:	0,
		'type' 				:	'iframe'
	});
	
	/*############################################################################
	Fancybox popup image system for larger scale photographs
	############################################################################ */
	$jQuery("a.photos").fancybox({
		'transitionIn'		:	'fade',
		'transitionOut'		:	'fade',
		'speedIn'			:	750, 
		'speedOut'			:	450, 
		'overlayShow'		:	true,
		'overlayColor'		:	'#000000',
		'overlayOpacity'	:	0.7,
		'autoScale'			:	false,
		'scrolling'			:	'no',
		'margin'			:	0,
		'padding'			:	0,
		'type' 				:	'image'
	});
	
	/*############################################################################
	Social Media on-hover image swaps
	############################################################################ */
	$jQuery("img.social-media-icon").hover(
		function()
		{
			this.src = this.src.replace("-off","-on");
		},
		function()
		{
			this.src = this.src.replace("-on","-off");
		}
	);
	
	/*############################################################################	
	Prevent the default search box text from being submitted as a search phrase
	############################################################################ */
	$jQuery("#searchbox").submit(function() {
		if ( $jQuery("input.searchbox").val() == "" ) {return false;}
	});
	
	
	/*############################################################################	
	Clear contact form contents on click, and repopulate with default values if nothing entered
	############################################################################ */
	$jQuery("#message").focus(function() {
		if ( $jQuery("#message").val() == "your message" ) {$jQuery("#message").attr('value','');}
	});
	$jQuery("#message").blur(function() {
		if ( $jQuery("#message").val() == "" ) {$jQuery("#message").attr('value','your message');}
	});
	$jQuery("#contactname").focus(function() {
		if ( $jQuery("#contactname").val() == "your name" ) {$jQuery("#contactname").attr('value','');}
	});
	$jQuery("#contactname").blur(function() {
		if ( $jQuery("#contactname").val() == "" ) {$jQuery("#contactname").attr('value','your name');}
	});
	$jQuery("#number").focus(function() {
		if ( $jQuery("#number").val() == "your number" ) {$jQuery("#number").attr('value','');}
	});
	$jQuery("#number").blur(function() {
		if ( $jQuery("#number").val() == "" ) {$jQuery("#number").attr('value','your number');}
	});
	$jQuery("#email").focus(function() {
		if ( $jQuery("#email").val() == "your email" ) {$jQuery("#email").attr('value','');}
	});
	$jQuery("#email").blur(function() {
		if ( $jQuery("#email").val() == "" ) {$jQuery("#email").attr('value','your email');}
	});
	
});

