$(document).ready(function(){
	$('a[rel*=facebox]').facebox(); 
	setupZoom();
	
	$('.customerTable tr:odd').addClass('alt');
	
	bikeDetails.stripeTable();	
	bikeDetails.requestQuote();
	//bikeDetails.accordion();
	
	subnav.overlayShadow();
	
	$('.forgotPW').click(function(){
		ColdFusion.Window.show('forgotPWWindow');
		return false;
	});
	
	$('.sendmessage').click(function(){
		ColdFusion.Window.show('yourMessageWindow');
		return false;
	});
	
	$('#su_billing_country').change(function(){		
		if($(this).val()=='US'){
			$('#selectBillingState').show();
			$('#selectBillingProvince').hide();
		}else{
			$('#selectBillingProvince').show();
			$('#selectBillingState').hide();
		}		
	});
	
	$('#su_shipping_country').change(function(){	
		if($(this).val()=='US'){
			$('#selectShippingState').show();
			$('#selectShippingProvince').hide();
		}else{
			$('#selectShippingProvince').show();
			$('#selectShippingState').hide();
		}		
	});
	
	tabControl.init();
	
	
});

function divSetup(){
	$('a[rel*=facebox]').facebox(); 
	setupZoom();
}

bikeDetails = {};
subnav = {};

bikeDetails.stripeTable = function(){
   $('#bikeAttributes tr:odd').addClass('alt');
}

bikeDetails.requestQuote = function(){
	if ($.browser.version != 7 && $.browser.version != 6) {
		$('.quotetrigger').click(function(){
			$('.quotedrawer').slideToggle();
		});
	}else{
		$('.quotetrigger').css('position','relative');
		$('.quotetrigger').append('<a href="#" class="ie7coverlink"></a>');
		$('.quotetrigger a').click(function(){
			$('.quotedrawer').slideToggle();
		});				
	}
}

//bikeDetails.accordion = function(){
//	$('#bikeAttributes h3:first').toggleClass('selected');
//	$('#bikeAttributes .contentdrawer:first').show();
//	if ($.browser.version != 7 && $.browser.version != 6) {
//		$('#bikeAttributes h3').click(function(){
//			$(this).toggleClass('selected');
//			$(this).next().slideToggle();
//		});
//	}else{
//		$('#bikeAttributes h3').css('position','relative');
//		$('#bikeAttributes h3').append('<a href="#" class="ie7coverlink"></a>');
//		$('#bikeAttributes h3 a').click(function(){
//			$(this).parent().toggleClass('selected');
//			$(this).parent().next().slideToggle();
//		});		
//	}
//}


subnav.overlayShadow = function(){
	if($.browser.version !=6)
	{
		$('.subnav li').each(function(){
			var shadowWidth = $(this).find('a').width() + 15;
			$(this).append("<span></span>");
			$(this).find('span').css('width',shadowWidth);
			
		});

		$('.subnav li').mouseover(function(){
			$('.subnav li a').removeClass('active');
			$(this).find('a').toggleClass('active');
			
			if($.browser.version == 7){
				//alert($(this).find('a').html());
			}
			
		});
		
		$('.subnav li').mouseout(function(){
			$('.subnav li a').removeClass('active');
		})
		
		$('.subnav li').click(function(){
			var URL = $(this).find('a').attr('href');
			window.location.href = URL;
		});
	}	
}

function initSIFR(){
sIFR.replace(grunge, {
  fixFocus:true,
  selector: '.orangeheader',
	css: [
      '.sIFR-root { font-size:14px; color:#ee8315; font-weight: normal; text-transform:uppercase; }',
	  'strong{font-size:14px; color:#ffffff; font-weight: normal; text-transform:uppercase; }'
      ],
  wmode: 'transparent'
});
sIFR.replace(grunge, {
  fixFocus:true,
  selector: '.whiteheader',
	css: [
      '.sIFR-root { font-size:12px; color:#FFFFFF; font-weight: normal; text-transform:uppercase; }'
      ],
  wmode: 'transparent'
});
}

var tabControl = {};
tabControl.init = function(){
	$('#tabs a').click(function(){
	
		var p = '#'+$(this).parent().parent().parent().attr('id');
		
		$(p +' #tabs a').removeClass('active');
		$(this).addClass('active');
		
		$(p + ' .tabbox').hide();
		$($(this).attr('href')).show();
		
		return false;
	});
}

//$(function() {
  //  var img = new Image();
   // $(img).load(function() {    // when image has loaded...
       // $(this).css('display', 'none'); // hide image by default
       // $('#tab1').removeClass('loading').append(this);   // remove 'div#loader.loading' class (loading anim gif), then insert our image in 'loader' div
       // $(this).fadeIn('slow'); // fade image in
   // }).attr('src', 'pic.jpg');
//});

