var $j = jQuery.noConflict();

$j(document).ready(function() 
{
	$j('#banner').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	$j('#portfolio').cycle({
		fx: 'scrollLeft' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	$j('#testimonials').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});

	/*$j('#access').mouseover(function () {
		$j('#logo').css("display","none");
		$j('#home-logo').css("display","block");
	});*/
	
	$j(".page-template-default #access, .page-template-default #menu_home").hover(
		function () {
			$j('#logo').css("display","none");
			$j('#home-logo').css("display","block");
		}, 
		function () {
			$j('#home-logo').css("display","none");
			$j('#logo').css("display","block");
		}
	);
		
	$j(".clicker-units").click(function()				// if any units clicker is clicked...
	{
		show_units( $j(this).data('clicker'), $j(this).data('label') );			// call the function to show units, with the data item related to this particular clicker
	});
	
	$j(".clicker-worktops").click(function()			// if any worktops clicker is clicked...
	{
		show_worktops( $j(this).data('clicker'), $j(this).data('label') );		// call the function to show worktops, with the data item related to this particular clicker
	});
	
	$j("#swatch").click(function()						// swap the swatch and the kitchen preview over - small preview and large swatch
	{
		$j('#mini-label').hide(1).delay(300).show(1);		// hide the 'click to zoom' label for the duration of the animation
		$j('#swatch').animate(
		{
			top: "0px",
			left: "0px",
			width: "512px",
			height: "288px"
		}, 300 );
		$j('#preview').animate(
		{
			top: "312px",
			left: "353px",
			width: "158px",
			height: "150px"
		}, 300 );
		$j('.preview-background').height(200);
		$j('.preview-background').width(355.5);
		$j('.preview-worktops').height(200);
		$j('.preview-worktops').width(355.5);
		$j('.preview-units').height(103);
		$j('.preview-units').width(355.5);
		$j('.preview-background').css('left', -170);
		$j('.preview-worktops').css('left', -170);
		$j('.preview-units').css('left', -170);
		$j('.preview-background').css('top', -45);
		$j('.preview-worktops').css('top', -45);
		$j('.preview-units').css('top', 52);		
		
		$j('#swatch').css( 'cursor', 'default' );		// set cursor to pointer for small panel only
		$j('#preview').css( 'cursor', 'pointer' );
	});
	
	$j("#preview").click(function()					// swap the swatch and the kitchen preview over - large preview and small swatch
	{
		$j('#mini-label').hide(1).delay(300).show(1);		// hide the 'click to zoom' label for the duration of the animation
		$j('#preview').animate(
		{
			top: "0px",
			left: "0px",
			width: "510px",
			height: "286px"
		}, 300 );
		$j('#swatch').animate(
		{
			top: "312px",
			left: "353px",
			width: "156px",
			height: "150px"
		}, 300 );
		$j('.preview-background').width(512);
		$j('.preview-background').height(288);
		$j('.preview-worktops').width(512);
		$j('.preview-worktops').height(288);		
		$j('.preview-units').width(512);
		$j('.preview-units').height(149);
		$j('.preview-background').css('left', 0);
		$j('.preview-worktops').css('left', 0);
		$j('.preview-units').css('left', 0);
		$j('.preview-background').css('top', -0);
		$j('.preview-worktops').css('top', 0);
		$j('.preview-units').css('top', 139);

		$j('#preview').css( 'cursor', 'default' );		// set cursor to pointer for small panel only
		$j('#swatch').css( 'cursor', 'pointer' );

	});
	
 });


function show_units ($unit_name, $units_label)
{
	$div_name = '#units_'+$unit_name;		// turn data name into full div identifier
	$j('.preview-units').hide();			// hide all units
	$j($div_name).show();					// show this unit
	
	$j('#selector-units-label').text($units_label);
}

function show_worktops ($worktop_name, $worktop_label)
{
	$div_name = '#worktop_'+$worktop_name;	// turn data name into full div identifier
	$j('.preview-worktops').hide();			// hide all worktops
	$j($div_name).show();					// show this worktop
	
	$div_name = '#swatch_'+$worktop_name;	// turn data name into full div intentifier
	$j('.swatches').hide(); 				// hide all swatches
	$j($div_name).show();					// show this swatch
	
	$j('#selector-worktops-label').text($worktop_label);

}
