$(function() {
	// Home - Flash
	if($('body#home').length) {
		var flashvars = {
			JSON_path: "/2five/_ui/skin/swf/home/json/hero.json",
			SWF_path: "/2five/_ui/skin/swf/home/swfs/"
		};
		var params = {
			wmode: 'transparent'
		};
		var attributes = {};
   		swfobject.embedSWF("/2five/_ui/skin/swf/home/hero.swf", "flashcontent", "100%", "475", "9","expressInstall.swf", flashvars, params, attributes);
	}
	
	
	// Tabs Init
	if ($('body.leftmenu-explore2').length) {
		$("#tabs").tabs({selected:1});
	}
	else {
		$("#tabs").tabs();
	}
	
	
	// Tabs Links
	$('ul.ui-tabs-nav a', '#explore').unbind('click').click(function() {
		window.location.href = $(this).attr('rel');
		return false;
	});
	
	
	// Colorbox
	$('a[rel^=gallery-]', '#right-content').colorbox();
	
	
	// Validate
	$("#frmContact").validate({
		rules: {
			txtFname: "required",
			txtLname: "required",
			txtCompany: {
				required: false
			},
			txtEmail: {
				required: true,
				email: true
			},
			txtMessage: "required"
		},
		messages: {
			txtFname: "Please enter your firstname",
			txtLname: "Please enter your lastname",
			txtEmail: "Please enter a valid email address",
			txtMessage: "Please enter your message"
		},
		submitHandler: function() { 
			form.submit(); 
		}
	});
    
    // Equal columns (find a dealer)
    $('div.multi-column ul', '#content').each(function() {
        // Find the split point
        var count = $('li', this).length;
        var split = Math.ceil(count/2) - 1;
        
        // Move everything after the split into a new list
        $(this).after('<ul class="second-column></ul>');
        $('li:gt('+ split +')', this).prependTo('ul.second-column', this);
        
        // Clean up
        $(this).parent().addClass('multi-column-applied');
        $(this).parent().append('<div class="clear-both"></div>');
    });
	
});
