/* 
javascript for stonesmith.co.uk

submenu dropdown and fixes for rubbish browsers 

*/

$(function()
{

	// about subnav control
	$('li#m1,#subm1').mouseover(function()
	{
		$('#subm1').css({'display':'block', 'opacity':'0.95'});
	}).mouseout(function()
	{
		$('.submenu1').css('display', 'none');
	});
	
	$('#subm1').mouseover(function()
	{
		$('#m1a').addClass('current');
	}).mouseout(function()
	{
		$('#m1a').removeClass('current');
	});

	
	// ie 7 fix menu
	if ( $.browser.msie && $.browser.version == 7 )
	{
		$('#nav').css('margin-top', '70px');
	}	

	// ie 6 fix menu
	if ( $.browser.msie && $.browser.version == 6 )
	{
		$('#nav').css({'width':'600px', 'margin-top':'70px'});
		$('#nav ul').css({'margin':'0'});
		$('#nav ul.submenu1').css({'left':'-526px'});
	}	
	
	
	// fix safari nav
	if ( $.browser.safari )
	{
		$('#nav ul.submenu1').css({'left':'41px'});
	}

	
	
	
	
	// image swaps - details pages
	$('.detailImagesBottom img').click(function()
	{
		$('img#detail').attr('src', $(this).attr('src'));
		
		// get the text from longdesc and turn it into an object...
		var wh = eval('(' + $(this).attr('title') + ')');
		var boxHeight  = 366;
		var paddingTop = (boxHeight - wh.height) / 2;
		var newBoxHeight = boxHeight - paddingTop;
		
		// detailImagesTop (366px high) needs padding from the top depending height of image.
		// need to remove the top margin from the image too - used only for the first image loaded...
		$('.detailImagesTop img').css('margin-top', 0);
		$('.detailImagesTop').css({'height':newBoxHeight, 'padding-top':paddingTop});
		
	});
	
	
	
	
	
	// required fields
	$('label.required').append('<span style="color:#a00;margin:0 0 0 0.25em;">*</span>');
	
	
	
	
	// featured sratpoarepfe
	$('#featuredStrapper').css('opacity', '0.9');
	
	
	
});