/* ---------------------------------------------------- */
/* JQuery												*/
/* ---------------------------------------------------- */
$jQuery(document).ready(function() 
{
	
	/*############################################################################
	Preload any images used for rollovers, to avoid flickering or delay as they load
	############################################################################ */
	$jQuery.preloadImages = function()
	{
		for(var i = 0; i<arguments.length; i++)
		{
			$jQuery("<img>").attr("src", arguments[i]);
		}
	}
	$jQuery.preloadImages(
		"images/delete_off.gif", 
		"images/delete_on.gif",
		"css/drop3/blank_over.gif"
	);
	
	
	/*############################################################################
	Does the FadeIn and fadeOut on product boxes & catgeory boxes
	############################################################################ */
	$jQuery("div.product_bottom").hoverShade();
	$jQuery("div.category_bottom").hoverShade();
	
	
	/*############################################################################
	Start the header image display system
	############################################################################ */
	/* Hide the non Javascript image display */
	$jQuery("#imagedisplay").css("visibility","hidden");
	/* make the image area visible - and then fade it in */
	$jQuery("#image_rotate").css("visibility","visible");
	$jQuery("#image_rotate").fadeIn(2000);
	
	/* Fade through the images */
	$jQuery('#image_rotate').innerfade({ 
		'animationtype':    'fade',
		'speed': 			3000, 
		'timeout': 			6000, 
		'type': 			'sequence', 
		'containerheight': 	'203px'
	});
	
	/*############################################################################
	Fancybox popup image system - any link with the class 'popup'
	############################################################################ */
	$jQuery("a.popup").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	600, 
		'speedOut'		:	150, 
		'overlayShow'	:	true
	});

	
	/*############################################################################	
	Clear form elements when clicked on (after checking that contents are the defaults - so user entered content is not removed)
	############################################################################ */
	$jQuery("#username").focus(function() {
		if ( $jQuery("#username").val() == "Username" ) {$jQuery("#username").attr('value','');}
	});
	$jQuery("#password").focus(function() {
		if ( $jQuery("#password").val() == "Password" ) {$jQuery("#password").attr('value','');}	
	});
	
	/*############################################################################
	Initialise the Accordion system
	############################################################################ */
	$jQuery("#accordion").accordion({ 
		header: "h3",
		autoHeight: false,
		active: false,
		navigation: true,
		collapsible: true
	});
	 
});


/*############################################################################################################################
Functions for hiding and showing two password fields, in order that a text field can be swapped with a hidden password field
############################################################################################################################ */
function pwdFocus() {
	$jQuery('#fakepassword').hide();
	$jQuery('#password').show();
	$jQuery('#password').focus();
}
function pwdBlur() {
	if ($jQuery('#password').attr('value') == '') {
		$jQuery('#password').hide();
		$jQuery('#fakepassword').show();
	}
}
