$(document).ready(function(){
//////Add target="_blank"
	$('.newtab').each(function(){$(this).attr('target','_blank')});

//////Paddles main nav dropdown
	$('#navbar div').mouseenter(function(){
		$(this).find('ul.subnav').show();
	}).mouseleave(function(){
		$(this).find('ul.subnav').hide();	
	});

///////Find Dealer header
	$('#finddealer_btn').toggle(function(){
		$(this).addClass('active');
		$('#dealer_search').show();
		return false;
	}, function(){
		$(this).removeClass('active');
		$('#dealer_search').hide();	
		return false;
	});
	

////////Fancy Box
	/* Close the fancybox when you submit a form*/

  
    $("a.fancy").fancybox({
		'titlePosition'  : 'inside',
		'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000'
	});
	
	
	$(".addmedia").fancybox({
		'overlayOpacity'	: 0.7,
		'overlayColor'		: '#000',
		'width'				: 340,
		'height'			: 300,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$("a.fancy_vid").click(function() {
	$.fancybox({
			'titlePosition'  : 'inside',
			'overlayOpacity'	:	0.7,
			'overlayColor'		:	'#000',
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'		: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
	
	
//////Side by side comparison
	/*$('a.comparison').click(function(){
		$('.compare_bar').show();
		return false;
	});*/
	
	blankColumn = $('#col1').html();
	

	function loadPaddle(obj){
		paddleName = obj.attr('rel'); 
		paddleCode = $('.hidden_paddles').find('.'+paddleName).html();
		obj.addClass('active');
		$(targetColumn).html(paddleCode);
	}
	
	$('.compare_bar a').toggle(function(){
		
		if ($('#col1').html() == blankColumn) {
			targetColumn = '#col1';
			loadPaddle($(this));
		}
		else if ($('#col2').html() == blankColumn) {
			targetColumn = '#col2';
			loadPaddle($(this));
		}
		else if ($('#col3').html() == blankColumn) {
			targetColumn = '#col3';
			loadPaddle($(this));
		}
		else if ($('#col4').html() == blankColumn) {
			targetColumn = '#col4';
			loadPaddle($(this));
		}
		return false;
		
	},function(){
		paddleName = $(this).attr('rel'); 
		targetColumn = $('.maincontent').find('#'+paddleName).parent().attr('id');
		$('#'+targetColumn).html(blankColumn);
		$(this).removeClass('active');
		return false;	
	});
	
///////Form Validation
	$("#mailing_list, #contact_forms, #warranty_forms").validate();
});



