$(document).ready(function(){
	$('a[rel*=facebox]').facebox(); 
	setupZoom();
	
	$('.customerTable tr:odd').addClass('alt');
	
	bikeDetails.stripeTable();	
	bikeDetails.requestQuote();
	//bikeDetails.accordion();
	
	
	 // Anything Slider
	 $('.anythingSlider').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 6000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 600,             // How long the slide transition takes
		hashTags: true,                 // Should links change the hashtag in the URL?
		buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "Go",                // Start text
		stopText: "Stop",               // Stop text
		navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	 });
	
	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();
	
	
});

// for anything slider
function formatText(index, panel) {return index + "";}

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;
	});
}


