$(document).ready(function(){
    /* Rollovers */
	var buttonStates = [ "-over", "-click", "-out" ];
    // add three state rollover effects on images
	$('img').mouseenter( function(){  
		for( i in buttonStates ) {  this.src = this.src.replace( buttonStates[ i ], "-over" );  } 
	}).mouseleave(  function(){  
		for( i in buttonStates ) {  this.src = this.src.replace( buttonStates[ i ], "-out" );  } 
	}).mousedown( function(){  
		for( i in buttonStates ) {  this.src = this.src.replace( buttonStates[ i ], "-click" );  } 
	}); 

	/*
	// add three state rollover effects on input button images
	$('input').mouseenter( function() { 
		 $(this).removeClass( "active"  );
		 $(this).addClass( "hover" );
	}).mouseleave(  function(){
		$(this).removeClass( "hover active"  );
	}).mousedown(  function(){
		$(this).removeClass( "hover"  );
		$(this).addClass( "active" );
	}); */
	
	// turn vehicle ctas opaque on mouseover and enable entire area clickable
	$('#featured .vehicle, .featured-vehicle, .boxEffect, .boxEffectModal').mouseenter( function(){ 
		$(this).find("img").stop().animate({ opacity: 0.7 }, 200); 
		$(this).find(".flv,.image").stop().animate({ opacity: 0.7 }, 200); 
	}).mouseleave( function(){ 
		$(this).find("img").stop().animate({ opacity: 1.0 }, 200);
		$(this).find(".flv, .image").stop().animate({ opacity: 0.0 }, 200); 
	}).mousedown( function() { 
	    if ( !$(this).is(".boxEffect" ) && !$(this).is(".boxEffectModal" ) )
			window.location = $(this).find("a:first").attr("href"); 
	});
		
	$("a").each( function() {
	
		if (( this.href.indexOf( "www.toyota.ca" ) != -1 )||( this.href.indexOf( "clubtoyota.toyota.ca" ) != -1 )){
			$(this).attr('target', '_blank');
			$(this).click( function(){
			
				_gaq.push(['_trackEvent', 'Visits - External Websites', 'Click - Toyota.ca', this.href ]);
		
				return confirm ("You are leaving Prairie Toyota Dealer's website and accessing Toyota Canada Inc.'s independently owned and operated national website. Toyota Canada's site and its Build & Price tool provide information, prices, rates and payments that are estimates based on MSRP and which do not include all costs and charges. See your local dealer for complete pricing details.");

			});
		}
	});
});
