



function highlightThis(obj)
{
	$('a.navFour').removeClass('currentBlock');
	$(obj).addClass('currentBlock');
}






function chooseSign(me, product_id, image_front, image_back)
{
	if ( !product_id )
	{
		return;
	}
		
	// $('input[type=radio]', me).attr('checked', 'checked');
	$('#signBuilderCanvas_front').html('<img src="/_getImage.php?image=' + image_front + '" alt="Product Image Front" />');
	$('#signBuilderCanvas_back').html('<img src="/_getImage.php?image=' + image_back + '" alt="Product Image Back" />');
	
	$('#signAlternativeImage option[value*=' + image_front + ']').attr('selected', 'selected');
	$('#product_id').val(product_id);
	$('#sign_background_front').val(image_front);
	$('#sign_background_back').val(image_back);
	
	// disabled the selects, enable ony this one
	//$('.signAlternativeSelect').attr('disabled', 'disabled');
	$('#signAlternativeImage_' + product_id).attr('disabled', false);
	
	centerBuilderImage();
	
}



function centerBuilderImage()
{
	setTimeout("doNothing()", 500);
	
	var e = '#signBuilderCanvas_front img#builderImage';
	var w = $(e).width();
	var h = $(e).height();
	if(h > 0){
		var r = w / h;
		var b = 330;
		if ( h > 50 && h > b )
		{
			$(e).height(b);
			var h = $(e).height();
			$(e).width(h * r);
		}
		var marginTop = Math.floor((b  - h) / 2);
	}else{
		var marginTop = 0;
	}
	$(e).css({marginTop: marginTop + 'px'});
	
	return;
}


function doNothing()
{
	return;
}



function centerCenterImage()
{
	$('.centerCenter img').each(function()
	{
		var w = $(this).width();
		var h = $(this).height();
		var r = w / h;
		var b = 200;
		if ( h > 30 && h > b )
		{
			$(this).height(b);
			var h = $(this).height();
			$(this).width(h * r);
		}
		var marginTop = Math.floor((b  - h) / 2);
		$(this).css({marginTop: marginTop + 'px'});
		marginTop = 0;
		
	});
	
}







// copy address details into delivery address fields...
function copyAddressToDelivery()
{
	// rewrite this you lazy ****. 
	// note to self:
	// surely it took longer to type out that it would to write a nice loop
	$('#cust_del_title').attr('value', 		$('#cust_title').attr('value'));
	$('#cust_del_first_name').attr('value', $('#cust_first_name').attr('value'));
	$('#cust_del_last_name').attr('value', 	$('#cust_last_name').attr('value'));
	$('#cust_del_address1').attr('value', 	$('#cust_address1').attr('value'));
	$('#cust_del_address2').attr('value', 	$('#cust_address2').attr('value'));
	$('#cust_del_town').attr('value', 		$('#cust_town').attr('value'));
	$('#cust_del_county').attr('value', 	$('#cust_county').attr('value'));
	$('#cust_del_postcode').attr('value', 	$('#cust_postcode').attr('value'));
	$('#cust_del_country_id').attr('value', $('#cust_country_id').attr('value'));
	$('#cust_del_telephone').attr('value', 	$('#cust_telephone').attr('value'));
	$('#cust_del_mobile').attr('value', 	$('#cust_mobile').attr('value'));
	$('#cust_del_fax').attr('value', 		$('#cust_fax').attr('value'));
	$('#cust_del_email').attr('value', 		$('#cust_email').attr('value'));
}




