$(document).ready(function() {
	
	
	//find brand image and add hover class
	$('a.thumb img').hover(function() {
	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});
	
	
	// Home Cycle
	$('#flash').cycle({ 
    fx:    'fade', 
    speed:  1000 
 	});
	
	
	// Open links in new window when rel="external" is applyed
	$('a[@rel="external"]').click(function(){
		this.target = "_blank";
	});
	
	
	// Gallery Cycle
	$('#gallery')
	.after('<div id="gallery-nav">')
	.cycle({
		fx:'scrollLeft',
		speed:'fast',
		pager:'#gallery-nav'
	});
	
	// Position the gallery nav
	$("#gallery-nav").livequery(function(){
		$(this).find("a:gt(9)").remove();
		$(this).css('width',($(this).find("a").length * 42));
		$(this).css('margin-left',(($(this).find("a").length * 42) / 2) * -1);		
	})
	
	// CMX Form
	if(jQuery.browser.mozilla) {
		$('form.cmxform').hide().find('label:not(.nocmx)').each(function(){
			var $labelContent = $(this).html();
			var $labelWidth = $(this).css('width');
			$(this).empty();
			$(this).append('<span style="display: block; width: '+$labelWidth+';">');
			$(this).prepend('</span>');
			$(this).css('display', '-moz-inline-box');
			$(this).find('span').html($labelContent);
			$('form.cmxform').show();
		});
	};           
	
	// Remove border on last li in forms
	
	$('#add-to-cart').find('li:last').css('border', 'none');
	
	$('#contact').find('li:last').css('border', 'none');
	
});


	

